Version Description
Download this release
Release Info
Developer | garyc40 |
Plugin | WP eCommerce |
Version | 3.8.8-beta |
Comparing to | |
See all releases |
Code changes from version 3.8.7.4 to 3.8.8-beta
- .phptidy-config.php +0 -24
- readme.txt +37 -7
- woo-integration/css/main_frame_style.css +0 -12
- woo-integration/css/style.css +0 -155
- woo-integration/js/script.js +0 -50
- woo-integration/options_presentation.php +0 -16
- woo-integration/woo_integration.php +0 -62
- wp-shopping-cart.php +1 -1
- wpsc-admin/admin-form-functions.php +2 -2
- wpsc-admin/admin.php +168 -32
- wpsc-admin/ajax-and-init.php +443 -535
- wpsc-admin/css/admin.css +227 -64
- wpsc-admin/css/arrows.png +0 -0
- wpsc-admin/css/loading-small.gif +0 -0
- wpsc-admin/css/plus-minus.png +0 -0
- wpsc-admin/css/settingspage.css +270 -28
- wpsc-admin/display-coupons.php +72 -15
- wpsc-admin/display-debug.page.php +1 -1
- wpsc-admin/display-items.page.php +1 -15
- wpsc-admin/display-options-settings.page.php +8 -225
- wpsc-admin/display-sales-logs.php +328 -546
- wpsc-admin/display-update.page.php +1 -1
- wpsc-admin/includes/display-items-functions.php +53 -36
- wpsc-admin/includes/product-functions.php +171 -168
- wpsc-admin/includes/products.php +46 -25
- wpsc-admin/includes/purchase-log-list-table-class.php +464 -0
- wpsc-admin/includes/purchase-logs-page/bulk-delete-confirm.php +9 -0
- wpsc-admin/includes/purchase-logs-page/item-details.php +148 -0
- wpsc-admin/includes/purchase-logs-page/list-table.php +91 -0
- wpsc-admin/includes/purchase-logs-page/packing-slip.php +160 -0
- wpsc-admin/includes/purchase-logs-page/upgrade.php +45 -0
- wpsc-admin/includes/purchlogs_upgrade.php +0 -103
- wpsc-admin/includes/save-data.functions.php +22 -6
- wpsc-admin/includes/settings-pages/checkout.php +0 -231
- wpsc-admin/includes/settings-pages/gateway.php +0 -151
- wpsc-admin/includes/settings-pages/import.php +0 -170
- wpsc-admin/includes/settings-pages/marketing.php +0 -108
- wpsc-admin/includes/settings-pages/shipping.php +0 -274
- wpsc-admin/includes/settings-pages/taxes.php +0 -188
- wpsc-admin/includes/{settings-pages → settings-tabs}/admin.php +23 -41
- wpsc-admin/includes/settings-tabs/checkout.php +466 -0
- wpsc-admin/includes/settings-tabs/gateway.php +181 -0
- wpsc-admin/includes/{settings-pages → settings-tabs}/general.php +56 -54
- wpsc-admin/includes/settings-tabs/import.php +162 -0
- wpsc-admin/includes/settings-tabs/marketing.php +87 -0
- wpsc-admin/includes/{settings-pages → settings-tabs}/presentation.php +201 -245
- wpsc-admin/includes/settings-tabs/shipping.php +284 -0
- wpsc-admin/includes/settings-tabs/taxes.php +248 -0
- wpsc-admin/includes/tax_and_shipping.php +2 -10
- wpsc-admin/includes/updating-functions.php +6 -6
- wpsc-admin/includes/walker-variation-checklist.php +42 -38
- wpsc-admin/js/admin.js +36 -428
- wpsc-admin/js/purchase-logs.js +135 -0
- wpsc-admin/js/settings-page.js +884 -0
- wpsc-admin/js/sortable-table.js +102 -0
- wpsc-admin/js/variations.js +222 -46
- wpsc-admin/settings-page.php +590 -0
- wpsc-core/images/drag.png +0 -0
- wpsc-core/js/tinymce3/window.php +1 -1
- wpsc-core/wpsc-constants.php +5 -4
- wpsc-core/wpsc-functions.php +64 -4
- wpsc-core/wpsc-installer.php +20 -24
- wpsc-includes/ajax.functions.php +37 -37
- wpsc-includes/cart.class.php +111 -82
- wpsc-includes/category.functions.php +45 -6
- wpsc-includes/checkout.class.php +75 -51
- wpsc-includes/coupons.class.php +43 -41
- wpsc-includes/display.functions.php +5 -5
- wpsc-includes/form-display.functions.php +3 -3
- wpsc-includes/image_processing.php +3 -3
- wpsc-includes/merchant.class.php +41 -8
- wpsc-includes/misc.functions.php +23 -11
- wpsc-includes/processing.functions.php +14 -13
- wpsc-includes/product-template.php +8 -6
- wpsc-includes/productfeed.php +1 -1
- wpsc-includes/purchaselogs.class.php +53 -25
- wpsc-includes/shipping.helper.php +13 -10
- wpsc-includes/shopping_cart_functions.php +1 -1
- wpsc-includes/theme.functions.php +9 -7
- wpsc-includes/variations.class.php +61 -46
- wpsc-merchants/GoogleCheckout-XML.php +257 -61
- wpsc-merchants/chronopay.php +8 -6
- wpsc-merchants/paypal-express.merchant.php +37 -11
- wpsc-merchants/paypal-pro.merchant.php +5 -5
- wpsc-merchants/paypal-standard.merchant.php +5 -5
- wpsc-shipping/library/shipwire_functions.php +3 -3
- wpsc-shipping/tablerate.php +66 -42
- wpsc-shipping/ups_20.php +27 -32
- wpsc-shipping/usps_20.php +58 -66
- wpsc-shipping/weightrate.php +67 -41
- wpsc-taxes/controllers/taxes_controller.class.php +27 -27
- wpsc-taxes/models/taxes.class.php +25 -19
- wpsc-taxes/taxes_module.php +7 -94
- wpsc-taxes/view/js/taxes-functions.js +0 -167
- wpsc-theme/functions/wpsc-transaction_results_functions.php +34 -23
- wpsc-theme/functions/wpsc-user_log_functions.php +5 -5
- wpsc-theme/wpsc-cart_widget.php +3 -3
- wpsc-theme/wpsc-shopping_cart_page.php +8 -0
- wpsc-theme/wpsc-single_product.php +1 -0
- wpsc-widgets/admin_menu_widget.php +0 -4
- wpsc-widgets/price_range_widget.php +7 -2
.phptidy-config.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// This is a config file for PHPtidy
|
3 |
-
// http://developer.berlios.de/projects/phptidy/
|
4 |
-
|
5 |
-
$project_files = array('*.php',
|
6 |
-
'merchants/*.php',
|
7 |
-
'shipping/*.php',
|
8 |
-
'merchants/*.php',
|
9 |
-
'updates/*.php',
|
10 |
-
'widgets/*.php',
|
11 |
-
'wpsc-includes/*.php',
|
12 |
-
'wpsc-admin/*.php',
|
13 |
-
'wpsc-admin/includes/*.php',
|
14 |
-
'wpsc-admin/includes/settings-pages/*.php');
|
15 |
-
|
16 |
-
$default_package = "WP e-Commerce";
|
17 |
-
$add_file_docblock = TRUE;
|
18 |
-
$add_functions_docblock = TRUE;
|
19 |
-
$add_doctags = TRUE;
|
20 |
-
$fix_docblock_format = TRUE;
|
21 |
-
$fix_docblock_space = TRUE;
|
22 |
-
$add_blank_lines = FALSE;
|
23 |
-
|
24 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: mufasa, jghazally, valentinas, mychelle, garyc40
|
3 |
Donate link: http://getshopped.org
|
4 |
Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
|
5 |
-
Requires at least: 3.
|
6 |
-
Tested up to: 3.
|
7 |
Stable tag: 3.8.7.4
|
8 |
|
9 |
WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
|
@@ -156,11 +156,41 @@ After upgrading from earlier versions look for link "Update Store". This will up
|
|
156 |
|
157 |
|
158 |
== Changelog ==
|
159 |
-
= 3.8.
|
160 |
-
*
|
161 |
-
|
162 |
-
|
163 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
= 3.8.7.2 =
|
166 |
* New: Support for g:availability to Google Merchant Centre feed. Props bbaskets & longercat
|
2 |
Contributors: mufasa, jghazally, valentinas, mychelle, garyc40
|
3 |
Donate link: http://getshopped.org
|
4 |
Tags: e-commerce, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
|
5 |
+
Requires at least: 3.1
|
6 |
+
Tested up to: 3.3
|
7 |
Stable tag: 3.8.7.4
|
8 |
|
9 |
WP e-Commerce is a free WordPress Shopping Cart Plugin that lets customers buy your products, services and digital downloads online.
|
156 |
|
157 |
|
158 |
== Changelog ==
|
159 |
+
= 3.8.8 =
|
160 |
+
* New: Actions for bulk actions on sales page: wpsc_sales_log_process_bulk_action, wpsc_sales_log_extra_tablenav
|
161 |
+
* New: Allow variation checkboxes to be collapsed & expanded without having to tick the variation set checkbox itself.
|
162 |
+
* New: Extra hooks during checkout cart display: wpsc_before_checkout_cart_row, wpsc_before_checkout_cart_item_image, wpsc_after_checkout_cart_item_image, wpsc_before_checkout_cart_item_name, wpsc_after_checkout_cart_item_name, wpsc_after_checkout_cart_row
|
163 |
+
* New: Filter for ordering the sales logs: wpsc_purchase_logs_orderby.
|
164 |
+
* New: Filter wpsc_cart_shipping.
|
165 |
+
* New: Filter wpsc_default_shipping_quote.
|
166 |
+
* New: Filter wpsc_item_shipping_amount_db.
|
167 |
+
* New: Filter wpsc_paypal_standard_post_data.
|
168 |
+
* New: Filter wpsc_product_permalink_cat_slug.
|
169 |
+
* New: Filter wpsc_product_postage_and_packaging.
|
170 |
+
* New: Filter wpsc_shipping_quote_value.
|
171 |
+
* New: Filters wpsc_calculate_total_tax, wpsc_coupons_amount.
|
172 |
+
* New: Settings Page API.
|
173 |
+
* New: Some helpful filters to download_csv function: wpsc_purchase_log_start_end_csv, wpsc_purchase_log_month_year_csv, wpsc_purchase_log_month_year_csv, wpsc_purchase_log_csv_headers, wpsc_purchas_log_csv_output
|
174 |
+
* New: Variation Drag & Drop sorting.
|
175 |
+
* Change: Display file names instead of the product name on the downloads page.
|
176 |
+
* Change: Improved variation UI in Product Edit page.
|
177 |
+
* Change: In General Settings page, when changing country, load region / state list using AJAX instead of page reload.
|
178 |
+
* Change: Only display variants' associated terms in Product Edit page rather than including the parent product name, which is redundant and cluttered.
|
179 |
+
* Change: Subtle UX tweaks for Store Settings page.
|
180 |
+
* Fix: $wpsc_query->query_vars['wpsc_product_category'] not always set on product page with hierarchical category permalinks.
|
181 |
+
* Fix: Cannot add new Checkout field.
|
182 |
+
* Fix: Cannot re-re-send buyer receipt.
|
183 |
+
* Fix: Double <p> tag with wpec_taxes_display_tax_bands() on product edit page.
|
184 |
+
* Fix: Fatal error when trying to include a non-existent admin file.
|
185 |
+
* Fix: Hide Google Feed information from display
|
186 |
+
* Fix: Make the WP e-Commerce 3.8.x activation/installation routine much more efficient.
|
187 |
+
* Fix: Total Quantity check fails for coupon codes.
|
188 |
+
* Fix: USPS: "FLATE RATE ENVELOPE" should be changed to "VARIABLE" to allow for shipping quotes to be based on weight.
|
189 |
+
* Fix: Use ->add_help_tab() to support WP 3.3 admin screen API.
|
190 |
+
* Fix: Using discount causes Paypal Express to calculate wrong total amount.
|
191 |
+
* Fix: get_the_content() is not enough in product feed.
|
192 |
+
* Fix: settings page JS compatibility issue with Firefox.
|
193 |
+
* Fix: wpsc_get_template_file_url() function is inefficient and causes 10 extra SQL queries per page load.
|
194 |
|
195 |
= 3.8.7.2 =
|
196 |
* New: Support for g:availability to Google Merchant Centre feed. Props bbaskets & longercat
|
woo-integration/css/main_frame_style.css
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
/* CSS Document */
|
2 |
-
|
3 |
-
li.wpsc_presentation a{
|
4 |
-
padding-left: 40px !important;
|
5 |
-
background: url(../../wpsc-core/images/credit_cards.png) no-repeat;
|
6 |
-
background-position: 12px center;
|
7 |
-
}
|
8 |
-
|
9 |
-
iframe#wpsc-presentation{
|
10 |
-
height: 2210px;
|
11 |
-
width: 100%;
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woo-integration/css/style.css
DELETED
@@ -1,155 +0,0 @@
|
|
1 |
-
/* CSS Document */
|
2 |
-
|
3 |
-
*{
|
4 |
-
font-family: 'Lucida Grande', Verdana, sans-serif;
|
5 |
-
font-size: 11px;
|
6 |
-
color: #666;
|
7 |
-
list-style: none;
|
8 |
-
}
|
9 |
-
|
10 |
-
h3{
|
11 |
-
font-size: 14px;
|
12 |
-
color: #333;
|
13 |
-
display: block;
|
14 |
-
border-bottom: solid 1px #e7e7e7;
|
15 |
-
padding-bottom: 7px;
|
16 |
-
}
|
17 |
-
|
18 |
-
tr{
|
19 |
-
display: block;
|
20 |
-
padding-bottom: 10px;
|
21 |
-
}
|
22 |
-
|
23 |
-
th[scope=row], th[score=row]{
|
24 |
-
text-align: left;
|
25 |
-
}
|
26 |
-
|
27 |
-
input[type=text]{
|
28 |
-
border: solid #CCC #EEE #EEE #CCC;
|
29 |
-
border-width: 1px;
|
30 |
-
background-color: #fafafa;
|
31 |
-
-moz-border-radius: 3px;
|
32 |
-
-webkit-border-radius: 3px;
|
33 |
-
-border-radius: 3px;
|
34 |
-
padding: 5px;
|
35 |
-
-webkit-bor
|
36 |
-
}
|
37 |
-
|
38 |
-
input[type=text]:hover{
|
39 |
-
background-color: #FFF;
|
40 |
-
}
|
41 |
-
|
42 |
-
.allign_top{
|
43 |
-
vertical-align: top;
|
44 |
-
}
|
45 |
-
|
46 |
-
.button_settings_th{
|
47 |
-
width: 180px;
|
48 |
-
}
|
49 |
-
|
50 |
-
.button_settings_desc{
|
51 |
-
width: 260px;
|
52 |
-
padding-left: 20px;
|
53 |
-
}
|
54 |
-
|
55 |
-
.product_settings_th{
|
56 |
-
width: 350px;
|
57 |
-
}
|
58 |
-
|
59 |
-
.product_page_settings_th, .product_category_settings_th, .thumbnail_settings_th{
|
60 |
-
width: 260px;
|
61 |
-
padding-right: 10px;
|
62 |
-
}
|
63 |
-
|
64 |
-
.shopping_cart_settings_th{
|
65 |
-
width: 240px;
|
66 |
-
padding-right: 10px;
|
67 |
-
}
|
68 |
-
|
69 |
-
.pagination_settings_th{
|
70 |
-
width: 200px;
|
71 |
-
}
|
72 |
-
|
73 |
-
.wpsc_select_wrapper{
|
74 |
-
-moz-border-radius: 4px;
|
75 |
-
-webkit-border-radius: 4px;
|
76 |
-
border-radius: 4px;
|
77 |
-
font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif;
|
78 |
-
font-size: 12px;
|
79 |
-
background: #FAFAFA url(../../functions/images/select.png) no-repeat right center;
|
80 |
-
border-color: #CCC #EEE #EEE #CCC;
|
81 |
-
border-style: solid;
|
82 |
-
border-width: 1px;
|
83 |
-
float: left;
|
84 |
-
height: 26px;
|
85 |
-
width: 280px;
|
86 |
-
margin: 0;
|
87 |
-
margin-bottom: 9px !important;
|
88 |
-
display: block;
|
89 |
-
color: #555;
|
90 |
-
}
|
91 |
-
|
92 |
-
.wpsc_select{
|
93 |
-
cursor: pointer;
|
94 |
-
height: 28px;
|
95 |
-
margin: 0;
|
96 |
-
opacity: 0;
|
97 |
-
padding: 0;
|
98 |
-
position: relative;
|
99 |
-
width: inherit;
|
100 |
-
z-index: 4;
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
.wpsc_select_span{
|
105 |
-
height: 26px;
|
106 |
-
line-height: 26px;
|
107 |
-
position: absolute;
|
108 |
-
z-index: 2;
|
109 |
-
padding-left: 6px;
|
110 |
-
}
|
111 |
-
|
112 |
-
.wpsc_select:hover{
|
113 |
-
color: #333;
|
114 |
-
background: white;
|
115 |
-
}
|
116 |
-
|
117 |
-
input[type=submit][name=updateoption]{
|
118 |
-
border-color: #BBB !important;
|
119 |
-
cursor: pointer;
|
120 |
-
background-color: #FAFAFA;
|
121 |
-
border: 1px solid;
|
122 |
-
padding: 5px;
|
123 |
-
font-family: "Lucida Grande", Verdana, sans-serif;
|
124 |
-
color: #555;
|
125 |
-
-moz-border-radius: 4px;
|
126 |
-
-webkit-border-radius: 4px;
|
127 |
-
-border-radius: 4px;
|
128 |
-
border-style: solid;
|
129 |
-
border-width: 1px;
|
130 |
-
position: fixed;
|
131 |
-
bottom: 10px;
|
132 |
-
}
|
133 |
-
|
134 |
-
input[type=submit][name=updateoption]:hover{
|
135 |
-
border-color: #666 !important;
|
136 |
-
color: black;
|
137 |
-
}
|
138 |
-
|
139 |
-
.comment_settings_th{
|
140 |
-
width: 250px;
|
141 |
-
}
|
142 |
-
|
143 |
-
#message{
|
144 |
-
position: fixed;
|
145 |
-
bottom: 10px;
|
146 |
-
right: 0px;
|
147 |
-
display: block;
|
148 |
-
width: 400px;
|
149 |
-
text-align: center;
|
150 |
-
background-color: #FFFFE0;
|
151 |
-
border: 1px solid #E6DB55;
|
152 |
-
-moz-border-radius: 4px;
|
153 |
-
-webkit-border-radius: 4px;
|
154 |
-
-border-radius: 4px;
|
155 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woo-integration/js/script.js
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
// JavaScript Document
|
2 |
-
(function($){
|
3 |
-
$(document).ready(function() {
|
4 |
-
//Button Settings Block
|
5 |
-
$("h3:contains('Button Settings')").next().find('th[scope="row"]').addClass('button_settings_th allign_top');
|
6 |
-
|
7 |
-
var i = $("h3:contains('Button Settings')").next().find('td').first();
|
8 |
-
i.html(i.html().replace('Buy Now Button only works for Paypal Standard, please activate Paypal Standard to enable this option.',''));
|
9 |
-
i.after("<td class='button_settings_desc'>Buy Now Button only works for Paypal Standard, please activate Paypal Standard to enable this option.</td>");
|
10 |
-
i.addClass('allign_top');
|
11 |
-
|
12 |
-
//Products Settings Block
|
13 |
-
$("h3:contains('Product Settings')").next().find('th[scope="row"]').addClass('product_settings_th allign_top');
|
14 |
-
$("h3:contains('Product Settings')").next().find('th[score="row"]').addClass('product_settings_th allign_top');
|
15 |
-
|
16 |
-
//Product Page Settings
|
17 |
-
$("h3:contains('Product Page Settings')").next().find('th[scope="row"]').addClass('product_page_settings_th allign_top');
|
18 |
-
|
19 |
-
//Shopping Cart Settings
|
20 |
-
$("h3:contains('Shopping Cart Settings')").next().find('th[scope="row"]').addClass('shopping_cart_settings_th allign_top');
|
21 |
-
|
22 |
-
//Product category Settings
|
23 |
-
$("h3:contains('Product Category Settings')").next().find('th[scope="row"]').addClass('product_category_settings_th allign_top');
|
24 |
-
|
25 |
-
//Thumbnail Settings
|
26 |
-
$("h3:contains('Thumbnail Settings')").next().next().find('th[scope="row"]').addClass('thumbnail_settings_th');
|
27 |
-
|
28 |
-
//Pagination Settings
|
29 |
-
$("h3:contains('Pagination settings')").next().find('th[scope="row"]').addClass('pagination_settings_th');
|
30 |
-
|
31 |
-
//Comment Settings
|
32 |
-
$("h3:contains('Comment Settings')").next().find('th[scope="row"]').addClass('comment_settings_th');
|
33 |
-
|
34 |
-
//Select control
|
35 |
-
$("select").wrap('<div class="wpsc_select_wrapper" />');
|
36 |
-
$("select").before('<span class="wpsc_select_span"></span>');
|
37 |
-
$("select").addClass("wpsc_select");
|
38 |
-
$("select").change(function (){
|
39 |
-
$(this).prev().text($(this).find('option:selected').text());
|
40 |
-
});
|
41 |
-
|
42 |
-
//Initialize select valua
|
43 |
-
$("select").each(function(index, element) {
|
44 |
-
$(this).prev().text($(this).find('option:selected').text());
|
45 |
-
});
|
46 |
-
|
47 |
-
//Remove Advanced Theme Setting
|
48 |
-
$('#themes_and_appearance').remove();
|
49 |
-
});
|
50 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woo-integration/options_presentation.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2 |
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
3 |
-
<head>
|
4 |
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5 |
-
<link rel="stylesheet" type="text/css" href="<?php echo WPSC_URL; ?>/woo-integration/css/style.css"/>
|
6 |
-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
|
7 |
-
<script type="text/javascript" src="<?php echo WPSC_URL; ?>/woo-integration/js/script.js"></script>
|
8 |
-
<title>Dirty Options Presentaion</title>
|
9 |
-
</head>
|
10 |
-
<body>
|
11 |
-
<?php
|
12 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/presentation.php' );
|
13 |
-
echo wpsc_options_presentation();
|
14 |
-
?>
|
15 |
-
</body>
|
16 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
woo-integration/woo_integration.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
//Remove presentation tab on wpsc option menu
|
4 |
-
function woo_wpsc_remove_presentation_tab($default_tabs){
|
5 |
-
unset( $default_tabs['presentation'] );
|
6 |
-
return $default_tabs;
|
7 |
-
}
|
8 |
-
|
9 |
-
//Filter redirect url so that WPSC presentation page will loac correctly after update
|
10 |
-
function woo_wpsc_filter_redirect_url($query){
|
11 |
-
if ($_GET['page']=='woothemes'){
|
12 |
-
$query = remove_query_arg('tab', $query);
|
13 |
-
$query = add_query_arg( 'page' , 'woothemes' , $query);
|
14 |
-
}
|
15 |
-
return $query;
|
16 |
-
}
|
17 |
-
|
18 |
-
//Print presentation menu subpage
|
19 |
-
function woo_wpsc_filter_option($return){
|
20 |
-
$return[1] .= '<li class="wpsc_presentation">
|
21 |
-
<a title="WPSC_presentation" href="#wpsc-option-presentation">
|
22 |
-
WPSC Presentation
|
23 |
-
</a>
|
24 |
-
</li>';
|
25 |
-
|
26 |
-
$return[0] .= ' <div class="group" id="wpsc-option-presentation">
|
27 |
-
<iframe id="wpsc-presentation" src="'.get_bloginfo('wpurl').'/wp-admin/admin-ajax.php?action=print_wpsc_presentation">
|
28 |
-
</iframe>
|
29 |
-
</div>';
|
30 |
-
|
31 |
-
return $return;
|
32 |
-
}
|
33 |
-
|
34 |
-
//Ajax respond for wp_ajax_print_wpsc_presentation
|
35 |
-
function woo_wpsc_presentation_menu(){
|
36 |
-
require_once( WPSC_FILE_PATH . '/woo-integration/options_presentation.php' );
|
37 |
-
die();
|
38 |
-
}
|
39 |
-
|
40 |
-
//Add main frame style sheet
|
41 |
-
function add_my_stylesheet() {
|
42 |
-
wp_register_style('gb_admin_style', get_bloginfo('template_url') . '/wpsc/css/main_frame_style.css' );
|
43 |
-
wp_enqueue_style('gb_admin_style');
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
function woo_wpsc_integration(){
|
48 |
-
//add_filter( 'wpsc_settings_tabs' , 'woo_wpsc_remove_presentation_tab');
|
49 |
-
add_filter( 'woo_before_option_page' , 'woo_wpsc_filter_option');
|
50 |
-
add_filter( 'wpsc_settings_redirect_url' , 'woo_wpsc_filter_redirect_url');
|
51 |
-
add_action( 'wp_ajax_print_wpsc_presentation' , 'woo_wpsc_presentation_menu');
|
52 |
-
add_action( 'admin_init' , 'add_my_stylesheet');
|
53 |
-
}
|
54 |
-
|
55 |
-
function wpsc_detect_woo(){
|
56 |
-
if (function_exists('woo_version')){
|
57 |
-
woo_wpsc_integration();
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
add_action('after_setup_theme', 'wpsc_detect_woo');
|
62 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wp-shopping-cart.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WP e-Commerce
|
4 |
* Plugin URI: http://getshopped.org/
|
5 |
* Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
|
6 |
-
* Version: 3.8.
|
7 |
* Author: Instinct Entertainment
|
8 |
* Author URI: http://getshopped.org/
|
9 |
**/
|
3 |
* Plugin Name: WP e-Commerce
|
4 |
* Plugin URI: http://getshopped.org/
|
5 |
* Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://getshopped.org" target="_blank">GetShopped.org</a> | <a href="http://getshopped.org/forums/" target="_blank">Support Forum</a> | <a href="http://docs.getshopped.org/" target="_blank">Documentation</a>
|
6 |
+
* Version: 3.8.8-dev
|
7 |
* Author: Instinct Entertainment
|
8 |
* Author URI: http://getshopped.org/
|
9 |
**/
|
wpsc-admin/admin-form-functions.php
CHANGED
@@ -279,8 +279,8 @@ function wpsc_packing_slip( $purchase_id ) {
|
|
279 |
|
280 |
switch($form_field['type']) {
|
281 |
case 'country':
|
282 |
-
|
283 |
-
$delivery_region_count = $wpdb->get_var(
|
284 |
|
285 |
if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0))
|
286 |
echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
|
279 |
|
280 |
switch($form_field['type']) {
|
281 |
case 'country':
|
282 |
+
$region_count_sql = $wpdb->prepare( "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('%s')", $purch_data['billing_country'] );
|
283 |
+
$delivery_region_count = $wpdb->get_var( $region_count_sql );
|
284 |
|
285 |
if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0))
|
286 |
echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r";
|
wpsc-admin/admin.php
CHANGED
@@ -21,18 +21,11 @@ require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs.class.php' );
|
|
21 |
require_once( WPSC_FILE_PATH . '/wpsc-includes/theming.class.php' );
|
22 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
|
23 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
|
24 |
-
|
25 |
if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
|
26 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
|
27 |
|
28 |
-
|
29 |
-
//Woothemes integration
|
30 |
-
require_once( WPSC_FILE_PATH . '/woo-integration/woo_integration.php' );
|
31 |
-
|
32 |
-
//settings pages include
|
33 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
|
34 |
-
|
35 |
-
if ( !get_option( 'wpsc_checkout_form_sets' ) ) {
|
36 |
$form_sets = array( 'Default Checkout Forms' );
|
37 |
update_option( 'wpsc_checkout_form_sets', $form_sets );
|
38 |
}
|
@@ -148,13 +141,15 @@ function wpsc_admin_pages() {
|
|
148 |
}
|
149 |
|
150 |
// Add to Dashboard
|
151 |
-
$page_hooks[] = $purchase_log_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs' );
|
152 |
|
153 |
if ( wpsc_show_update_link() )
|
154 |
$page_hooks[] = add_submenu_page( 'index.php', __( 'Update Store', 'wpsc' ), __( 'Store Update', 'wpsc' ), 'administrator', 'wpsc-update', 'wpsc_display_update_page' );
|
155 |
|
156 |
$page_hooks[] = add_submenu_page( 'index.php', __( 'Store Upgrades', 'wpsc' ), __( 'Store Upgrades', 'wpsc' ), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page' );
|
157 |
|
|
|
|
|
158 |
// Set the base page for Products
|
159 |
$products_page = 'edit.php?post_type=wpsc-product';
|
160 |
|
@@ -168,16 +163,6 @@ function wpsc_admin_pages() {
|
|
168 |
if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
|
169 |
$page_hooks[] = add_options_page( __( 'Store Debug', 'wpsc' ), __( 'Store Debug', 'wpsc' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
|
170 |
|
171 |
-
|
172 |
-
$header = '<p><strong>' . __( 'For More Information', 'wpsc' ) . '</strong></p>';
|
173 |
-
|
174 |
-
add_contextual_help( 'toplevel_page_wpsc-sales-logs', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/sales/'>About the Sales Page</a>", 'wpsc' ) );
|
175 |
-
add_contextual_help( 'toplevel_page_wpsc-edit-products', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/products'>About the Products Page</a>", 'wpsc' ) );
|
176 |
-
add_contextual_help( 'products_page_wpsc-edit-groups', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/categories/'>About the Categories Page</a>", 'wpsc' ) );
|
177 |
-
add_contextual_help( 'products_page_edit-tags', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/variations/'>About the Variations Page</a>", 'wpsc' ) );
|
178 |
-
add_contextual_help( 'settings_page_wpsc-settings', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/store-settings/general/'>General Settings</a><br /> <a target='_blank' href='http://getshopped.org/resources/docs/store-settings/checkout/'>Checkout Options</a> <br />", 'wpsc' ) );
|
179 |
-
add_contextual_help( 'products_page_wpsc-edit-coupons', $header . __( "<a target='_blank' href='http://getshopped.org/resources/docs/building-your-store/marketing'>Marketing Options</a><br />", 'wpsc' ) );
|
180 |
-
|
181 |
$page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
|
182 |
|
183 |
do_action( 'wpsc_add_submenu' );
|
@@ -194,8 +179,9 @@ function wpsc_admin_pages() {
|
|
194 |
add_action( 'load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js' );
|
195 |
break;
|
196 |
|
197 |
-
case $
|
198 |
add_action( 'admin_head', 'wpsc_product_log_rss_feed' );
|
|
|
199 |
break;
|
200 |
|
201 |
case $edit_coupons_page :
|
@@ -210,8 +196,149 @@ function wpsc_admin_pages() {
|
|
210 |
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' ) );
|
211 |
}
|
212 |
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
function wpsc_product_log_rss_feed() {
|
216 |
echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&rss_key=key&action=purchase_log&type=rss' title='WP e-Commerce Purchase Log RSS' rel='alternate'/>";
|
217 |
}
|
@@ -239,8 +366,19 @@ function wpsc_admin_include_coupon_js() {
|
|
239 |
function wpsc_admin_include_optionspage_css_and_js() {
|
240 |
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
241 |
wp_enqueue_script( 'wp-e-commerce-js-ajax', WPSC_URL . '/wpsc-core/js/ajax.js', false, $version_identifier );
|
242 |
-
wp_enqueue_script( 'wp-e-commerce-js-ui-tabs', WPSC_URL . '/wpsc-admin/js/jquery-ui.js', false, $version_identifier );
|
243 |
wp_enqueue_script( 'wp-e-commerce-js-dimensions', WPSC_URL . '/wpsc-admin/js/dimensions.js', false, $version_identifier );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
|
245 |
wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL . '/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' );
|
246 |
}
|
@@ -298,24 +436,21 @@ function wpsc_admin_include_css_and_js_refac( $pagehook ) {
|
|
298 |
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
299 |
$pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
|
300 |
|
301 |
-
if ( ( in_array( $pagehook, $pages ) && $post_type == 'wpsc-product' ) || $current_screen->id == 'edit-wpsc_product_category' || $current_screen->id == 'dashboard_page_wpsc-sales-logs' || $current_screen->id == 'settings_page_wpsc-settings' || $current_screen->id == 'wpsc-product_page_wpsc-edit-coupons' ) {
|
302 |
wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
|
303 |
wp_enqueue_script( 'wp-e-commerce-admin-parameters', $siteurl . '/wp-admin/admin.php?wpsc_admin_dynamic_js=true', false, $version_identifier );
|
304 |
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 );
|
305 |
wp_enqueue_script( 'wp-e-commerce-legacy-ajax', WPSC_URL . '/wpsc-admin/js/ajax.js', false, $version_identifier ); // needs removing
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
} else {
|
312 |
-
wp_enqueue_script( 'inline-edit-post' );
|
313 |
}
|
314 |
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
315 |
wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl . "/wp-admin/admin.php?wpsc_admin_dynamic_css=true", false, $version_identifier, 'all' );
|
316 |
// Localize scripts
|
317 |
wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
|
318 |
-
'unsaved_changes_detected' => __( 'Unsaved changes have been detected. Click OK to lose these changes and continue.', 'wpsc' ),
|
319 |
'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
|
320 |
'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};'
|
321 |
) );
|
@@ -868,6 +1003,7 @@ add_action( 'permalink_structure_changed' , 'wpsc_check_permalink_notice' );
|
|
868 |
add_action( 'permalink_structure_changed' , 'wpsc_update_permalinks' );
|
869 |
/* add_action( 'get_sample_permalink_html' , 'wpsc_update_permalinks' ); // this just seems unnecessary and produces PHP notices */
|
870 |
add_action( 'wp_ajax_category_sort_order', 'wpsc_ajax_set_category_order' );
|
|
|
871 |
add_action( 'wp_ajax_wpsc_ie_save', 'wpsc_ajax_ie_save' );
|
872 |
add_action('in_admin_header', 'wpsc_add_meta_boxes');
|
873 |
?>
|
21 |
require_once( WPSC_FILE_PATH . '/wpsc-includes/theming.class.php' );
|
22 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
|
23 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
|
24 |
+
|
25 |
if ( ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( $_SESSION['wpsc_activate_debug_page'] == true ) ) || ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( constant( 'WPSC_ADD_DEBUG_PAGE' ) == true ) ) )
|
26 |
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-debug.page.php' );
|
27 |
|
28 |
+
if ( ! get_option( 'wpsc_checkout_form_sets' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
$form_sets = array( 'Default Checkout Forms' );
|
30 |
update_option( 'wpsc_checkout_form_sets', $form_sets );
|
31 |
}
|
141 |
}
|
142 |
|
143 |
// Add to Dashboard
|
144 |
+
// $page_hooks[] = $purchase_log_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-sales-logs', 'wpsc_display_sales_logs' );
|
145 |
|
146 |
if ( wpsc_show_update_link() )
|
147 |
$page_hooks[] = add_submenu_page( 'index.php', __( 'Update Store', 'wpsc' ), __( 'Store Update', 'wpsc' ), 'administrator', 'wpsc-update', 'wpsc_display_update_page' );
|
148 |
|
149 |
$page_hooks[] = add_submenu_page( 'index.php', __( 'Store Upgrades', 'wpsc' ), __( 'Store Upgrades', 'wpsc' ), 'administrator', 'wpsc-upgrades', 'wpsc_display_upgrades_page' );
|
150 |
|
151 |
+
$page_hooks[] = $purchase_logs_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), 'administrator', 'wpsc-purchase-logs', 'wpsc_display_purchase_logs_page' );
|
152 |
+
|
153 |
// Set the base page for Products
|
154 |
$products_page = 'edit.php?post_type=wpsc-product';
|
155 |
|
163 |
if ( ( defined( 'WPSC_ADD_DEBUG_PAGE' ) && ( WPSC_ADD_DEBUG_PAGE == true ) ) || ( isset( $_SESSION['wpsc_activate_debug_page'] ) && ( true == $_SESSION['wpsc_activate_debug_page'] ) ) )
|
164 |
$page_hooks[] = add_options_page( __( 'Store Debug', 'wpsc' ), __( 'Store Debug', 'wpsc' ), 'administrator', 'wpsc-debug', 'wpsc_debug_page' );
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
$page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
|
167 |
|
168 |
do_action( 'wpsc_add_submenu' );
|
179 |
add_action( 'load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js' );
|
180 |
break;
|
181 |
|
182 |
+
case $purchase_logs_page :
|
183 |
add_action( 'admin_head', 'wpsc_product_log_rss_feed' );
|
184 |
+
add_action( 'load-' . $page_hook, 'wpsc_admin_include_purchase_logs_css_and_js' );
|
185 |
break;
|
186 |
|
187 |
case $edit_coupons_page :
|
196 |
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' ) );
|
197 |
}
|
198 |
|
199 |
+
add_action( 'load-' . $edit_options_page, 'wpsc_load_settings_page', 1 );
|
200 |
+
|
201 |
+
// only load the purchase log list table and page classes when it's necessary
|
202 |
+
// also, the WPSC_Purchase_Logs_List_Table needs to be initializied before admin_header.php
|
203 |
+
// is loaded, therefore wpsc_load_purchase_logs_page needs to do this as well
|
204 |
+
add_action( 'load-' . $purchase_logs_page, 'wpsc_load_purchase_logs_page', 1 );
|
205 |
+
|
206 |
+
// Help tabs
|
207 |
+
add_action( 'load-' . $edit_options_page , 'wpsc_add_help_tabs' );
|
208 |
+
add_action( 'load-' . $purchase_logs_page, 'wpsc_add_help_tabs' );
|
209 |
+
add_action( 'load-' . $edit_coupons_page , 'wpsc_add_help_tabs' );
|
210 |
+
add_action( 'load-edit.php' , 'wpsc_add_help_tabs' );
|
211 |
+
add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
|
212 |
+
add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
|
213 |
+
add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* This function adds contextual help to all WPEC screens.
|
218 |
+
* add_contextual_help() is supported as well as $screen->add_help_tab().
|
219 |
+
*
|
220 |
+
* @since 3.8.8
|
221 |
+
*/
|
222 |
+
function wpsc_add_help_tabs() {
|
223 |
+
$tabs = array(
|
224 |
+
// Store Settings Page
|
225 |
+
'settings_page_wpsc-settings' => array(
|
226 |
+
'title' => _x( 'Store Settings', 'contextual help tab', 'wpsc' ),
|
227 |
+
'links' => array(
|
228 |
+
'category/configuring-your-store/store-settings/' => _x( 'Store Settings Overview' , 'contextual help link', 'wpsc' ),
|
229 |
+
'category/configuring-your-store/payment-gateways/' => _x( 'Configuring Your Payment Gateways', 'contextual help link', 'wpsc' ),
|
230 |
+
'category/configuring-your-store/shipping/' => _x( 'Configuring Your Shipping Modules', 'contextual help link', 'wpsc' ),
|
231 |
+
),
|
232 |
+
),
|
233 |
+
|
234 |
+
// Sales Log Page
|
235 |
+
'dashboard_page_wpsc-purchase-logs' => array(
|
236 |
+
'title' => _x( 'Sales Log', 'contextual help tab', 'wpsc' ),
|
237 |
+
'links' => array(
|
238 |
+
'documentation/sales/' => _x( 'Monitor and Manage Your Sales', 'contextual help link', 'wpsc' ),
|
239 |
+
),
|
240 |
+
),
|
241 |
+
|
242 |
+
// Main Products Listing Admin Page (edit.php?post_type=wpsc-product)
|
243 |
+
'edit-wpsc-product' => array(
|
244 |
+
'title' => _x( 'Product Catalog', 'contextual help tab', 'wpsc' ),
|
245 |
+
'links' => array(
|
246 |
+
'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
|
247 |
+
),
|
248 |
+
),
|
249 |
+
|
250 |
+
// Add and Edit Product Pages
|
251 |
+
'wpsc-product' => array(
|
252 |
+
'title' => _x( 'Add and Edit Product', 'contextual help tab', 'wpsc' ),
|
253 |
+
'links' => array(
|
254 |
+
'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
|
255 |
+
'resource/video-adding-products/' => _x( 'Video: Adding Products', 'contextual help link', 'wpsc' ),
|
256 |
+
),
|
257 |
+
),
|
258 |
+
|
259 |
+
// Product Tags Page
|
260 |
+
'edit-product_tag' => array(
|
261 |
+
'title' => _x( 'Product Tags', 'contextual help tab', 'wpsc' ),
|
262 |
+
'links' =>array(
|
263 |
+
'resource/video-product-tags/' => _x( 'Video: Product Tags', 'contextual help link', 'wpsc' ),
|
264 |
+
),
|
265 |
+
),
|
266 |
+
|
267 |
+
// Product Category Page
|
268 |
+
'edit-wpsc_product_category' => array(
|
269 |
+
'title' => _x( 'Product Categories', 'contextual help tab', 'wpsc' ),
|
270 |
+
'links' => array(
|
271 |
+
'resource/video-creating-product-categories/' => _x( 'Video: Creating Product Categories', 'contextual help link', 'wpsc' ),
|
272 |
+
),
|
273 |
+
),
|
274 |
+
|
275 |
+
// Product Variations Page
|
276 |
+
'edit-wpsc-variation' => array(
|
277 |
+
'title' => _x( 'Product Variations', 'contextual help tab', 'wpsc' ),
|
278 |
+
'links' => array(
|
279 |
+
'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wpsc' ),
|
280 |
+
),
|
281 |
+
),
|
282 |
+
|
283 |
+
// Coupon Page
|
284 |
+
'wpsc-product_page_wpsc-edit-coupons' => array(
|
285 |
+
'title' => _x( 'Coupons', 'contextual help tab', 'wpsc' ),
|
286 |
+
'links' => array(
|
287 |
+
'resource/video-creating-coupons/' => _x( 'Video: Creating Coupons', 'contextual help link', 'wpsc' ),
|
288 |
+
),
|
289 |
+
),
|
290 |
+
);
|
291 |
+
|
292 |
+
$screen = get_current_screen();
|
293 |
+
if ( array_key_exists( $screen->id, $tabs ) ) {
|
294 |
+
$tab = $tabs[$screen->id];
|
295 |
+
$content = '<p><strong>' . __( 'Fore More Information', 'wpsc' ) . '</strong></p>';
|
296 |
+
$links = array();
|
297 |
+
foreach( $tab['links'] as $link => $link_title ) {
|
298 |
+
$link = 'http://docs.getshopped.org/' . $link;
|
299 |
+
$links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
|
300 |
+
}
|
301 |
+
$content .= '<p>' . implode( '<br />', $links ) . '</p>';
|
302 |
+
|
303 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.3', '<' ) ) {
|
304 |
+
add_contextual_help( $screen->id, $content );
|
305 |
+
} else {
|
306 |
+
$screen->add_help_tab( array(
|
307 |
+
'id' => $screen->id . '_help',
|
308 |
+
'title' => $tab['title'],
|
309 |
+
'content' => $content,
|
310 |
+
) );
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
function wpsc_admin_include_purchase_logs_css_and_js() {
|
316 |
+
wp_enqueue_script( 'wp-e-commerce-purchase-logs', WPSC_URL . '/wpsc-admin/js/purchase-logs.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION );
|
317 |
+
wp_localize_script( 'wp-e-commerce-purchase-logs', 'WPSC_Purchase_Logs_Admin', array(
|
318 |
+
'nonce' => wp_create_nonce( 'wpsc_purchase_logs' ),
|
319 |
+
'status_error_dialog' => __( "An unknown error occurred. The order's status might not have been updated properly.\n\nPlease refresh this page and try again.", 'wpsc' ),
|
320 |
+
'tracking_error_dialog' => __( "An unknown error occurred. The order's tracking ID might not have been updated properly.\n\nPlease refresh this page and try again.", 'wpsc' ),
|
321 |
+
'send_tracking_email_error_dialog' => __( "An unknown error occurred. The tracking email might not have been sent.\n\nPlease refresh this page and try again.", 'wpsc' ),
|
322 |
+
'sending_message' => _x( 'sending...', 'sending tracking email for purchase log', 'wpsc' ),
|
323 |
+
'sent_message' => _x( 'Email Sent!', 'sending tracking email for purchase log', 'wpsc' ),
|
324 |
+
) );
|
325 |
+
}
|
326 |
+
|
327 |
+
function wpsc_load_settings_page() {
|
328 |
+
require_once('settings-page.php');
|
329 |
+
WPSC_Settings_Page::get_instance();
|
330 |
}
|
331 |
+
|
332 |
+
function wpsc_load_purchase_logs_page() {
|
333 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
|
334 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
|
335 |
+
$page = new WPSC_Purchase_Log_Page();
|
336 |
+
}
|
337 |
+
|
338 |
+
function wpsc_display_purchase_logs_page() {
|
339 |
+
do_action( 'wpsc_display_purchase_logs_page' );
|
340 |
+
}
|
341 |
+
|
342 |
function wpsc_product_log_rss_feed() {
|
343 |
echo "<link type='application/rss+xml' href='" . get_option( 'siteurl' ) . "/wp-admin/index.php?rss=true&rss_key=key&action=purchase_log&type=rss' title='WP e-Commerce Purchase Log RSS' rel='alternate'/>";
|
344 |
}
|
366 |
function wpsc_admin_include_optionspage_css_and_js() {
|
367 |
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
368 |
wp_enqueue_script( 'wp-e-commerce-js-ajax', WPSC_URL . '/wpsc-core/js/ajax.js', false, $version_identifier );
|
|
|
369 |
wp_enqueue_script( 'wp-e-commerce-js-dimensions', WPSC_URL . '/wpsc-admin/js/dimensions.js', false, $version_identifier );
|
370 |
+
wp_enqueue_script( 'wp-e-commerce-admin-settings-page', WPSC_URL . '/wpsc-admin/js/settings-page.js', array( 'jquery-query' ), $version_identifier );
|
371 |
+
|
372 |
+
wp_localize_script( 'wp-e-commerce-admin-settings-page', 'WPSC_Settings_Page', array(
|
373 |
+
'nonce' => wp_create_nonce( 'wpsc_settings_page_nonce' ),
|
374 |
+
'current_tab' => WPSC_Settings_Page::get_instance()->get_current_tab_id(),
|
375 |
+
'before_unload_dialog' => __( 'The changes you made will be lost if you navigate away from this page.', 'wpsc' ),
|
376 |
+
'ajax_navigate_confirm_dialog' => __( 'The changes you made will be lost if you navigate away from this page.', 'wpsc' ) . "\n\n" . __( 'Click OK to discard your changes, or Cancel to remain on this page.' ),
|
377 |
+
'checkout_field_sort_error_dialog' => __( "An error occurred when saving your field order preference.\n\nPlease refresh the page and try again.", 'wpsc' ),
|
378 |
+
'edit_field_options' => __( 'Edit Options', 'wpsc' ),
|
379 |
+
'hide_edit_field_options' => __( 'Hide Options', 'wpsc' ),
|
380 |
+
) );
|
381 |
+
|
382 |
wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
|
383 |
wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL . '/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' );
|
384 |
}
|
436 |
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
437 |
$pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
|
438 |
|
439 |
+
if ( ( in_array( $pagehook, $pages ) && $post_type == 'wpsc-product' ) || $current_screen->id == 'edit-wpsc_product_category' || $current_screen->id == 'dashboard_page_wpsc-sales-logs' || $current_screen->id == 'dashboard_page_wpsc-purchase-logs' || $current_screen->id == 'settings_page_wpsc-settings' || $current_screen->id == 'wpsc-product_page_wpsc-edit-coupons' || $current_screen->id == 'edit-wpsc-variation' ) {
|
440 |
wp_enqueue_script( 'livequery', WPSC_URL . '/wpsc-admin/js/jquery.livequery.js', array( 'jquery' ), '1.0.3' );
|
441 |
wp_enqueue_script( 'wp-e-commerce-admin-parameters', $siteurl . '/wp-admin/admin.php?wpsc_admin_dynamic_js=true', false, $version_identifier );
|
442 |
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 );
|
443 |
wp_enqueue_script( 'wp-e-commerce-legacy-ajax', WPSC_URL . '/wpsc-admin/js/ajax.js', false, $version_identifier ); // needs removing
|
444 |
+
|
445 |
+
wp_enqueue_script( 'wpsc-sortable-table', WPSC_URL . '/wpsc-admin/js/sortable-table.js', array( 'jquery' ) );
|
446 |
+
|
447 |
+
if ( in_array( $current_screen->id, array( 'edit-wpsc-variation', 'wpsc-product' ) ) ) {
|
448 |
+
wp_enqueue_script( 'wp-e-commerce-variations', WPSC_URL . '/wpsc-admin/js/variations.js', array( 'jquery', 'wpsc-sortable-table' ), $version_identifier );
|
|
|
|
|
449 |
}
|
450 |
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
451 |
wp_enqueue_style( 'wp-e-commerce-admin-dynamic', $siteurl . "/wp-admin/admin.php?wpsc_admin_dynamic_css=true", false, $version_identifier, 'all' );
|
452 |
// Localize scripts
|
453 |
wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
|
|
|
454 |
'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
|
455 |
'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};'
|
456 |
) );
|
1003 |
add_action( 'permalink_structure_changed' , 'wpsc_update_permalinks' );
|
1004 |
/* add_action( 'get_sample_permalink_html' , 'wpsc_update_permalinks' ); // this just seems unnecessary and produces PHP notices */
|
1005 |
add_action( 'wp_ajax_category_sort_order', 'wpsc_ajax_set_category_order' );
|
1006 |
+
add_action( 'wp_ajax_variation_sort_order', 'wpsc_ajax_set_variation_order' );
|
1007 |
add_action( 'wp_ajax_wpsc_ie_save', 'wpsc_ajax_ie_save' );
|
1008 |
add_action('in_admin_header', 'wpsc_add_meta_boxes');
|
1009 |
?>
|
wpsc-admin/ajax-and-init.php
CHANGED
@@ -8,36 +8,166 @@
|
|
8 |
* @package wp-e-commerce
|
9 |
* @since 3.7
|
10 |
*/
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
|
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
global $wpdb;
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
$message = get_option( 'wpsc_trackingid_message' );
|
35 |
$message = str_replace( '%trackid%', $trackingid, $message );
|
36 |
$message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
|
37 |
|
38 |
$email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
|
39 |
-
$email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id
|
40 |
-
|
41 |
|
42 |
$subject = get_option( 'wpsc_trackingid_subject' );
|
43 |
$subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
|
@@ -46,16 +176,10 @@ function wpsc_purchlog_email_trackid() {
|
|
46 |
add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
|
47 |
|
48 |
wp_mail( $email, $subject, $message);
|
49 |
-
|
50 |
-
remove_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name' );
|
51 |
-
remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
|
52 |
-
|
53 |
-
exit( true );
|
54 |
}
|
55 |
|
56 |
-
|
57 |
-
add_action( 'admin_init', 'wpsc_purchlog_email_trackid' );
|
58 |
-
}
|
59 |
|
60 |
function wpsc_ajax_sales_quarterly() {
|
61 |
$lastdate = $_POST['add_start'];
|
@@ -89,9 +213,9 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
|
|
89 |
function wpsc_delete_file() {
|
90 |
global $wpdb;
|
91 |
$output = 0;
|
92 |
-
$row_number = absint( $
|
93 |
-
$product_id = absint( $
|
94 |
-
$file_name = basename( $
|
95 |
check_admin_referer( 'delete_file_' . $file_name );
|
96 |
|
97 |
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_parent = %d AND post_type ='wpsc-product-file'", $file_name, $product_id );
|
@@ -102,6 +226,7 @@ function wpsc_delete_file() {
|
|
102 |
if ( $_POST['ajax'] !== 'true' ) {
|
103 |
$sendback = wp_get_referer();
|
104 |
wp_redirect( $sendback );
|
|
|
105 |
}
|
106 |
|
107 |
echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
|
@@ -156,7 +281,7 @@ function wpsc_duplicate_product() {
|
|
156 |
wp_redirect( $sendback );
|
157 |
exit();
|
158 |
} else {
|
159 |
-
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 );
|
160 |
}
|
161 |
}
|
162 |
|
@@ -221,9 +346,10 @@ function wpsc_duplicate_taxonomies( $id, $new_id, $post_type ) {
|
|
221 |
*/
|
222 |
function wpsc_duplicate_product_meta( $id, $new_id ) {
|
223 |
global $wpdb;
|
224 |
-
$post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id" );
|
225 |
|
226 |
-
|
|
|
|
|
227 |
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
228 |
$values = array();
|
229 |
foreach ( $post_meta_infos as $meta_info ) {
|
@@ -246,7 +372,6 @@ function wpsc_duplicate_product_meta( $id, $new_id ) {
|
|
246 |
* Duplicates children product and children meta
|
247 |
*/
|
248 |
function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
|
249 |
-
global $wpdb;
|
250 |
|
251 |
//Get children products and duplicate them
|
252 |
$child_posts = get_posts( array(
|
@@ -256,30 +381,49 @@ function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
|
|
256 |
'numberposts' => -1,
|
257 |
) );
|
258 |
|
259 |
-
foreach ( $child_posts as $child_post )
|
260 |
-
|
261 |
-
|
262 |
}
|
263 |
|
264 |
function wpsc_purchase_log_csv() {
|
265 |
global $wpdb, $wpsc_gateways;
|
266 |
get_currentuserinfo();
|
267 |
$count = 0;
|
268 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
$form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
|
270 |
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
|
271 |
-
|
272 |
-
$start_timestamp = $_GET['start_timestamp'];
|
273 |
-
$end_timestamp = $_GET['end_timestamp'];
|
274 |
-
$data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' ORDER BY `date` DESC", ARRAY_A );
|
275 |
$csv = 'Purchase ID, Price, Firstname, Lastname, Email, Order Status, Data, ';
|
276 |
-
header( 'Content-Type: text/csv' );
|
277 |
-
header( 'Content-Disposition: inline; filename="Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv"' );
|
278 |
-
$headers = "\"Purchase ID\",\"Purchase Total\","; //capture the headers
|
279 |
|
|
|
280 |
$headers2 ="\"Payment Gateway\",";
|
281 |
$headers2 .="\"Payment Status\",\"Purchase Date\",";
|
282 |
|
|
|
283 |
|
284 |
foreach ( (array)$data as $purchase ) {
|
285 |
$form_headers = '';
|
@@ -293,7 +437,10 @@ function wpsc_purchase_log_csv() {
|
|
293 |
$output .= "\"" . $collected_data['value'] . "\","; // get form fields
|
294 |
}
|
295 |
|
296 |
-
$
|
|
|
|
|
|
|
297 |
|
298 |
|
299 |
$status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
|
@@ -304,12 +451,13 @@ function wpsc_purchase_log_csv() {
|
|
304 |
$cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
|
305 |
$cart = $wpdb->get_results( $cartsql, ARRAY_A );
|
306 |
|
307 |
-
if($count < count($cart))
|
308 |
-
|
309 |
// Go through all products in cart and display quantity and sku
|
310 |
foreach ( (array)$cart as $item ) {
|
311 |
-
$skuvalue = get_product_meta($item['prodid'], 'sku', true);
|
312 |
-
if(empty(
|
|
|
313 |
$output .= "\"" . $item['quantity'] . " x " . str_replace( '"', '\"', $item['name'] ) . "\"";
|
314 |
$output .= "," . $skuvalue."," ;
|
315 |
}
|
@@ -317,14 +465,18 @@ function wpsc_purchase_log_csv() {
|
|
317 |
}
|
318 |
// Get the most number of products and create a header for them
|
319 |
$headers3 = "";
|
320 |
-
for($i = 0; $i < $count
|
321 |
$headers3 .= "\"Quantity - Product Name \", \" SKU \"";
|
322 |
-
if($i < ($count-1))
|
323 |
-
|
324 |
}
|
325 |
|
326 |
-
|
327 |
-
|
|
|
|
|
|
|
|
|
328 |
}
|
329 |
}
|
330 |
|
@@ -363,14 +515,6 @@ function wpsc_admin_ajax() {
|
|
363 |
exit();
|
364 |
}
|
365 |
|
366 |
-
if ( isset( $_POST['remove_form_field'] ) && $_POST['remove_form_field'] == "true" && is_numeric( $_POST['form_id'] ) ) {
|
367 |
-
if ( current_user_can( 'manage_options' ) ) {
|
368 |
-
$wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_CHECKOUT_FORMS . "` SET `active` = '0' WHERE `id` = %d LIMIT 1 ;", $_POST['form_id'] ) );
|
369 |
-
exit( ' ' );
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
|
374 |
if ( isset( $_POST['hide_ecom_dashboard'] ) && $_POST['hide_ecom_dashboard'] == 'true' ) {
|
375 |
require_once (ABSPATH . WPINC . '/rss.php');
|
376 |
$rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
|
@@ -401,13 +545,22 @@ function wpsc_admin_ajax() {
|
|
401 |
exit();
|
402 |
} else {
|
403 |
|
404 |
-
$log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '"
|
405 |
if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
|
406 |
wpsc_member_activate_subscriptions( $_POST['id'] );
|
407 |
}
|
408 |
|
409 |
-
$
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
|
412 |
transaction_results( $log_data['sessionid'], false );
|
413 |
}
|
@@ -462,7 +615,7 @@ function wpsc_admin_sale_rss() {
|
|
462 |
}
|
463 |
|
464 |
function wpsc_display_invoice() {
|
465 |
-
$purchase_id = (int)$
|
466 |
add_action('wpsc_packing_slip', 'wpsc_packing_slip');
|
467 |
do_action('wpsc_before_packing_slip', $purchase_id);
|
468 |
do_action('wpsc_packing_slip', $purchase_id);
|
@@ -480,18 +633,18 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc_display_invoice' == $_RE
|
|
480 |
*/
|
481 |
function wpsc_purchlog_resend_email() {
|
482 |
global $wpdb;
|
483 |
-
$log_id = $
|
484 |
$wpec_taxes_controller = new wpec_taxes_controller();
|
485 |
if ( is_numeric( $log_id ) ) {
|
486 |
-
$selectsql = "SELECT `sessionid` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`=
|
487 |
-
$purchase_log = $wpdb->get_var( $selectsql );
|
488 |
-
transaction_results( $purchase_log, false);
|
489 |
$sent = true;
|
490 |
}
|
491 |
$sendback = wp_get_referer();
|
492 |
-
if ( isset( $sent ) )
|
493 |
-
|
494 |
-
|
495 |
wp_redirect( $sendback );
|
496 |
exit();
|
497 |
}
|
@@ -586,8 +739,8 @@ if ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'
|
|
586 |
function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
|
587 |
global $wpdb;
|
588 |
if ( empty($purchlog_id) && empty($purchlog_status) ) {
|
589 |
-
$purchlog_id = absint( $_POST['
|
590 |
-
$purchlog_status = absint( $_POST['
|
591 |
}
|
592 |
|
593 |
$log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '{$purchlog_id}' LIMIT 1", ARRAY_A );
|
@@ -600,16 +753,29 @@ function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
|
|
600 |
// then you can get rid of this hook and have each person overwrite the method that updates the status.
|
601 |
do_action('wpsc_edit_order_status', array('purchlog_id'=>$purchlog_id, 'purchlog_data'=>$log_data, 'new_status'=>$purchlog_status));
|
602 |
|
603 |
-
$wpdb->
|
604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
wpsc_clear_stock_claims();
|
606 |
wpsc_decrement_claimed_stock($purchlog_id);
|
607 |
|
608 |
if ( $purchlog_status == 3 )
|
609 |
-
|
|
|
|
|
|
|
|
|
610 |
}
|
611 |
|
612 |
-
add_action( '
|
613 |
|
614 |
function wpsc_save_product_order() {
|
615 |
global $wpdb;
|
@@ -622,9 +788,18 @@ function wpsc_save_product_order() {
|
|
622 |
print_r( $products );
|
623 |
|
624 |
foreach ( $products as $order => $product_id ) {
|
625 |
-
|
626 |
-
|
627 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
628 |
$success = true;
|
629 |
|
630 |
exit( (string)$success );
|
@@ -634,22 +809,38 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
|
|
634 |
add_action( 'admin_init', 'wpsc_save_product_order' );
|
635 |
}
|
636 |
|
637 |
-
function
|
638 |
global $wpdb;
|
639 |
-
|
|
|
|
|
|
|
|
|
640 |
$order = 1;
|
641 |
-
foreach ( $
|
642 |
-
|
643 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
644 |
|
645 |
-
$order++;
|
646 |
}
|
647 |
-
$success = true;
|
648 |
|
649 |
-
|
650 |
}
|
651 |
-
|
652 |
-
|
653 |
|
654 |
/* Start Order Notes (by Ben) */
|
655 |
function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
|
@@ -659,7 +850,21 @@ function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' )
|
|
659 |
$purchlog_id = absint( $_POST['purchlog_id'] );
|
660 |
$purchlog_notes = $wpdb->escape( $_POST['purchlog_notes'] );
|
661 |
}
|
662 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
663 |
}
|
664 |
}
|
665 |
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
|
@@ -681,20 +886,20 @@ function wpsc_delete_purchlog( $purchlog_id='' ) {
|
|
681 |
$cart_content = $wpdb->get_results( $delete_log_form_sql, ARRAY_A );
|
682 |
}
|
683 |
|
684 |
-
$purchlog_status = $wpdb->get_var( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`="
|
685 |
if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
|
686 |
-
$wpdb->query( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` =
|
687 |
}
|
688 |
|
689 |
-
$wpdb->query( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid
|
690 |
-
$wpdb->query( "DELETE FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` IN (
|
691 |
-
$wpdb->query( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id
|
692 |
|
693 |
$deleted = 1;
|
694 |
|
695 |
if ( is_numeric( $_GET['purchlog_id'] ) ) {
|
696 |
$sendback = wp_get_referer();
|
697 |
-
$sendback = remove_query_arg( '
|
698 |
if ( isset( $deleted ) ) {
|
699 |
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
700 |
}
|
@@ -707,25 +912,8 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
|
|
707 |
add_action( 'admin_init', 'wpsc_delete_purchlog' );
|
708 |
}
|
709 |
|
710 |
-
/*
|
711 |
-
* Get Shipping Form ajax call
|
712 |
-
*/
|
713 |
-
|
714 |
-
function wpsc_ajax_get_shipping_form() {
|
715 |
-
$shippingname = $_REQUEST['shippingname'];
|
716 |
-
$_SESSION['previous_shipping_name'] = $shippingname;
|
717 |
-
$shipping_data = wpsc_get_shipping_form( $shippingname );
|
718 |
-
$html_shipping_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['name'] ) );
|
719 |
-
$shipping_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $shipping_data['form_fields'] ) );
|
720 |
-
echo "shipping_name_html = '$html_shipping_name'; \n\r";
|
721 |
-
echo "shipping_form_html = '$shipping_form'; \n\r";
|
722 |
-
echo "has_submit_button = '{$shipping_data['has_submit_button']}'; \n\r";
|
723 |
-
exit();
|
724 |
-
}
|
725 |
-
|
726 |
function wpsc_ajax_get_payment_form() {
|
727 |
$paymentname = $_REQUEST['paymentname'];
|
728 |
-
$_SESSION['previous_payment_name'] = $paymentname;
|
729 |
$payment_data = wpsc_get_payment_form( $paymentname );
|
730 |
$html_payment_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['name'] ) );
|
731 |
$payment_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['form_fields'] ) );
|
@@ -734,170 +922,10 @@ function wpsc_ajax_get_payment_form() {
|
|
734 |
echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
|
735 |
exit();
|
736 |
}
|
737 |
-
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_shipping_form') )
|
738 |
-
add_action( 'admin_init', 'wpsc_ajax_get_shipping_form' );
|
739 |
|
740 |
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_payment_form') )
|
741 |
add_action( 'admin_init', 'wpsc_ajax_get_payment_form' );
|
742 |
|
743 |
-
|
744 |
-
/*
|
745 |
-
* Submit Options from Settings Pages,
|
746 |
-
* takes an array of options checks to see whether it is empty or the same as the exisiting values
|
747 |
-
* and if its not it updates them.
|
748 |
-
*/
|
749 |
-
|
750 |
-
function wpsc_submit_options( $selected='' ) {
|
751 |
-
global $wpdb, $wpsc_gateways;
|
752 |
-
$updated = 0;
|
753 |
-
|
754 |
-
//This is to change the Overall target market selection
|
755 |
-
check_admin_referer( 'update-options', 'wpsc-update-options' );
|
756 |
-
if ( isset( $_POST['change-settings'] ) ) {
|
757 |
-
if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
|
758 |
-
update_option( 'wpsc_also_bought', 1 );
|
759 |
-
else
|
760 |
-
update_option( 'wpsc_also_bought', 0 );
|
761 |
-
|
762 |
-
if ( isset( $_POST['display_find_us'] ) && $_POST['display_find_us'] == 'on' )
|
763 |
-
update_option( 'display_find_us', 1 );
|
764 |
-
else
|
765 |
-
update_option( 'display_find_us', 0 );
|
766 |
-
|
767 |
-
if ( isset( $_POST['wpsc_share_this'] ) && $_POST['wpsc_share_this'] == 'on' )
|
768 |
-
update_option( 'wpsc_share_this', 1 );
|
769 |
-
else
|
770 |
-
update_option( 'wpsc_share_this', 0 );
|
771 |
-
|
772 |
-
}
|
773 |
-
if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
|
774 |
-
$selected = 'none';
|
775 |
-
|
776 |
-
if ( !isset( $_POST['countrylist2'] ) )
|
777 |
-
$_POST['countrylist2'] = '';
|
778 |
-
if ( !isset( $_POST['country_id'] ) )
|
779 |
-
$_POST['country_id'] = '';
|
780 |
-
if ( !isset( $_POST['country_tax'] ) )
|
781 |
-
$_POST['country_tax'] = '';
|
782 |
-
|
783 |
-
if ( $_POST['countrylist2'] != null || !empty($selected) ) {
|
784 |
-
$AllSelected = false;
|
785 |
-
if ( $selected == 'all' ) {
|
786 |
-
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
|
787 |
-
$AllSelected = true;
|
788 |
-
}
|
789 |
-
if ( $selected == 'none' ) {
|
790 |
-
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
|
791 |
-
$AllSelected = true;
|
792 |
-
}
|
793 |
-
if ( $AllSelected != true ) {
|
794 |
-
$countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
|
795 |
-
//find the countries not selected
|
796 |
-
$unselectedCountries = array_diff( $countrylist, $_POST['countrylist2'] );
|
797 |
-
foreach ( $unselectedCountries as $unselected ) {
|
798 |
-
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 0 WHERE id = '" . $unselected . "' LIMIT 1" );
|
799 |
-
}
|
800 |
-
|
801 |
-
//find the countries that are selected
|
802 |
-
$selectedCountries = array_intersect( $countrylist, $_POST['countrylist2'] );
|
803 |
-
foreach ( $selectedCountries as $selected ) {
|
804 |
-
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = 1 WHERE id = '" . $selected . "' LIMIT 1" );
|
805 |
-
}
|
806 |
-
}
|
807 |
-
}
|
808 |
-
$previous_currency = get_option( 'currency_type' );
|
809 |
-
|
810 |
-
//To update options
|
811 |
-
if ( isset( $_POST['wpsc_options'] ) ) {
|
812 |
-
// make sure stock keeping time is a number
|
813 |
-
if ( isset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] ) ) {
|
814 |
-
$skt =& $_POST['wpsc_options']['wpsc_stock_keeping_time']; // I hate repeating myself
|
815 |
-
$skt = (float) $skt;
|
816 |
-
if ( $skt <= 0 || ( $skt < 1 && $_POST['wpsc_options']['wpsc_stock_keeping_interval'] == 'hour' ) ) {
|
817 |
-
unset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] );
|
818 |
-
unset( $_POST['wpsc_options']['wpsc_stock_keeping_interval'] );
|
819 |
-
}
|
820 |
-
}
|
821 |
-
|
822 |
-
foreach ( $_POST['wpsc_options'] as $key => $value ) {
|
823 |
-
if ( $value != get_option( $key ) ) {
|
824 |
-
update_option( $key, $value );
|
825 |
-
$updated++;
|
826 |
-
|
827 |
-
}
|
828 |
-
}
|
829 |
-
}
|
830 |
-
|
831 |
-
if ( $previous_currency != get_option( 'currency_type' ) ) {
|
832 |
-
$currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` IN ('" . absint( get_option( 'currency_type' ) ) . "')" );
|
833 |
-
|
834 |
-
$selected_gateways = get_option( 'custom_gateway_options' );
|
835 |
-
$already_changed = array( );
|
836 |
-
foreach ( $selected_gateways as $selected_gateway ) {
|
837 |
-
if ( isset( $wpsc_gateways[$selected_gateway]['supported_currencies'] ) ) {
|
838 |
-
if ( in_array( $currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'] ) ) {
|
839 |
-
|
840 |
-
$option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
|
841 |
-
|
842 |
-
if ( !in_array( $option_name, $already_changed ) ) {
|
843 |
-
update_option( $option_name, $currency_code );
|
844 |
-
$already_changed[] = $option_name;
|
845 |
-
}
|
846 |
-
}
|
847 |
-
}
|
848 |
-
}
|
849 |
-
}
|
850 |
-
|
851 |
-
foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
|
852 |
-
if ( is_object( $shipping ) )
|
853 |
-
$shipping->submit_form();
|
854 |
-
}
|
855 |
-
|
856 |
-
|
857 |
-
//This is for submitting shipping details to the shipping module
|
858 |
-
if ( !isset( $_POST['update_gateways'] ) )
|
859 |
-
$_POST['update_gateways'] = '';
|
860 |
-
if ( !isset( $_POST['custom_shipping_options'] ) )
|
861 |
-
$_POST['custom_shipping_options'] = null;
|
862 |
-
if ( $_POST['update_gateways'] == 'true' ) {
|
863 |
-
|
864 |
-
update_option( 'custom_shipping_options', $_POST['custom_shipping_options'] );
|
865 |
-
|
866 |
-
$shipadd = 0;
|
867 |
-
foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
|
868 |
-
foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
|
869 |
-
if ( $shipping->internal_name == $shippingoption ) {
|
870 |
-
$shipadd++;
|
871 |
-
}
|
872 |
-
}
|
873 |
-
}
|
874 |
-
}
|
875 |
-
|
876 |
-
$sendback = wp_get_referer();
|
877 |
-
|
878 |
-
if ( isset( $updated ) ) {
|
879 |
-
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
880 |
-
}
|
881 |
-
if ( isset( $shipadd ) ) {
|
882 |
-
$sendback = add_query_arg( 'shipadd', $shipadd, $sendback );
|
883 |
-
}
|
884 |
-
|
885 |
-
if ( !isset( $_SESSION['wpsc_settings_curr_page'] ) )
|
886 |
-
$_SESSION['wpsc_settings_curr_page'] = '';
|
887 |
-
if ( !isset( $_POST['page_title'] ) )
|
888 |
-
$_POST['page_title'] = '';
|
889 |
-
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
890 |
-
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
891 |
-
}
|
892 |
-
|
893 |
-
$sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
|
894 |
-
$sendback = apply_filters( 'wpsc_settings_redirect_url', $sendback );
|
895 |
-
wp_redirect( $sendback );
|
896 |
-
exit();
|
897 |
-
}
|
898 |
-
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'submit_options') )
|
899 |
-
add_action( 'admin_init', 'wpsc_submit_options' );
|
900 |
-
|
901 |
add_action( 'update_option_product_category_hierarchical_url', 'wpsc_update_option_product_category_hierarchical_url' );
|
902 |
|
903 |
function wpsc_update_option_product_category_hierarchical_url() {
|
@@ -930,7 +958,17 @@ function wpsc_rearrange_images() {
|
|
930 |
$i = 0;
|
931 |
foreach ( $images as $image ) {
|
932 |
if ( $image > 0 ) {
|
933 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
934 |
$i++;
|
935 |
}
|
936 |
}
|
@@ -997,19 +1035,42 @@ function wpsc_clean_categories() {
|
|
997 |
$sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
|
998 |
foreach ( (array)$sql_data as $datarow ) {
|
999 |
if ( $datarow['active'] == 1 ) {
|
1000 |
-
$tidied_name = trim( $datarow['name'] );
|
1001 |
-
$tidied_name = strtolower( $tidied_name );
|
1002 |
$url_name = sanitize_title( $tidied_name );
|
1003 |
-
$similar_names = $wpdb->get_row( "SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '
|
1004 |
$extension_number = '';
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
|
|
1008 |
$url_name .= $extension_number;
|
1009 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1010 |
$updated;
|
|
|
1011 |
} else if ( $datarow['active'] == 0 ) {
|
1012 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1013 |
$updated;
|
1014 |
}
|
1015 |
}
|
@@ -1022,6 +1083,7 @@ function wpsc_clean_categories() {
|
|
1022 |
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
1023 |
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
1024 |
}
|
|
|
1025 |
wp_redirect( $sendback );
|
1026 |
|
1027 |
exit();
|
@@ -1035,9 +1097,19 @@ function wpsc_change_region_tax() {
|
|
1035 |
if ( is_array( $_POST['region_tax'] ) ) {
|
1036 |
foreach ( $_POST['region_tax'] as $region_id => $tax ) {
|
1037 |
if ( is_numeric( $region_id ) && is_numeric( $tax ) ) {
|
1038 |
-
$previous_tax = $wpdb->get_var( "SELECT `tax` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` =
|
1039 |
if ( $tax != $previous_tax ) {
|
1040 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1041 |
$changes_made = true;
|
1042 |
}
|
1043 |
}
|
@@ -1196,195 +1268,10 @@ function wpsc_gateway_settings() {
|
|
1196 |
if ( (isset( $_POST['payment_gw'] ) && $_POST['payment_gw'] != null ) ) {
|
1197 |
update_option( 'payment_gateway', $_POST['payment_gw'] );
|
1198 |
}
|
1199 |
-
$sendback = wp_get_referer();
|
1200 |
-
|
1201 |
-
if ( isset( $updated ) ) {
|
1202 |
-
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
1203 |
-
}
|
1204 |
-
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
1205 |
-
$sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
|
1206 |
-
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
1207 |
-
}
|
1208 |
-
wp_redirect( $sendback );
|
1209 |
-
exit();
|
1210 |
}
|
1211 |
if ( isset( $_REQUEST['wpsc_gateway_settings'] ) && ($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings') )
|
1212 |
add_action( 'admin_init', 'wpsc_gateway_settings' );
|
1213 |
|
1214 |
-
function wpsc_check_form_options() {
|
1215 |
-
global $wpdb;
|
1216 |
-
|
1217 |
-
$id = $wpdb->escape( $_POST['form_id'] );
|
1218 |
-
$sql = 'SELECT `options` FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE `id`=' . $id;
|
1219 |
-
$options = $wpdb->get_var( $sql );
|
1220 |
-
if ( $options != '' ) {
|
1221 |
-
$options = maybe_unserialize( $options );
|
1222 |
-
if ( !is_array( $options ) ) {
|
1223 |
-
$options = unserialize( $options );
|
1224 |
-
}
|
1225 |
-
$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>";
|
1226 |
-
|
1227 |
-
foreach ( (array)$options as $key => $value ) {
|
1228 |
-
$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 . "][]' /> <a class='wpsc_delete_option' href='' <img src='" . WPSC_CORE_IMAGES_URL . "/trash.gif' alt='" . __( 'Delete', 'wpsc' ) . "' title='" . __( 'Delete', 'wpsc' ) . "' /></a></td></tr>";
|
1229 |
-
}
|
1230 |
-
} else {
|
1231 |
-
$output = '';
|
1232 |
-
}
|
1233 |
-
exit( $output );
|
1234 |
-
}
|
1235 |
-
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'check_form_options') )
|
1236 |
-
add_action( 'admin_init', 'wpsc_check_form_options' );
|
1237 |
-
|
1238 |
-
//handles the editing and adding of new checkout fields
|
1239 |
-
function wpsc_checkout_settings() {
|
1240 |
-
global $wpdb;
|
1241 |
-
$updated = 0;
|
1242 |
-
$wpdb->show_errors = true;
|
1243 |
-
$filter = isset( $_POST['selected_form_set'] ) ? $_POST['selected_form_set'] : '0';
|
1244 |
-
if ( ! isset( $_POST['new_form_mandatory'] ) )
|
1245 |
-
$_POST['new_form_mandatory'] = array();
|
1246 |
-
|
1247 |
-
if ( $_POST['new_form_set'] != null ) {
|
1248 |
-
$checkout_sets = get_option( 'wpsc_checkout_form_sets' );
|
1249 |
-
$checkout_sets[] = $_POST['new_form_set'];
|
1250 |
-
update_option( 'wpsc_checkout_form_sets', $checkout_sets );
|
1251 |
-
}
|
1252 |
-
|
1253 |
-
/*
|
1254 |
-
// Save checkout options
|
1255 |
-
*/
|
1256 |
-
$options = array( );
|
1257 |
-
if ( isset($_POST['wpsc_checkout_option_label']) && is_array( $_POST['wpsc_checkout_option_label'] ) ) {
|
1258 |
-
foreach ( $_POST['wpsc_checkout_option_label'] as $form_id => $values ) {
|
1259 |
-
$options = array( );
|
1260 |
-
foreach ( (array)$values as $key => $form_option ) {
|
1261 |
-
$form_option = str_ireplace( "'", "", $form_option );
|
1262 |
-
$form_val = str_ireplace( "'", "", esc_attr( $_POST['wpsc_checkout_option_value'][$form_id][$key] ) );
|
1263 |
-
$options[$form_option] = $form_val;
|
1264 |
-
}
|
1265 |
-
|
1266 |
-
$options = serialize( $options );
|
1267 |
-
$wpdb->update(
|
1268 |
-
WPSC_TABLE_CHECKOUT_FORMS,
|
1269 |
-
array( 'options' => $options ),
|
1270 |
-
array( 'id' => $form_id ),
|
1271 |
-
'%s',
|
1272 |
-
'%d'
|
1273 |
-
);
|
1274 |
-
}
|
1275 |
-
}
|
1276 |
-
|
1277 |
-
|
1278 |
-
if ( $_POST['form_name'] != null ) {
|
1279 |
-
foreach ( $_POST['form_name'] as $form_id => $form_name ) {
|
1280 |
-
$form_type = $_POST['form_type'][$form_id];
|
1281 |
-
$form_mandatory = 0;
|
1282 |
-
if ( isset( $_POST['form_mandatory'][$form_id] ) && ($_POST['form_mandatory'][$form_id] == 1) ) {
|
1283 |
-
$form_mandatory = 1;
|
1284 |
-
}
|
1285 |
-
$form_display_log = 0;
|
1286 |
-
if ( isset( $_POST['form_display_log'][$form_id] ) && ($_POST['form_display_log'][$form_id] == 1) ) {
|
1287 |
-
$form_display_log = 1;
|
1288 |
-
}
|
1289 |
-
$unique_name = '';
|
1290 |
-
if ( $_POST['unique_names'][$form_id] != '-1' ) {
|
1291 |
-
$unique_name = $_POST['unique_names'][$form_id];
|
1292 |
-
}
|
1293 |
-
$wpdb->update(
|
1294 |
-
WPSC_TABLE_CHECKOUT_FORMS,
|
1295 |
-
array(
|
1296 |
-
'name' => $form_name,
|
1297 |
-
'type' => $form_type,
|
1298 |
-
'mandatory' => $form_mandatory,
|
1299 |
-
'display_log' => $form_display_log,
|
1300 |
-
'unique_name' => $unique_name,
|
1301 |
-
),
|
1302 |
-
array( 'id' => $form_id ),
|
1303 |
-
'%s',
|
1304 |
-
'%d'
|
1305 |
-
);
|
1306 |
-
}
|
1307 |
-
}
|
1308 |
-
|
1309 |
-
if ( isset( $_POST['new_form_name'] ) ) {
|
1310 |
-
$added = 0;
|
1311 |
-
foreach ( $_POST['new_form_name'] as $form_id => $form_name ) {
|
1312 |
-
$form_type = $_POST['new_form_type'][$form_id];
|
1313 |
-
$form_mandatory = 0;
|
1314 |
-
if ( ! empty( $_POST['new_form_mandatory'][$form_id] ) ) {
|
1315 |
-
$form_mandatory = 1;
|
1316 |
-
}
|
1317 |
-
$form_display_log = 0;
|
1318 |
-
if ( isset( $_POST['new_form_display_log'][$form_id] ) && $_POST['new_form_display_log'][$form_id] == 1 ) {
|
1319 |
-
$form_display_log = 1;
|
1320 |
-
}
|
1321 |
-
$form_unique_name = '';
|
1322 |
-
if ( $_POST['new_form_unique_name'][$form_id] != '-1' ) {
|
1323 |
-
$form_unique_name = $_POST['new_form_unique_name'][$form_id];
|
1324 |
-
}
|
1325 |
-
|
1326 |
-
$max_order_sql = "SELECT MAX(`checkout_order`) AS `checkout_order` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
|
1327 |
-
|
1328 |
-
if ( isset( $_POST['new_form_order'][$form_id] ) && $_POST['new_form_order'][$form_id] != '' ) {
|
1329 |
-
$order_number = $_POST['new_form_order'][$form_id];
|
1330 |
-
} else {
|
1331 |
-
$max_order_sql = $wpdb->get_results( $max_order_sql, ARRAY_A );
|
1332 |
-
$order_number = $max_order_sql[0]['checkout_order'] + 1;
|
1333 |
-
}
|
1334 |
-
|
1335 |
-
$wpdb->insert(
|
1336 |
-
WPSC_TABLE_CHECKOUT_FORMS,
|
1337 |
-
array(
|
1338 |
-
'name' => $form_name,
|
1339 |
-
'type' => $form_type,
|
1340 |
-
'mandatory' => $form_mandatory,
|
1341 |
-
'display_log' => $form_display_log,
|
1342 |
-
'default' => '',
|
1343 |
-
'active' => '1',
|
1344 |
-
'checkout_order' => $order_number,
|
1345 |
-
'unique_name' => $form_unique_name,
|
1346 |
-
'checkout_set' => $filter,
|
1347 |
-
),
|
1348 |
-
array( '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s' )
|
1349 |
-
);
|
1350 |
-
|
1351 |
-
$added++;
|
1352 |
-
}
|
1353 |
-
}
|
1354 |
-
|
1355 |
-
if ( isset( $_POST['wpsc_options'] ) ) {
|
1356 |
-
foreach ( $_POST['wpsc_options'] as $key => $value ) {
|
1357 |
-
if ( $value != get_option( $key ) ) {
|
1358 |
-
update_option( $key, $value );
|
1359 |
-
$updated++;
|
1360 |
-
}
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
$sendback = wp_get_referer();
|
1365 |
-
if ( isset( $form_set_key ) ) {
|
1366 |
-
$sendback = add_query_arg( 'checkout-set', $form_set_key, $sendback );
|
1367 |
-
} else if ( isset( $_POST['wpsc_form_set'] ) ) {
|
1368 |
-
$filter = $_POST['wpsc_form_set'];
|
1369 |
-
$sendback = add_query_arg( 'checkout-set', $filter, $sendback );
|
1370 |
-
}
|
1371 |
-
|
1372 |
-
if ( isset( $updated ) ) {
|
1373 |
-
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
1374 |
-
}
|
1375 |
-
if ( ! empty( $added ) ) {
|
1376 |
-
$sendback = add_query_arg( 'added', $added, $sendback );
|
1377 |
-
}
|
1378 |
-
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
1379 |
-
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
1380 |
-
}
|
1381 |
-
$sendback = add_query_arg( 'page', 'wpsc-settings', $sendback );
|
1382 |
-
wp_redirect( $sendback );
|
1383 |
-
exit();
|
1384 |
-
}
|
1385 |
-
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'checkout_settings') )
|
1386 |
-
add_action( 'admin_init', 'wpsc_checkout_settings' );
|
1387 |
-
|
1388 |
function wpsc_google_shipping_settings() {
|
1389 |
if ( isset( $_POST['submit'] ) ) {
|
1390 |
foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
|
@@ -1410,67 +1297,6 @@ if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action']
|
|
1410 |
add_action( 'admin_init', 'wpsc_google_shipping_settings' );
|
1411 |
}
|
1412 |
|
1413 |
-
//for ajax call of settings page tabs
|
1414 |
-
function wpsc_settings_page_ajax() {
|
1415 |
-
$html = '';
|
1416 |
-
$modified_page_title = $_POST['page_title'];
|
1417 |
-
$page_title = str_replace( "tab-", "", $modified_page_title );
|
1418 |
-
|
1419 |
-
check_admin_referer( $modified_page_title );
|
1420 |
-
switch ( $page_title ) {
|
1421 |
-
case 'checkout' :
|
1422 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/checkout.php' );
|
1423 |
-
wpsc_options_checkout();
|
1424 |
-
break;
|
1425 |
-
|
1426 |
-
case 'gateway' :
|
1427 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/gateway.php' );
|
1428 |
-
wpsc_options_gateway();
|
1429 |
-
break;
|
1430 |
-
|
1431 |
-
case 'shipping' :
|
1432 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/shipping.php' );
|
1433 |
-
wpsc_options_shipping();
|
1434 |
-
break;
|
1435 |
-
|
1436 |
-
case 'admin' :
|
1437 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/admin.php' );
|
1438 |
-
wpsc_options_admin();
|
1439 |
-
break;
|
1440 |
-
|
1441 |
-
case 'presentation' :
|
1442 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/presentation.php' );
|
1443 |
-
wpsc_options_presentation();
|
1444 |
-
break;
|
1445 |
-
|
1446 |
-
case 'taxes' :
|
1447 |
-
wpec_taxes_settings_page(); //see wpec-taxes view
|
1448 |
-
break;
|
1449 |
-
|
1450 |
-
case 'marketing' :
|
1451 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/marketing.php' );
|
1452 |
-
wpsc_options_marketing();
|
1453 |
-
break;
|
1454 |
-
|
1455 |
-
case 'import' :
|
1456 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/import.php' );
|
1457 |
-
wpsc_options_import();
|
1458 |
-
break;
|
1459 |
-
|
1460 |
-
case 'general' :
|
1461 |
-
default;
|
1462 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
|
1463 |
-
wpsc_options_general();
|
1464 |
-
break;
|
1465 |
-
}
|
1466 |
-
|
1467 |
-
$_SESSION['wpsc_settings_curr_page'] = $page_title;
|
1468 |
-
|
1469 |
-
exit( $html );
|
1470 |
-
}
|
1471 |
-
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'settings_page_ajax') )
|
1472 |
-
add_action( 'admin_init', 'wpsc_settings_page_ajax' );
|
1473 |
-
|
1474 |
function wpsc_update_variations() {
|
1475 |
$product_id = absint( $_POST["product_id"] );
|
1476 |
$product_type_object = get_post_type_object('wpsc-product');
|
@@ -1566,8 +1392,7 @@ function wpsc_delete_coupon(){
|
|
1566 |
$coupon_id = (int)$_GET['delete_id'];
|
1567 |
|
1568 |
if(isset($coupon_id)) {
|
1569 |
-
$wpdb->query("DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` =
|
1570 |
-
|
1571 |
$deleted = 1;
|
1572 |
}
|
1573 |
$sendback = wp_get_referer();
|
@@ -1667,11 +1492,41 @@ function variation_price_field( $variation ) {
|
|
1667 |
</tr>
|
1668 |
<?php
|
1669 |
}
|
1670 |
-
|
1671 |
}
|
1672 |
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
|
1673 |
add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
|
1674 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1675 |
function variation_price_field_check( $variation ) {
|
1676 |
|
1677 |
$term_prices = get_option( 'term_prices' );
|
@@ -1682,7 +1537,7 @@ function variation_price_field_check( $variation ) {
|
|
1682 |
$checked = ''; ?>
|
1683 |
|
1684 |
<tr class="form-field">
|
1685 |
-
<th scope="row" valign="top"><label for="apply_to_current"><?php _e( 'Apply to current variations?' ) ?></label></th>
|
1686 |
<td>
|
1687 |
<span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" style="width:2%;" <?php echo $checked; ?> /><?php _e( 'By checking this box, the price rule you implement above will be applied to all variations that currently exist. If you leave it unchecked, it will only apply to products that use this variation created or edited from now on. Take note, this will apply this rule to <strong>every</strong> product using this variation. If you need to override it for any reason on a specific product, simply go to that product and change the price.', 'wpsc' ); ?></span>
|
1688 |
</td>
|
@@ -1691,6 +1546,8 @@ function variation_price_field_check( $variation ) {
|
|
1691 |
}
|
1692 |
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
|
1693 |
|
|
|
|
|
1694 |
/**
|
1695 |
* @todo - Should probably refactor this at some point - very procedural,
|
1696 |
* WAY too many foreach loops for my liking :) But it does the trick
|
@@ -1784,4 +1641,55 @@ function wpsc_delete_variations( $postid ) {
|
|
1784 |
}
|
1785 |
}
|
1786 |
add_action( 'delete_post', 'wpsc_delete_variations' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1787 |
?>
|
8 |
* @package wp-e-commerce
|
9 |
* @since 3.7
|
10 |
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Add new variation set via AJAX.
|
14 |
+
*
|
15 |
+
* If the variation set name is the same as an existing variation set,
|
16 |
+
* the children variant terms will be added inside that existing set.
|
17 |
+
* @since 3.8.8
|
18 |
+
*/
|
19 |
+
function wpsc_add_variation_set() {
|
20 |
+
$new_variation_set = $_POST['variation_set'];
|
21 |
+
$variants = preg_split( '/\s*,\s*/', $_POST['variants'] );
|
22 |
+
|
23 |
+
$parent_term_exists = term_exists( $new_variation_set, 'wpsc-variation' );
|
24 |
+
|
25 |
+
// only use an existing parent ID if the term is not a child term
|
26 |
+
if ( $parent_term_exists ) {
|
27 |
+
$parent_term = get_term( $parent_term_exists['term_id'], 'wpsc-variation' );
|
28 |
+
if ( $parent_term->parent == '0' )
|
29 |
+
$variation_set_id = $parent_term_exists['term_id'];
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( empty( $variation_set_id ) ) {
|
33 |
+
$results = wp_insert_term( $new_variation_set, 'wpsc-variation' );
|
34 |
+
if ( is_wp_error( $results ) )
|
35 |
+
die('-1');
|
36 |
+
$variation_set_id = $results['term_id'];
|
37 |
+
}
|
38 |
+
|
39 |
+
$inserted_variants = array();
|
40 |
+
|
41 |
+
if ( ! empty( $variation_set_id ) ) {
|
42 |
+
foreach ( $variants as $variant ) {
|
43 |
+
$results = wp_insert_term( $variant, 'wpsc-variation', array( 'parent' => $variation_set_id ) );
|
44 |
+
|
45 |
+
if ( is_wp_error( $results ) )
|
46 |
+
die('-1');
|
47 |
+
|
48 |
+
$inserted_variants[] = $results['term_id'];
|
49 |
}
|
50 |
|
51 |
+
require_once( 'includes/walker-variation-checklist.php' );
|
52 |
+
|
53 |
+
/* --- DIRTY HACK START --- */
|
54 |
+
/*
|
55 |
+
There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485.
|
56 |
+
The next 3 lines will delete children term cache for wpsc-variation.
|
57 |
+
Without this hack, the new child variations won't be displayed on "Variations" page and
|
58 |
+
also won't be displayed in wp_terms_checklist() call below.
|
59 |
+
*/
|
60 |
+
clean_term_cache( $variation_set_id, 'wpsc-variation' );
|
61 |
+
delete_option('wpsc-variation_children');
|
62 |
+
wp_cache_set( 'last_changed', 1, 'terms' );
|
63 |
+
_get_term_hierarchy('wpsc-variation');
|
64 |
+
/* --- DIRTY HACK END --- */
|
65 |
+
|
66 |
+
wp_terms_checklist( (int) $_POST['post_id'], array(
|
67 |
+
'taxonomy' => 'wpsc-variation',
|
68 |
+
'descendants_and_self' => $variation_set_id,
|
69 |
+
'walker' => new WPSC_Walker_Variation_Checklist( $inserted_variants ),
|
70 |
+
'checked_ontop' => false,
|
71 |
+
) );
|
72 |
}
|
73 |
+
exit();
|
74 |
}
|
75 |
|
76 |
+
add_action( 'wp_ajax_wpsc_add_variation_set', 'wpsc_add_variation_set' );
|
77 |
+
|
78 |
+
function wpsc_payment_gateway_settings_form() {
|
79 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
80 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
81 |
+
|
82 |
+
require_once( 'settings-page.php' );
|
83 |
+
require_once( 'includes/settings-tabs/gateway.php' );
|
84 |
+
|
85 |
+
$tab = new WPSC_Settings_Tab_Gateway();
|
86 |
+
$tab->display_payment_gateway_settings_form();
|
87 |
+
exit;
|
88 |
}
|
89 |
|
90 |
+
add_action( 'wp_ajax_wpsc_payment_gateway_settings_form', 'wpsc_payment_gateway_settings_form' );
|
91 |
+
|
92 |
+
function wpsc_shipping_module_settings_form() {
|
93 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
94 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
95 |
+
|
96 |
+
require_once( 'settings-page.php' );
|
97 |
+
require_once( 'includes/settings-tabs/shipping.php' );
|
98 |
+
|
99 |
+
$tab = new WPSC_Settings_Tab_Shipping();
|
100 |
+
$tab->display_shipping_module_settings_form();
|
101 |
+
exit;
|
102 |
+
}
|
103 |
+
|
104 |
+
add_action( 'wp_ajax_wpsc_shipping_module_settings_form', 'wpsc_shipping_module_settings_form' );
|
105 |
+
|
106 |
+
function wpsc_navigate_settings_tab() {
|
107 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
108 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
109 |
+
|
110 |
+
require_once( 'settings-page.php' );
|
111 |
+
|
112 |
+
$settings_page = new WPSC_Settings_Page( $_POST['tab'] );
|
113 |
+
$settings_page->display_current_tab();
|
114 |
+
exit;
|
115 |
+
}
|
116 |
+
|
117 |
+
add_action( 'wp_ajax_wpsc_navigate_settings_tab', 'wpsc_navigate_settings_tab' );
|
118 |
+
|
119 |
+
function wpsc_display_region_list() {
|
120 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
121 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
122 |
+
|
123 |
+
require_once( 'settings-page.php' );
|
124 |
+
require_once( 'includes/settings-tabs/general.php' );
|
125 |
+
|
126 |
+
$tab = new WPSC_Settings_Tab_General();
|
127 |
+
$tab->display_region_drop_down();
|
128 |
+
exit;
|
129 |
+
}
|
130 |
+
|
131 |
+
add_action( 'wp_ajax_wpsc_display_region_list', 'wpsc_display_region_list' );
|
132 |
+
|
133 |
+
function wpsc_purchase_log_save_tracking_id() {
|
134 |
global $wpdb;
|
135 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_purchase_logs' ) )
|
136 |
+
die( 'Session expired. Try refreshing your Sales Log page.' );
|
137 |
+
|
138 |
+
|
139 |
+
$wpdb->update(
|
140 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
141 |
+
array(
|
142 |
+
'track_id' => $_POST['value']
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'id' => $_POST['log_id']
|
146 |
+
),
|
147 |
+
'%s',
|
148 |
+
'%d'
|
149 |
+
);
|
150 |
+
|
151 |
+
die('success');
|
152 |
+
}
|
153 |
+
|
154 |
+
add_action( 'wp_ajax_wpsc_purchase_log_save_tracking_id', 'wpsc_purchase_log_save_tracking_id' );
|
155 |
+
|
156 |
+
function wpsc_purchase_log_send_tracking_email() {
|
157 |
+
global $wpdb;
|
158 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_purchase_logs' ) )
|
159 |
+
die( 'Session expired. Try refreshing your Sales Log page.' );
|
160 |
+
|
161 |
+
$id = absint( $_POST['log_id'] );
|
162 |
+
$sql = $wpdb->prepare( "SELECT `track_id` FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE `id`=%d LIMIT 1", $id );
|
163 |
+
$trackingid = $wpdb->get_var( $sql );
|
164 |
|
165 |
$message = get_option( 'wpsc_trackingid_message' );
|
166 |
$message = str_replace( '%trackid%', $trackingid, $message );
|
167 |
$message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
|
168 |
|
169 |
$email_form_field = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1" );
|
170 |
+
$email = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=%d AND `form_id` = '$email_form_field' LIMIT 1", $id ) );
|
|
|
171 |
|
172 |
$subject = get_option( 'wpsc_trackingid_subject' );
|
173 |
$subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
|
176 |
add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
|
177 |
|
178 |
wp_mail( $email, $subject, $message);
|
179 |
+
die( 'success' );
|
|
|
|
|
|
|
|
|
180 |
}
|
181 |
|
182 |
+
add_action( 'wp_ajax_wpsc_purchase_log_send_tracking_email', 'wpsc_purchase_log_send_tracking_email' );
|
|
|
|
|
183 |
|
184 |
function wpsc_ajax_sales_quarterly() {
|
185 |
$lastdate = $_POST['add_start'];
|
213 |
function wpsc_delete_file() {
|
214 |
global $wpdb;
|
215 |
$output = 0;
|
216 |
+
$row_number = absint( $_REQUEST['row_number'] );
|
217 |
+
$product_id = absint( $_REQUEST['product_id'] );
|
218 |
+
$file_name = basename( $_REQUEST['file_name'] );
|
219 |
check_admin_referer( 'delete_file_' . $file_name );
|
220 |
|
221 |
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_parent = %d AND post_type ='wpsc-product-file'", $file_name, $product_id );
|
226 |
if ( $_POST['ajax'] !== 'true' ) {
|
227 |
$sendback = wp_get_referer();
|
228 |
wp_redirect( $sendback );
|
229 |
+
exit;
|
230 |
}
|
231 |
|
232 |
echo "jQuery('#select_product_file_row_$row_number').fadeOut('fast',function() {\n";
|
281 |
wp_redirect( $sendback );
|
282 |
exit();
|
283 |
} else {
|
284 |
+
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: ', 'wpsc' ) . $id );
|
285 |
}
|
286 |
}
|
287 |
|
346 |
*/
|
347 |
function wpsc_duplicate_product_meta( $id, $new_id ) {
|
348 |
global $wpdb;
|
|
|
349 |
|
350 |
+
$post_meta_infos = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = %d", $id ) );
|
351 |
+
|
352 |
+
if ( count( $post_meta_infos ) ) {
|
353 |
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
354 |
$values = array();
|
355 |
foreach ( $post_meta_infos as $meta_info ) {
|
372 |
* Duplicates children product and children meta
|
373 |
*/
|
374 |
function wpsc_duplicate_children( $old_parent_id, $new_parent_id ) {
|
|
|
375 |
|
376 |
//Get children products and duplicate them
|
377 |
$child_posts = get_posts( array(
|
381 |
'numberposts' => -1,
|
382 |
) );
|
383 |
|
384 |
+
foreach ( $child_posts as $child_post )
|
385 |
+
wpsc_duplicate_product_process( $child_post, $new_parent_id );
|
386 |
+
|
387 |
}
|
388 |
|
389 |
function wpsc_purchase_log_csv() {
|
390 |
global $wpdb, $wpsc_gateways;
|
391 |
get_currentuserinfo();
|
392 |
$count = 0;
|
393 |
+
if ( 'key' == $_REQUEST['rss_key'] && current_user_can( 'manage_options' ) ) {
|
394 |
+
if ( isset( $_REQUEST['start_timestamp'] ) && isset( $_REQUEST['end_timestamp'] ) ) {
|
395 |
+
$start_timestamp = $_REQUEST['start_timestamp'];
|
396 |
+
$end_timestamp = $_REQUEST['end_timestamp'];
|
397 |
+
$start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
|
398 |
+
$start_end_sql = apply_filters( 'wpsc_purchase_log_start_end_csv', $start_end_sql );
|
399 |
+
$data = $wpdb->get_results( $wpdb->prepare( $start_end_sql, $start_timestamp, $end_timestamp ), ARRAY_A );
|
400 |
+
$csv_name = 'Purchase Log ' . date( "M-d-Y", $start_timestamp ) . ' to ' . date( "M-d-Y", $end_timestamp ) . '.csv';
|
401 |
+
} elseif ( isset( $_REQUEST['m'] ) ) {
|
402 |
+
$year = (int) substr( $_REQUEST['m'], 0, 4);
|
403 |
+
$month = (int) substr( $_REQUEST['m'], -2 );
|
404 |
+
$month_year_sql = "
|
405 |
+
SELECT *
|
406 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . "
|
407 |
+
WHERE YEAR(FROM_UNIXTIME(date)) = %d AND MONTH(FROM_UNIXTIME(date)) = %d
|
408 |
+
";
|
409 |
+
$month_year_sql = apply_filters( 'wpsc_purchase_log_month_year_csv', $month_year_sql );
|
410 |
+
$data = $wpdb->get_results( $wpdb->prepare( $month_year_sql, $year, $month ), ARRAY_A );
|
411 |
+
$csv_name = 'Purchase Log ' . $month . '/' . $year . '.csv';
|
412 |
+
} else {
|
413 |
+
$sql = apply_filters( 'wpsc_purchase_log_month_year_csv', "SELECT * FROM " . WPSC_TABLE_PURCHASE_LOGS );
|
414 |
+
$data = $wpdb->get_results( $sql, ARRAY_A );
|
415 |
+
$csv_name = "All Purchase Logs.csv";
|
416 |
+
}
|
417 |
+
|
418 |
$form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
|
419 |
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
|
|
|
|
|
|
|
|
|
420 |
$csv = 'Purchase ID, Price, Firstname, Lastname, Email, Order Status, Data, ';
|
|
|
|
|
|
|
421 |
|
422 |
+
$headers = "\"Purchase ID\",\"Purchase Total\","; //capture the headers
|
423 |
$headers2 ="\"Payment Gateway\",";
|
424 |
$headers2 .="\"Payment Status\",\"Purchase Date\",";
|
425 |
|
426 |
+
$output = '';
|
427 |
|
428 |
foreach ( (array)$data as $purchase ) {
|
429 |
$form_headers = '';
|
437 |
$output .= "\"" . $collected_data['value'] . "\","; // get form fields
|
438 |
}
|
439 |
|
440 |
+
if ( isset( $wpsc_gateways[$purchase['gateway']] ) && isset( $wpsc_gateways[$purchase['gateway']]['display_name'] ) )
|
441 |
+
$output .= "\"" . $wpsc_gateways[$purchase['gateway']]['display_name'] . "\","; //get gateway name
|
442 |
+
else
|
443 |
+
$output .= "\"\",";
|
444 |
|
445 |
|
446 |
$status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
|
451 |
$cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
|
452 |
$cart = $wpdb->get_results( $cartsql, ARRAY_A );
|
453 |
|
454 |
+
if( $count < count( $cart ) )
|
455 |
+
$count = count( $cart );
|
456 |
// Go through all products in cart and display quantity and sku
|
457 |
foreach ( (array)$cart as $item ) {
|
458 |
+
$skuvalue = get_product_meta( $item['prodid'], 'sku', true );
|
459 |
+
if( empty( $skuvalue ) )
|
460 |
+
$skuvalue = __( 'N/A', 'wpsc' );
|
461 |
$output .= "\"" . $item['quantity'] . " x " . str_replace( '"', '\"', $item['name'] ) . "\"";
|
462 |
$output .= "," . $skuvalue."," ;
|
463 |
}
|
465 |
}
|
466 |
// Get the most number of products and create a header for them
|
467 |
$headers3 = "";
|
468 |
+
for( $i = 0; $i < $count; $i++ ){
|
469 |
$headers3 .= "\"Quantity - Product Name \", \" SKU \"";
|
470 |
+
if( $i < ( $count - 1 ) )
|
471 |
+
$headers3 .= ",";
|
472 |
}
|
473 |
|
474 |
+
$headers = apply_filters( 'wpsc_purchase_log_csv_headers', $headers . $form_headers . $headers2 . $headers3, $data, $form_data );
|
475 |
+
$output = apply_filters( 'wpsc_purchase_log_csv_output', $output, $data, $form_data );
|
476 |
+
header( 'Content-Type: text/csv' );
|
477 |
+
header( 'Content-Disposition: inline; filename="' . $csv_name . '"' );
|
478 |
+
echo $headers . "\n". $output;
|
479 |
+
exit;
|
480 |
}
|
481 |
}
|
482 |
|
515 |
exit();
|
516 |
}
|
517 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
if ( isset( $_POST['hide_ecom_dashboard'] ) && $_POST['hide_ecom_dashboard'] == 'true' ) {
|
519 |
require_once (ABSPATH . WPINC . '/rss.php');
|
520 |
$rss = fetch_rss( 'http://www.instinct.co.nz/feed/' );
|
545 |
exit();
|
546 |
} else {
|
547 |
|
548 |
+
$log_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id'] ), ARRAY_A );
|
549 |
if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
|
550 |
wpsc_member_activate_subscriptions( $_POST['id'] );
|
551 |
}
|
552 |
|
553 |
+
$wpdb->update(
|
554 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
555 |
+
array(
|
556 |
+
'processed' => $newvalue
|
557 |
+
),
|
558 |
+
array(
|
559 |
+
'id' => $_POST['id']
|
560 |
+
),
|
561 |
+
'%d',
|
562 |
+
'%d'
|
563 |
+
);
|
564 |
if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
|
565 |
transaction_results( $log_data['sessionid'], false );
|
566 |
}
|
615 |
}
|
616 |
|
617 |
function wpsc_display_invoice() {
|
618 |
+
$purchase_id = (int)$_REQUEST['purchaselog_id'];
|
619 |
add_action('wpsc_packing_slip', 'wpsc_packing_slip');
|
620 |
do_action('wpsc_before_packing_slip', $purchase_id);
|
621 |
do_action('wpsc_packing_slip', $purchase_id);
|
633 |
*/
|
634 |
function wpsc_purchlog_resend_email() {
|
635 |
global $wpdb;
|
636 |
+
$log_id = $_REQUEST['email_buyer_id'];
|
637 |
$wpec_taxes_controller = new wpec_taxes_controller();
|
638 |
if ( is_numeric( $log_id ) ) {
|
639 |
+
$selectsql = "SELECT `sessionid` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %d LIMIT 1";
|
640 |
+
$purchase_log = $wpdb->get_var( $wpdb->prepare( $selectsql, $log_id ) );
|
641 |
+
transaction_results( $purchase_log, false );
|
642 |
$sent = true;
|
643 |
}
|
644 |
$sendback = wp_get_referer();
|
645 |
+
if ( isset( $sent ) )
|
646 |
+
$sendback = add_query_arg( 'sent', $sent, $sendback );
|
647 |
+
|
648 |
wp_redirect( $sendback );
|
649 |
exit();
|
650 |
}
|
739 |
function wpsc_purchlog_edit_status( $purchlog_id='', $purchlog_status='' ) {
|
740 |
global $wpdb;
|
741 |
if ( empty($purchlog_id) && empty($purchlog_status) ) {
|
742 |
+
$purchlog_id = absint( $_POST['id'] );
|
743 |
+
$purchlog_status = absint( $_POST['new_status'] );
|
744 |
}
|
745 |
|
746 |
$log_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '{$purchlog_id}' LIMIT 1", ARRAY_A );
|
753 |
// then you can get rid of this hook and have each person overwrite the method that updates the status.
|
754 |
do_action('wpsc_edit_order_status', array('purchlog_id'=>$purchlog_id, 'purchlog_data'=>$log_data, 'new_status'=>$purchlog_status));
|
755 |
|
756 |
+
$wpdb->update(
|
757 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
758 |
+
array(
|
759 |
+
'processed' => $purchlog_status
|
760 |
+
),
|
761 |
+
array(
|
762 |
+
'id' => $purchlog_id
|
763 |
+
),
|
764 |
+
'%d',
|
765 |
+
'%d'
|
766 |
+
);
|
767 |
wpsc_clear_stock_claims();
|
768 |
wpsc_decrement_claimed_stock($purchlog_id);
|
769 |
|
770 |
if ( $purchlog_status == 3 )
|
771 |
+
transaction_results($log_data['sessionid'],false,null);
|
772 |
+
|
773 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
774 |
+
die('success');
|
775 |
+
}
|
776 |
}
|
777 |
|
778 |
+
add_action( 'wp_ajax_wpsc_change_purchase_log_status', 'wpsc_purchlog_edit_status' );
|
779 |
|
780 |
function wpsc_save_product_order() {
|
781 |
global $wpdb;
|
788 |
print_r( $products );
|
789 |
|
790 |
foreach ( $products as $order => $product_id ) {
|
791 |
+
$wpdb->update(
|
792 |
+
$wpdb->posts,
|
793 |
+
array(
|
794 |
+
'menu_order' => $order
|
795 |
+
),
|
796 |
+
array(
|
797 |
+
'ID' => $product_id
|
798 |
+
),
|
799 |
+
'%d',
|
800 |
+
'%d'
|
801 |
+
);
|
802 |
+
}
|
803 |
$success = true;
|
804 |
|
805 |
exit( (string)$success );
|
809 |
add_action( 'admin_init', 'wpsc_save_product_order' );
|
810 |
}
|
811 |
|
812 |
+
function wpsc_update_checkout_fields_order() {
|
813 |
global $wpdb;
|
814 |
+
|
815 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
816 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
817 |
+
|
818 |
+
$checkout_fields = $_REQUEST['sort_order'];
|
819 |
$order = 1;
|
820 |
+
foreach ( $checkout_fields as $checkout_field ) {
|
821 |
+
// ignore new fields
|
822 |
+
if ( strpos( $checkout_field, 'new-field' ) === 0 )
|
823 |
+
continue;
|
824 |
+
$checkout_field = absint( preg_replace('/[^0-9]+/', '', $checkout_field ) );
|
825 |
+
$wpdb->update(
|
826 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
827 |
+
array(
|
828 |
+
'notes' => $purchlog_notes
|
829 |
+
),
|
830 |
+
array(
|
831 |
+
'id' => $purchlog_id
|
832 |
+
),
|
833 |
+
'%s',
|
834 |
+
'%d'
|
835 |
+
);
|
836 |
|
837 |
+
$order ++;
|
838 |
}
|
|
|
839 |
|
840 |
+
die( 'success' );
|
841 |
}
|
842 |
+
|
843 |
+
add_action( 'wp_ajax_wpsc_update_checkout_fields_order', 'wpsc_update_checkout_fields_order' );
|
844 |
|
845 |
/* Start Order Notes (by Ben) */
|
846 |
function wpsc_purchlogs_update_notes( $purchlog_id = '', $purchlog_notes = '' ) {
|
850 |
$purchlog_id = absint( $_POST['purchlog_id'] );
|
851 |
$purchlog_notes = $wpdb->escape( $_POST['purchlog_notes'] );
|
852 |
}
|
853 |
+
$wpdb->update(
|
854 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
855 |
+
array(
|
856 |
+
'notes' => $purchlog_notes
|
857 |
+
),
|
858 |
+
array(
|
859 |
+
'id' => $purchlog_id
|
860 |
+
),
|
861 |
+
array(
|
862 |
+
'%s'
|
863 |
+
),
|
864 |
+
array(
|
865 |
+
'%d'
|
866 |
+
)
|
867 |
+
);
|
868 |
}
|
869 |
}
|
870 |
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'purchlogs_update_notes' ) )
|
886 |
$cart_content = $wpdb->get_results( $delete_log_form_sql, ARRAY_A );
|
887 |
}
|
888 |
|
889 |
+
$purchlog_status = $wpdb->get_var( $wpdb->prepare( "SELECT `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= %d", $purchlog_id ) );
|
890 |
if ( $purchlog_status == 5 || $purchlog_status == 1 ) {
|
891 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` WHERE `cart_id` = %d AND `cart_submitted` = '1'", $purchlog_id ) );
|
892 |
}
|
893 |
|
894 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchlog_id ) );
|
895 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` IN (%d)", $purchlog_id ) );
|
896 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = %d LIMIT 1", $purchlog_id ) );
|
897 |
|
898 |
$deleted = 1;
|
899 |
|
900 |
if ( is_numeric( $_GET['purchlog_id'] ) ) {
|
901 |
$sendback = wp_get_referer();
|
902 |
+
$sendback = remove_query_arg( array( 'c', 'id' ), $sendback );
|
903 |
if ( isset( $deleted ) ) {
|
904 |
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
905 |
}
|
912 |
add_action( 'admin_init', 'wpsc_delete_purchlog' );
|
913 |
}
|
914 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
915 |
function wpsc_ajax_get_payment_form() {
|
916 |
$paymentname = $_REQUEST['paymentname'];
|
|
|
917 |
$payment_data = wpsc_get_payment_form( $paymentname );
|
918 |
$html_payment_name = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['name'] ) );
|
919 |
$payment_form = str_replace( Array( "\n", "\r" ), Array( "\\n", "\\r" ), addslashes( $payment_data['form_fields'] ) );
|
922 |
echo "has_submit_button = '{$payment_data['has_submit_button']}'; \n\r";
|
923 |
exit();
|
924 |
}
|
|
|
|
|
925 |
|
926 |
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'get_payment_form') )
|
927 |
add_action( 'admin_init', 'wpsc_ajax_get_payment_form' );
|
928 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
add_action( 'update_option_product_category_hierarchical_url', 'wpsc_update_option_product_category_hierarchical_url' );
|
930 |
|
931 |
function wpsc_update_option_product_category_hierarchical_url() {
|
958 |
$i = 0;
|
959 |
foreach ( $images as $image ) {
|
960 |
if ( $image > 0 ) {
|
961 |
+
$wpdb->update(
|
962 |
+
$wpdb->posts,
|
963 |
+
array(
|
964 |
+
'menu_order' => $i
|
965 |
+
),
|
966 |
+
array(
|
967 |
+
'ID' => $image
|
968 |
+
),
|
969 |
+
'%d',
|
970 |
+
'%d'
|
971 |
+
);
|
972 |
$i++;
|
973 |
}
|
974 |
}
|
1035 |
$sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
|
1036 |
foreach ( (array)$sql_data as $datarow ) {
|
1037 |
if ( $datarow['active'] == 1 ) {
|
1038 |
+
$tidied_name = strtolower( trim( $datarow['name'] ) );
|
|
|
1039 |
$url_name = sanitize_title( $tidied_name );
|
1040 |
+
$similar_names = $wpdb->get_row( $wpdb->prepare( "SELECT COUNT(*) AS `count`, MAX(REPLACE(`nice-name`, '%s', '')) AS `max_number` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `nice-name` REGEXP '^( " . esc_sql( $url_name ) . " ){1}(\d)*$' AND `id` NOT IN (%d) ", $url_name, $datarow['id'] ), ARRAY_A );
|
1041 |
$extension_number = '';
|
1042 |
+
|
1043 |
+
if ( $similar_names['count'] > 0 )
|
1044 |
+
$extension_number = (int)$similar_names['max_number'] + 2;
|
1045 |
+
|
1046 |
$url_name .= $extension_number;
|
1047 |
+
|
1048 |
+
$wpdb->update(
|
1049 |
+
WPSC_TABLE_PRODUCT_CATEGORIES,
|
1050 |
+
array(
|
1051 |
+
'nice-name' => $url_name
|
1052 |
+
),
|
1053 |
+
array(
|
1054 |
+
'id' => $datarow['id']
|
1055 |
+
),
|
1056 |
+
'%s',
|
1057 |
+
'%d'
|
1058 |
+
);
|
1059 |
+
|
1060 |
$updated;
|
1061 |
+
|
1062 |
} else if ( $datarow['active'] == 0 ) {
|
1063 |
+
$wpdb->update(
|
1064 |
+
WPSC_TABLE_PRODUCT_CATEGORIES,
|
1065 |
+
array(
|
1066 |
+
'nice-name' => ''
|
1067 |
+
),
|
1068 |
+
array(
|
1069 |
+
'id' => $datarow['id']
|
1070 |
+
),
|
1071 |
+
'%s',
|
1072 |
+
'%d'
|
1073 |
+
);
|
1074 |
$updated;
|
1075 |
}
|
1076 |
}
|
1083 |
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
1084 |
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
1085 |
}
|
1086 |
+
|
1087 |
wp_redirect( $sendback );
|
1088 |
|
1089 |
exit();
|
1097 |
if ( is_array( $_POST['region_tax'] ) ) {
|
1098 |
foreach ( $_POST['region_tax'] as $region_id => $tax ) {
|
1099 |
if ( is_numeric( $region_id ) && is_numeric( $tax ) ) {
|
1100 |
+
$previous_tax = $wpdb->get_var( $wpdb->prepare( "SELECT `tax` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` = %d LIMIT 1", $region_id ) );
|
1101 |
if ( $tax != $previous_tax ) {
|
1102 |
+
$wpdb->update(
|
1103 |
+
WPSC_TABLE_REGION_TAX,
|
1104 |
+
array(
|
1105 |
+
'tax' => $tax
|
1106 |
+
),
|
1107 |
+
array(
|
1108 |
+
'id' => $region_id
|
1109 |
+
),
|
1110 |
+
'%s',
|
1111 |
+
'%d'
|
1112 |
+
);
|
1113 |
$changes_made = true;
|
1114 |
}
|
1115 |
}
|
1268 |
if ( (isset( $_POST['payment_gw'] ) && $_POST['payment_gw'] != null ) ) {
|
1269 |
update_option( 'payment_gateway', $_POST['payment_gw'] );
|
1270 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1271 |
}
|
1272 |
if ( isset( $_REQUEST['wpsc_gateway_settings'] ) && ($_REQUEST['wpsc_gateway_settings'] == 'gateway_settings') )
|
1273 |
add_action( 'admin_init', 'wpsc_gateway_settings' );
|
1274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1275 |
function wpsc_google_shipping_settings() {
|
1276 |
if ( isset( $_POST['submit'] ) ) {
|
1277 |
foreach ( (array)$_POST['google_shipping'] as $key => $country ) {
|
1297 |
add_action( 'admin_init', 'wpsc_google_shipping_settings' );
|
1298 |
}
|
1299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1300 |
function wpsc_update_variations() {
|
1301 |
$product_id = absint( $_POST["product_id"] );
|
1302 |
$product_type_object = get_post_type_object('wpsc-product');
|
1392 |
$coupon_id = (int)$_GET['delete_id'];
|
1393 |
|
1394 |
if(isset($coupon_id)) {
|
1395 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_COUPON_CODES."` WHERE `id` = %d LIMIT 1", $coupon_id ) );
|
|
|
1396 |
$deleted = 1;
|
1397 |
}
|
1398 |
$sendback = wp_get_referer();
|
1492 |
</tr>
|
1493 |
<?php
|
1494 |
}
|
|
|
1495 |
}
|
1496 |
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
|
1497 |
add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
|
1498 |
|
1499 |
+
/*
|
1500 |
+
WordPress doesnt let you change the custom post type taxonomy form very easily
|
1501 |
+
Use Jquery to move the set variation (parent) field to the top and add a description
|
1502 |
+
*/
|
1503 |
+
function variation_set_field(){
|
1504 |
+
?>
|
1505 |
+
<script>
|
1506 |
+
/* change the text on the variation set from (none) to new variation set*/
|
1507 |
+
jQuery("#parent option[value='-1']").text("New Variation Set");
|
1508 |
+
/* Move to the top of the form and add a description */
|
1509 |
+
jQuery("#tag-name").parent().before( jQuery("#parent").parent().append('<p>Choose the Variation Set you want to add variants to. If your\'e creating a new variation set then select "New Variation Set"</p>') );
|
1510 |
+
/*
|
1511 |
+
create a small description about variations below the add variation / set title
|
1512 |
+
we can then get rid of the big red danger warning
|
1513 |
+
*/
|
1514 |
+
( jQuery("div#ajax-response").after('<p>Variations allow you to create options for your products, for example if you\'re selling T-Shirts they will have a size option you can create this as a variation. Size will be the Variation Set name, and it will be a "New Variant Set". You will then create variants (small, medium, large) which will have the "Variation Set" of Size. Once you have made your set you can use the table on the right to manage them (edit, delete). You will be able to order your variants by draging and droping them within their Variation Set.</p>') );
|
1515 |
+
</script>
|
1516 |
+
<?php
|
1517 |
+
}
|
1518 |
+
add_action( 'wpsc-variation_edit_form_fields', 'variation_set_field' );
|
1519 |
+
add_action( 'wpsc-variation_add_form_fields', 'variation_set_field' );
|
1520 |
+
|
1521 |
+
|
1522 |
+
function category_edit_form(){
|
1523 |
+
?>
|
1524 |
+
<script type="text/javascript">
|
1525 |
+
|
1526 |
+
</script>
|
1527 |
+
<?php
|
1528 |
+
}
|
1529 |
+
|
1530 |
function variation_price_field_check( $variation ) {
|
1531 |
|
1532 |
$term_prices = get_option( 'term_prices' );
|
1537 |
$checked = ''; ?>
|
1538 |
|
1539 |
<tr class="form-field">
|
1540 |
+
<th scope="row" valign="top"><label for="apply_to_current"><?php _e( 'Apply to current variations?', 'wpsc' ) ?></label></th>
|
1541 |
<td>
|
1542 |
<span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" style="width:2%;" <?php echo $checked; ?> /><?php _e( 'By checking this box, the price rule you implement above will be applied to all variations that currently exist. If you leave it unchecked, it will only apply to products that use this variation created or edited from now on. Take note, this will apply this rule to <strong>every</strong> product using this variation. If you need to override it for any reason on a specific product, simply go to that product and change the price.', 'wpsc' ); ?></span>
|
1543 |
</td>
|
1546 |
}
|
1547 |
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
|
1548 |
|
1549 |
+
|
1550 |
+
|
1551 |
/**
|
1552 |
* @todo - Should probably refactor this at some point - very procedural,
|
1553 |
* WAY too many foreach loops for my liking :) But it does the trick
|
1641 |
}
|
1642 |
}
|
1643 |
add_action( 'delete_post', 'wpsc_delete_variations' );
|
1644 |
+
|
1645 |
+
/*
|
1646 |
+
Save the variations that have been
|
1647 |
+
created on the products page
|
1648 |
+
*/
|
1649 |
+
function wpsc_add_variant_from_products_page() {
|
1650 |
+
/* This is the parent term / vartiation set we will save this first */
|
1651 |
+
$variation_set_term = $_POST['variation'];
|
1652 |
+
$variants[0] = $_POST['variant'];
|
1653 |
+
|
1654 |
+
/*
|
1655 |
+
variants can be coma separated so we check for
|
1656 |
+
these and put them into an array
|
1657 |
+
*/
|
1658 |
+
$variants = explode( ',', $variants[0] );
|
1659 |
+
wp_insert_term( $variation_set_term, 'wpsc-variation', $args = array() );
|
1660 |
+
|
1661 |
+
/* now get the parent id so we can save all the kids*/
|
1662 |
+
$parent_term = term_exists( $variation_set_term, 'wpsc-variation' ); // array is returned if taxonomy is given
|
1663 |
+
$parent_term_id = $parent_term['term_id']; // get numeric term id
|
1664 |
+
/* if we have a parent and some kids then we will add kids now */
|
1665 |
+
if( !empty($parent_term_id) && !empty($variants) ){
|
1666 |
+
foreach( $variants as $variant ){
|
1667 |
+
wp_insert_term( $variant, 'wpsc-variation', $args = array('parent' => $parent_term_id) );
|
1668 |
+
/* want to get out the id so we can return it with the response */
|
1669 |
+
$varient_term = term_exists( $variant, 'wpsc-variation', $parent_term_id );
|
1670 |
+
$variant_term_id[] = $varient_term['term_id']; // get numeric term id
|
1671 |
+
}
|
1672 |
+
}
|
1673 |
+
$response = new WP_Ajax_Response;
|
1674 |
+
$response -> add( array(
|
1675 |
+
'data' => 'success',
|
1676 |
+
'supplemental' => array(
|
1677 |
+
'variant_id' => implode(",",$variant_term_id),
|
1678 |
+
),
|
1679 |
+
)
|
1680 |
+
);
|
1681 |
+
$response -> send();
|
1682 |
+
exit();
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
add_action( 'wp_ajax_wpsc_add_variant_from_products_page', 'wpsc_add_variant_from_products_page' );
|
1686 |
+
|
1687 |
+
function wpsc_delete_variant_from_products_page(){
|
1688 |
+
$variant_id = $_POST['variant_id'];
|
1689 |
+
/* should never be empty but best to check first*/
|
1690 |
+
if (!empty($variant_id))
|
1691 |
+
wp_delete_term( $variant_id, 'wpsc-variation');
|
1692 |
+
exit();
|
1693 |
+
}
|
1694 |
+
add_action( 'wp_ajax_wpsc_delete_variant_from_products_page', 'wpsc_delete_variant_from_products_page' );
|
1695 |
?>
|
wpsc-admin/css/admin.css
CHANGED
@@ -1,20 +1,80 @@
|
|
1 |
/*
|
2 |
-
* This is the new WPSC Admin CSS file
|
3 |
|
4 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
.wpsc_trackingid_row{
|
6 |
margin-left:20px;
|
7 |
}
|
8 |
|
9 |
ul.children{
|
10 |
-
padding-left:5px;
|
11 |
}
|
12 |
.category_indenter{
|
13 |
-
|
14 |
float:left;
|
15 |
width:auto;
|
16 |
-
|
17 |
}
|
|
|
18 |
/**
|
19 |
*Dashboard Widget CSS
|
20 |
*
|
@@ -97,9 +157,6 @@ th#purchid{
|
|
97 |
th#details{
|
98 |
width:100px;
|
99 |
}
|
100 |
-
th#amount{
|
101 |
-
width:75px;
|
102 |
-
}
|
103 |
th#name{
|
104 |
/* width:220px; */
|
105 |
}
|
@@ -174,7 +231,7 @@ th#status{
|
|
174 |
textarea#additional_description{
|
175 |
border: 1px solid #dfdfdf;
|
176 |
/* width:465px !important; */
|
177 |
-
}
|
178 |
.wpsc-separator {
|
179 |
background:transparent url(../../images/menu-arrows.gif) no-repeat scroll left 5px;
|
180 |
cursor:w-resize;
|
@@ -267,14 +324,13 @@ table.widefat .ui-sortable-helper td, table.widefat .ui-sortable-helper th{
|
|
267 |
border-top: 1px solid #DFDFDF;
|
268 |
opacity: .4;
|
269 |
}
|
270 |
-
.product-placeholder {
|
271 |
border-width: 1px;
|
272 |
border-style: dashed;
|
273 |
z-index: 900;
|
274 |
border-color: #bbb;
|
275 |
background-color: #eaeaea !important;
|
276 |
-
|
277 |
-
height: 50px;
|
278 |
}
|
279 |
|
280 |
div#poststuff table tr td {
|
@@ -571,22 +627,22 @@ div.image_resize_extra_forms {
|
|
571 |
|
572 |
/* variations CSS starts */
|
573 |
|
574 |
-
table.product_variation_listing{
|
575 |
margin-bottom: 12px;
|
576 |
}
|
577 |
|
578 |
-
table.product_variation_listing th.variation_name{
|
579 |
color: #71A4C8;
|
580 |
font-style: italic;
|
581 |
text-align: left;
|
582 |
padding-bottom: 1px;
|
583 |
}
|
584 |
|
585 |
-
table.product_variation_grid{
|
586 |
margin-top: 12px;
|
587 |
}
|
588 |
|
589 |
-
table.product_variation_grid th.variation_name{
|
590 |
color: #71A4C8;
|
591 |
font-style: italic;
|
592 |
text-align: left;
|
@@ -712,17 +768,6 @@ div.variation_checkboxes {
|
|
712 |
margin-bottom: 4px;
|
713 |
}
|
714 |
|
715 |
-
div.variation_checkboxes label {
|
716 |
-
display: block;
|
717 |
-
margin-bottom: 2px;
|
718 |
-
}
|
719 |
-
|
720 |
-
div.variation_checkboxes label input {
|
721 |
-
position: relative;
|
722 |
-
top: 2px;
|
723 |
-
margin-right: 3px;
|
724 |
-
}
|
725 |
-
|
726 |
a.variation_edit_button {
|
727 |
display: block;
|
728 |
height: 16px;
|
@@ -751,18 +796,72 @@ div.select_variation_file p input {
|
|
751 |
top: 2px;
|
752 |
}
|
753 |
|
|
|
|
|
|
|
754 |
|
755 |
-
|
756 |
-
|
757 |
}
|
758 |
|
759 |
-
|
|
|
760 |
}
|
761 |
-
|
762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
}
|
764 |
-
/* variations CSS ends */
|
765 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
766 |
|
767 |
div#side-sortables input[type="file"] {
|
768 |
width:250px;
|
@@ -803,26 +902,10 @@ span.small_italic{
|
|
803 |
* Display Products CSS ends here
|
804 |
*/
|
805 |
|
806 |
-
/*
|
807 |
-
div.wpsc_shipping_options{
|
808 |
-
width:100%;
|
809 |
-
padding:3px 0;
|
810 |
-
}
|
811 |
-
.wpsc-shipping-actions{
|
812 |
-
visibility:hidden;
|
813 |
-
font-size: 10px;
|
814 |
-
margin:2px 9em 0 0;
|
815 |
-
float:right;
|
816 |
-
}
|
817 |
-
div.wpsc_shipping_options:hover .wpsc-shipping-actions{
|
818 |
-
font-size:10px;
|
819 |
-
visibility:visible;
|
820 |
-
}
|
821 |
-
|
822 |
-
/*
|
823 |
* Product Groups styles start here
|
824 |
*/
|
825 |
-
td.firstcol div.postbox div.inside{
|
826 |
margin: 0px;
|
827 |
padding: 0px;
|
828 |
}
|
@@ -1208,7 +1291,7 @@ a.admin_download span{
|
|
1208 |
text-decoration: underline;
|
1209 |
}
|
1210 |
|
1211 |
-
/*
|
1212 |
* Product Groups styles end here
|
1213 |
*/
|
1214 |
.wpsc_td_note{
|
@@ -1263,11 +1346,11 @@ a.variation_handle {
|
|
1263 |
{
|
1264 |
margin-right:300px
|
1265 |
}
|
1266 |
-
#media-buttons #add_audio,
|
1267 |
-
#media-buttons #add_video,
|
1268 |
#media-buttons #add_media {
|
1269 |
display:none;
|
1270 |
-
}
|
1271 |
.meta-box-sortables-wpec .postbox:hover .handlediv {
|
1272 |
background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
|
1273 |
}
|
@@ -1494,10 +1577,10 @@ div.modify_coupon{ border: 1px solid #eeeeee; display: none; width: 100%; }
|
|
1494 |
table.coupon_data{
|
1495 |
width: 100%;
|
1496 |
}
|
1497 |
-
table.add-coupon{width:100%;}
|
1498 |
table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
|
1499 |
table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
|
1500 |
-
table.add-coupon tr td p{padding:0;margin:5px;}
|
1501 |
#table_header{
|
1502 |
font-size:16px;
|
1503 |
margin-top:20px;
|
@@ -1613,13 +1696,13 @@ ul.wpsc_categories {
|
|
1613 |
clear: both;
|
1614 |
}
|
1615 |
|
1616 |
-
a.
|
1617 |
{
|
1618 |
-
|
1619 |
-
margin:10px;
|
1620 |
}
|
1621 |
-
|
1622 |
display:none;
|
|
|
1623 |
}
|
1624 |
#search-products{
|
1625 |
width:auto;
|
@@ -1667,7 +1750,7 @@ ul#category_list_li li span.handle {
|
|
1667 |
float:left;
|
1668 |
|
1669 |
padding: 5px;
|
1670 |
-
|
1671 |
}
|
1672 |
|
1673 |
.category_admin_list_img a.row-title{
|
@@ -1701,9 +1784,7 @@ input.wpsc_cat_box {
|
|
1701 |
width:auto;
|
1702 |
margin:6px;
|
1703 |
}
|
1704 |
-
|
1705 |
-
display:none;
|
1706 |
-
}
|
1707 |
.wpsc_ie_field{
|
1708 |
width:100%;
|
1709 |
}
|
@@ -1803,3 +1884,85 @@ float: left;
|
|
1803 |
vertical-align: middle;
|
1804 |
width: auto;
|
1805 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
/*
|
2 |
+
* This is the new WPSC Admin CSS file
|
3 |
|
4 |
*/
|
5 |
+
ul.variation_checkboxes li {
|
6 |
+
margin: 1px 0 3px;
|
7 |
+
}
|
8 |
+
/* This is the variation meta box stuff need to put it in the correct place - mychelle */
|
9 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td span{
|
10 |
+
display:none;
|
11 |
+
}
|
12 |
+
|
13 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.weight{
|
14 |
+
width: 81px;
|
15 |
+
}
|
16 |
+
|
17 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.stock{
|
18 |
+
width: 110px;
|
19 |
+
}
|
20 |
+
|
21 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.price{
|
22 |
+
width: 125px;
|
23 |
+
padding-top:10px;
|
24 |
+
}
|
25 |
+
|
26 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.post-title{
|
27 |
+
width: 115px;
|
28 |
+
}
|
29 |
+
|
30 |
+
div#wpsc_product_variation_forms table#wpsc_product_list td.stock {
|
31 |
+
display: none;
|
32 |
+
}
|
33 |
+
|
34 |
+
div#wpsc_add_variant_desc,
|
35 |
+
div#wpsc_add_variation_desc{
|
36 |
+
float: left;
|
37 |
+
margin:33px 0px 30px 20px;
|
38 |
+
}
|
39 |
+
|
40 |
+
div#wpsc_add_variation_desc{
|
41 |
+
width:300px;
|
42 |
+
}
|
43 |
+
|
44 |
+
div#wpsc_add_variant_desc{
|
45 |
+
width:200px;
|
46 |
+
}
|
47 |
+
|
48 |
+
div#wpsc_add_variant{
|
49 |
+
float: left;
|
50 |
+
max-width: 245px;
|
51 |
+
}
|
52 |
+
|
53 |
+
div #add_new_variation{
|
54 |
+
float:left;
|
55 |
+
width:215px;
|
56 |
+
}
|
57 |
+
|
58 |
+
input.wpsc_ie_field {
|
59 |
+
margin-bottom:10px;
|
60 |
+
}
|
61 |
+
|
62 |
+
.wpsc_ie_save{
|
63 |
+
margin-bottom:5px;
|
64 |
+
}
|
65 |
+
|
66 |
.wpsc_trackingid_row{
|
67 |
margin-left:20px;
|
68 |
}
|
69 |
|
70 |
ul.children{
|
71 |
+
padding-left:5px;
|
72 |
}
|
73 |
.category_indenter{
|
|
|
74 |
float:left;
|
75 |
width:auto;
|
|
|
76 |
}
|
77 |
+
|
78 |
/**
|
79 |
*Dashboard Widget CSS
|
80 |
*
|
157 |
th#details{
|
158 |
width:100px;
|
159 |
}
|
|
|
|
|
|
|
160 |
th#name{
|
161 |
/* width:220px; */
|
162 |
}
|
231 |
textarea#additional_description{
|
232 |
border: 1px solid #dfdfdf;
|
233 |
/* width:465px !important; */
|
234 |
+
}
|
235 |
.wpsc-separator {
|
236 |
background:transparent url(../../images/menu-arrows.gif) no-repeat scroll left 5px;
|
237 |
cursor:w-resize;
|
324 |
border-top: 1px solid #DFDFDF;
|
325 |
opacity: .4;
|
326 |
}
|
327 |
+
.wpsc-sortable-table-placeholder td, .product-placeholder {
|
328 |
border-width: 1px;
|
329 |
border-style: dashed;
|
330 |
z-index: 900;
|
331 |
border-color: #bbb;
|
332 |
background-color: #eaeaea !important;
|
333 |
+
height: 38px;
|
|
|
334 |
}
|
335 |
|
336 |
div#poststuff table tr td {
|
627 |
|
628 |
/* variations CSS starts */
|
629 |
|
630 |
+
table.product_variation_listing{
|
631 |
margin-bottom: 12px;
|
632 |
}
|
633 |
|
634 |
+
table.product_variation_listing th.variation_name{
|
635 |
color: #71A4C8;
|
636 |
font-style: italic;
|
637 |
text-align: left;
|
638 |
padding-bottom: 1px;
|
639 |
}
|
640 |
|
641 |
+
table.product_variation_grid{
|
642 |
margin-top: 12px;
|
643 |
}
|
644 |
|
645 |
+
table.product_variation_grid th.variation_name{
|
646 |
color: #71A4C8;
|
647 |
font-style: italic;
|
648 |
text-align: left;
|
768 |
margin-bottom: 4px;
|
769 |
}
|
770 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
771 |
a.variation_edit_button {
|
772 |
display: block;
|
773 |
height: 16px;
|
796 |
top: 2px;
|
797 |
}
|
798 |
|
799 |
+
.variation_checkboxes li {
|
800 |
+
margin:0;
|
801 |
+
}
|
802 |
|
803 |
+
.variation_checkboxes ul {
|
804 |
+
margin-left:30px;
|
805 |
}
|
806 |
|
807 |
+
.js .variation_checkboxes .children {
|
808 |
+
display:none;
|
809 |
}
|
810 |
+
|
811 |
+
.js .variation_checkboxes .expanded .children {
|
812 |
+
display:block;
|
813 |
+
}
|
814 |
+
|
815 |
+
.variation_checkboxes a.expand {
|
816 |
+
background:url(arrows.png) no-repeat left -108px;
|
817 |
+
display:inline-block;
|
818 |
+
height:15px;
|
819 |
+
width:15px;
|
820 |
+
text-indent:-999em;
|
821 |
+
vertical-align:middle;
|
822 |
+
}
|
823 |
+
|
824 |
+
.variation_checkboxes .expanded a.expand {
|
825 |
+
background-position:left top;
|
826 |
+
}
|
827 |
+
|
828 |
+
#add-new-variation-set {
|
829 |
+
margin-bottom:20px;
|
830 |
+
display:none;
|
831 |
+
}
|
832 |
+
|
833 |
+
#add-new-variation-set p {
|
834 |
+
position:relative;
|
835 |
+
}
|
836 |
+
|
837 |
+
#add-new-variation-set p.howto {
|
838 |
+
margin-bottom:16px;
|
839 |
+
}
|
840 |
+
|
841 |
+
#add-new-variation-set p label.focus {
|
842 |
+
color:#666;
|
843 |
+
}
|
844 |
+
|
845 |
+
#add-new-variation-set p.error label {
|
846 |
+
color:red;
|
847 |
+
}
|
848 |
+
|
849 |
+
#add-new-variation-set p label {
|
850 |
+
color:#000;
|
851 |
+
cursor:text;
|
852 |
+
left:6px;
|
853 |
+
position:absolute;
|
854 |
+
top:4px;
|
855 |
}
|
|
|
856 |
|
857 |
+
#add-new-variation-set .text-field {
|
858 |
+
width:195px;
|
859 |
+
}
|
860 |
+
|
861 |
+
.variation-set-prototype {
|
862 |
+
display:none;
|
863 |
+
}
|
864 |
+
/* variations CSS ends */
|
865 |
|
866 |
div#side-sortables input[type="file"] {
|
867 |
width:250px;
|
902 |
* Display Products CSS ends here
|
903 |
*/
|
904 |
|
905 |
+
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
906 |
* Product Groups styles start here
|
907 |
*/
|
908 |
+
td.firstcol div.postbox div.inside{
|
909 |
margin: 0px;
|
910 |
padding: 0px;
|
911 |
}
|
1291 |
text-decoration: underline;
|
1292 |
}
|
1293 |
|
1294 |
+
/*
|
1295 |
* Product Groups styles end here
|
1296 |
*/
|
1297 |
.wpsc_td_note{
|
1346 |
{
|
1347 |
margin-right:300px
|
1348 |
}
|
1349 |
+
#media-buttons #add_audio,
|
1350 |
+
#media-buttons #add_video,
|
1351 |
#media-buttons #add_media {
|
1352 |
display:none;
|
1353 |
+
}
|
1354 |
.meta-box-sortables-wpec .postbox:hover .handlediv {
|
1355 |
background: transparent url(../../wpsc-core/images/menu-bits.gif) no-repeat scroll 0% -111px;
|
1356 |
}
|
1577 |
table.coupon_data{
|
1578 |
width: 100%;
|
1579 |
}
|
1580 |
+
table.add-coupon{width:100%;}
|
1581 |
table.add-coupon tr th{ text-align: left; padding: 2px 5px 0px 5px; border: none;}
|
1582 |
table.add-coupon tr td{ text-align: left; padding: 2px 5px 2px 5px; border: none;}
|
1583 |
+
table.add-coupon tr td p{padding:0;margin:5px;}
|
1584 |
#table_header{
|
1585 |
font-size:16px;
|
1586 |
margin-top:20px;
|
1696 |
clear: both;
|
1697 |
}
|
1698 |
|
1699 |
+
a.update_variations_action
|
1700 |
{
|
1701 |
+
vertical-align:middle;
|
|
|
1702 |
}
|
1703 |
+
#poststuff .inside p.update-variations {
|
1704 |
display:none;
|
1705 |
+
margin-top:1em;
|
1706 |
}
|
1707 |
#search-products{
|
1708 |
width:auto;
|
1750 |
float:left;
|
1751 |
|
1752 |
padding: 5px;
|
1753 |
+
|
1754 |
}
|
1755 |
|
1756 |
.category_admin_list_img a.row-title{
|
1784 |
width:auto;
|
1785 |
margin:6px;
|
1786 |
}
|
1787 |
+
|
|
|
|
|
1788 |
.wpsc_ie_field{
|
1789 |
width:100%;
|
1790 |
}
|
1884 |
vertical-align: middle;
|
1885 |
width: auto;
|
1886 |
}
|
1887 |
+
|
1888 |
+
img.ajax-feedback-active {
|
1889 |
+
vertical-align:middle;
|
1890 |
+
visibility:visible;
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
.dashboard_page_wpsc-purchase-logs .column-id {
|
1894 |
+
width:75px;
|
1895 |
+
}
|
1896 |
+
|
1897 |
+
.dashboard_page_wpsc-purchase-logs .column-amount {
|
1898 |
+
width:100px;
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
.js table.purchase-logs td.column-status span, table.purchase-logs .column-status select {
|
1902 |
+
display:none;
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
.js table.purchase-logs .column-status select {
|
1906 |
+
display:inline-block;
|
1907 |
+
margin-right:5px;
|
1908 |
+
}
|
1909 |
+
|
1910 |
+
table.purchase-logs .column-tracking {
|
1911 |
+
position:relative;
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
table.purchase-logs .column-tracking .empty .send-email {
|
1915 |
+
display:none;
|
1916 |
+
}
|
1917 |
+
|
1918 |
+
table.purchase-logs .column-tracking .add {
|
1919 |
+
position:absolute;
|
1920 |
+
left:14px;
|
1921 |
+
top:7px;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
table.purchase-logs .column-tracking {
|
1925 |
+
width:200px;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
table.purchase-logs .column-tracking input[type="text"] {
|
1929 |
+
width:180px;
|
1930 |
+
}
|
1931 |
+
|
1932 |
+
table.purchase-logs .column-tracking a.save {
|
1933 |
+
display:none;
|
1934 |
+
float:right;
|
1935 |
+
}
|
1936 |
+
|
1937 |
+
table.purchase-logs .column-tracking a.add {
|
1938 |
+
display:none;
|
1939 |
+
color:#ccc;
|
1940 |
+
cursor:text;
|
1941 |
+
}
|
1942 |
+
|
1943 |
+
table.purchase-logs .column-tracking .empty a.add {
|
1944 |
+
display:inline;
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
table.purchase-logs .column-tracking .ajax-feedback {
|
1948 |
+
display:none;
|
1949 |
+
float:right;
|
1950 |
+
margin-top:5px;
|
1951 |
+
}
|
1952 |
+
|
1953 |
+
table.purchase-logs .column-tracking .ajax-feedback-active {
|
1954 |
+
display:inline-block;
|
1955 |
+
}
|
1956 |
+
|
1957 |
+
table.purchase-logs .column-tracking em.sent {
|
1958 |
+
color:green;
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
table.purchase-logs .column-id .delete {
|
1962 |
+
color:red;
|
1963 |
+
visibility:hidden;
|
1964 |
+
}
|
1965 |
+
|
1966 |
+
table.purchase-logs tr:hover .column-id .delete {
|
1967 |
+
visibility:visible;
|
1968 |
+
}
|
wpsc-admin/css/arrows.png
ADDED
Binary file
|
wpsc-admin/css/loading-small.gif
ADDED
Binary file
|
wpsc-admin/css/plus-minus.png
ADDED
Binary file
|
wpsc-admin/css/settingspage.css
CHANGED
@@ -1,37 +1,77 @@
|
|
1 |
table#wpsc_checkout_list{
|
2 |
width:100%;
|
3 |
}
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
th#drag{
|
8 |
width:50px;
|
9 |
}
|
|
|
|
|
|
|
10 |
tr.wpsc_grey{
|
11 |
background-color: #ededed;
|
12 |
}
|
13 |
td.drag a:hover{
|
14 |
-
|
15 |
-
/*background-image: url(../../images/roll-over-drag.jpg);
|
16 |
-
background-repeat: no-repeat;
|
17 |
-
background-position: center;*/
|
18 |
cursor: move;
|
19 |
}
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
#checkout_message{
|
25 |
display: none;
|
26 |
}
|
27 |
|
28 |
-
#wpsc_checkout_list
|
29 |
-
|
30 |
}
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
border-width: 1px;
|
36 |
border-style: dashed;
|
37 |
z-index: 900;
|
@@ -39,10 +79,6 @@ tr.checkout-placeholder {
|
|
39 |
background-color: #f5f5f5;
|
40 |
margin: -2px 0 0 -2px;
|
41 |
}
|
42 |
-
#wpsc_checkout_list tbody {
|
43 |
-
width: 700px;
|
44 |
-
border-collapse:collapse;
|
45 |
-
}
|
46 |
|
47 |
/* Removed to prevent overlapping the Contextual Help tab
|
48 |
#wpsc_options {
|
@@ -64,11 +100,11 @@ tr.checkout-placeholder {
|
|
64 |
min-width:850px;
|
65 |
}
|
66 |
|
67 |
-
table
|
68 |
padding: 0;
|
69 |
vertical-align: top;
|
70 |
}
|
71 |
-
|
72 |
padding: 0 0 8px 8px;
|
73 |
width:394px;
|
74 |
}
|
@@ -88,19 +124,11 @@ td.gateway_settings h4{
|
|
88 |
margin-top:0;
|
89 |
}
|
90 |
|
91 |
-
.wpsc_shipping_options{
|
92 |
-
border-top: 1px solid #e9e9e9;
|
93 |
-
|
94 |
-
}
|
95 |
-
td.select_gateway p {
|
96 |
-
margin: 0px 15px 4px 5px;
|
97 |
-
}
|
98 |
-
|
99 |
div#wpsc_shipwire_setting, div#shipping_discount_value {
|
100 |
display: none;
|
101 |
}
|
102 |
|
103 |
-
table
|
104 |
margin:0;
|
105 |
width:100%;
|
106 |
}
|
@@ -193,4 +221,218 @@ div#themes_and_appearance ol {
|
|
193 |
|
194 |
div#themes_and_appearance ol li {
|
195 |
font-size: 11px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
1 |
table#wpsc_checkout_list{
|
2 |
width:100%;
|
3 |
}
|
4 |
+
|
5 |
+
table#wpsc_checkout_list tbody {
|
6 |
+
position:relative;
|
7 |
+
}
|
8 |
+
|
9 |
+
th#actions{
|
10 |
+
width:65px;
|
11 |
}
|
12 |
th#drag{
|
13 |
width:50px;
|
14 |
}
|
15 |
+
th#name {
|
16 |
+
width:205px;
|
17 |
+
}
|
18 |
tr.wpsc_grey{
|
19 |
background-color: #ededed;
|
20 |
}
|
21 |
td.drag a:hover{
|
|
|
|
|
|
|
|
|
22 |
cursor: move;
|
23 |
}
|
24 |
+
|
25 |
+
th.column-type{
|
26 |
+
width:150px;
|
27 |
+
}
|
28 |
+
|
29 |
+
th.column-unique_name {
|
30 |
+
width:150px;
|
31 |
}
|
32 |
|
33 |
#checkout_message{
|
34 |
display: none;
|
35 |
}
|
36 |
|
37 |
+
#wpsc_checkout_list td {
|
38 |
+
vertical-align:middle;
|
39 |
}
|
40 |
+
|
41 |
+
#wpsc_checkout_list .uniquenamecol small {
|
42 |
+
color:#999;
|
43 |
+
}
|
44 |
+
|
45 |
+
td.drag a img {
|
46 |
+
vertical-align:middle;
|
47 |
+
}
|
48 |
+
|
49 |
+
#wpsc_checkout_list_body .ajax-feedback {
|
50 |
+
display:none;
|
51 |
+
}
|
52 |
+
|
53 |
+
#wpsc_checkout_list_body .ajax-feedback-active {
|
54 |
+
display:inline-block;
|
55 |
+
margin-left:4px;
|
56 |
}
|
57 |
+
|
58 |
+
th.column-mandatory, th.column-display {
|
59 |
+
width: 101px;
|
60 |
+
}
|
61 |
+
|
62 |
+
.widefat th.column-mandatory, td.mandatorycol, .widefat th.column-display, td.displaycol, .widefat th.column-trash, td.trashcol {
|
63 |
+
text-align:center;
|
64 |
+
}
|
65 |
+
|
66 |
+
#wpsc_checkout_list .ui-sortable-helper {
|
67 |
+
margin-left:0;
|
68 |
+
}
|
69 |
+
|
70 |
+
#wpsc_checkout_list .actionscol .cell-wrapper {
|
71 |
+
float:right !important;
|
72 |
+
}
|
73 |
+
|
74 |
+
tr.checkout-placeholder td {
|
75 |
border-width: 1px;
|
76 |
border-style: dashed;
|
77 |
z-index: 900;
|
79 |
background-color: #f5f5f5;
|
80 |
margin: -2px 0 0 -2px;
|
81 |
}
|
|
|
|
|
|
|
|
|
82 |
|
83 |
/* Removed to prevent overlapping the Contextual Help tab
|
84 |
#wpsc_options {
|
100 |
min-width:850px;
|
101 |
}
|
102 |
|
103 |
+
table.wpsc-edit-module-options tr td {
|
104 |
padding: 0;
|
105 |
vertical-align: top;
|
106 |
}
|
107 |
+
.wpsc-module-settings {
|
108 |
padding: 0 0 8px 8px;
|
109 |
width:394px;
|
110 |
}
|
124 |
margin-top:0;
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
div#wpsc_shipwire_setting, div#shipping_discount_value {
|
128 |
display: none;
|
129 |
}
|
130 |
|
131 |
+
table.wpsc-edit-module-options {
|
132 |
margin:0;
|
133 |
width:100%;
|
134 |
}
|
221 |
|
222 |
div#themes_and_appearance ol li {
|
223 |
font-size: 11px;
|
224 |
+
}
|
225 |
+
|
226 |
+
a.nav-tab-loading {
|
227 |
+
color:#D54E21;
|
228 |
+
}
|
229 |
+
|
230 |
+
#wpsc_options h2 .nav-tab {
|
231 |
+
font-size:16px;
|
232 |
+
line-height:20px;
|
233 |
+
padding:3px 6px 3px;
|
234 |
+
margin-right:0;
|
235 |
+
}
|
236 |
+
|
237 |
+
#wpsc_options h2.nav-tab-wrapper {
|
238 |
+
padding-left:7px;
|
239 |
+
}
|
240 |
+
|
241 |
+
#wpsc_options .postbox .inside p.submit {
|
242 |
+
margin-top:5px;
|
243 |
+
padding:0;
|
244 |
+
}
|
245 |
+
|
246 |
+
#wpsc-shipping-module-settings td small {
|
247 |
+
color:#666;
|
248 |
+
font-style:italic;
|
249 |
+
}
|
250 |
+
|
251 |
+
.wpsc-shipping-module-settings-tablerate .postbox .inside, .wpsc-shipping-module-settings-weightrate .postbox .inside {
|
252 |
+
padding: 0;
|
253 |
+
}
|
254 |
+
|
255 |
+
.wpsc-shipping-module-settings-tablerate .form-table th, .wpsc-shipping-module-settings-weightrate .form-table th {
|
256 |
+
border-bottom:1px solid #dfdfdf;
|
257 |
+
font-size:12px;
|
258 |
+
font-weight:bold;
|
259 |
+
padding:7px 10px 7px 20px;
|
260 |
+
}
|
261 |
+
|
262 |
+
.wpsc-shipping-module-settings-tablerate .form-table, .wpsc-shipping-module-settings-weightrate .form-table {
|
263 |
+
margin-top:0;
|
264 |
+
}
|
265 |
+
|
266 |
+
.wpsc-shipping-module-settings-tablerate .total {
|
267 |
+
width:120px;
|
268 |
+
}
|
269 |
+
|
270 |
+
.wpsc-shipping-module-settings-weightrate .form-table th.total-weight {
|
271 |
+
padding-left:10px;
|
272 |
+
width:140px;
|
273 |
+
}
|
274 |
+
|
275 |
+
.wpsc-shipping-module-settings-tablerate .form-table td, .wpsc-shipping-module-settings-weightrate .form-table td {
|
276 |
+
border-bottom:1px solid #dfdfdf;
|
277 |
+
padding:0 10px;
|
278 |
+
}
|
279 |
+
|
280 |
+
.wpsc-shipping-module-settings-tablerate .form-table td .cell-wrapper, .wpsc-shipping-module-settings-weightrate .form-table td .cell-wrapper {
|
281 |
+
padding:7px 0;
|
282 |
+
width:100%;
|
283 |
+
}
|
284 |
+
|
285 |
+
#wpsc_options .wpsc-shipping-module-settings-tablerate .postbox .inside .submit, #wpsc_options .wpsc-shipping-module-settings-weightrate .postbox .inside .submit {
|
286 |
+
padding:0 10px 0 20px;
|
287 |
+
}
|
288 |
+
|
289 |
+
.wpsc-shipping-module-settings-tablerate td .actions, .wpsc-shipping-module-settings-weightrate td .actions {
|
290 |
+
float:right;
|
291 |
+
margin-right:10px;
|
292 |
+
}
|
293 |
+
|
294 |
+
.wpsc-shipping-module-settings-tablerate td .add, .wpsc-shipping-module-settings-weightrate td .add {
|
295 |
+
display:none;
|
296 |
+
}
|
297 |
+
|
298 |
+
#wpsc_options .action {
|
299 |
+
display:none;
|
300 |
+
}
|
301 |
+
|
302 |
+
.js #wpsc_options .js-warning {
|
303 |
+
display:none;
|
304 |
+
}
|
305 |
+
|
306 |
+
.js #wpsc_options .wpsc-shipping-module-settings-tablerate td .action,
|
307 |
+
.js #wpsc_options .wpsc-shipping-module-settings-weightrate td .action,
|
308 |
+
.js #wpsc_checkout_list .action {
|
309 |
+
background-image:url(plus-minus.png);
|
310 |
+
background-repeat:no-repeat;
|
311 |
+
display:inline-block;
|
312 |
+
height:20px;
|
313 |
+
margin-left:3px;
|
314 |
+
text-indent:-9999em;
|
315 |
+
width:20px;
|
316 |
+
}
|
317 |
+
|
318 |
+
.js #wpsc_options .wpsc-shipping-module-settings-tablerate td span.action,
|
319 |
+
.js #wpsc_options .wpsc-shipping-module-settings-weightrate td span.action,
|
320 |
+
.js #wpsc_checkout_list span.action {
|
321 |
+
opacity:0.3;
|
322 |
+
}
|
323 |
+
|
324 |
+
.js .wpsc-shipping-module-settings-tablerate td a.add:hover,
|
325 |
+
.js .wpsc-shipping-module-settings-weightrate td a.add:hover,
|
326 |
+
.js #wpsc_checkout_list .actionscol a.add:hover,
|
327 |
+
.js .wpsc-field-options-table .column-actions a.add:hover {
|
328 |
+
background-position:-20px 0;
|
329 |
+
}
|
330 |
+
|
331 |
+
.js .wpsc-shipping-module-settings-tablerate td a.add:active,
|
332 |
+
.js .wpsc-shipping-module-settings-weightrate td a.add:active,
|
333 |
+
.js #wpsc_checkout_list .actionscol a.add:active,
|
334 |
+
.js .wpsc-field-options-table .column-actions a.add:active {
|
335 |
+
background-position:-40px 0;
|
336 |
+
}
|
337 |
+
|
338 |
+
.js .wpsc-shipping-module-settings-tablerate td a.delete:hover,
|
339 |
+
.js .wpsc-shipping-module-settings-weightrate td a.delete:hover,
|
340 |
+
.js #wpsc_checkout_list .actionscol a.delete:hover,
|
341 |
+
.js .wpsc-field-options-table .column-actions a.delete:hover {
|
342 |
+
background-position:-20px -20px;
|
343 |
+
}
|
344 |
+
|
345 |
+
.js .wpsc-shipping-module-settings-tablerate td a.delete:active,
|
346 |
+
.js .wpsc-shipping-module-settings-weightrate td a.delete:active,
|
347 |
+
.js #wpsc_checkout_list .actionscol a.delete:active,
|
348 |
+
.js .wpsc-field-options-table .column-actions a.delete:active {
|
349 |
+
background-position:-40px -20px;
|
350 |
+
}
|
351 |
+
|
352 |
+
.js .wpsc-shipping-module-settings-tablerate td .delete,
|
353 |
+
.js .wpsc-shipping-module-settings-weightrate td .delete,
|
354 |
+
.js #wpsc_checkout_list .actionscol .delete,
|
355 |
+
.js .wpsc-field-options-table .column-actions .delete {
|
356 |
+
background-position:0 -20px;
|
357 |
+
}
|
358 |
+
|
359 |
+
#wpsc_checkout_list .wpsc-field-options-table {
|
360 |
+
border-collapse:collapse;
|
361 |
+
margin-bottom:1em;
|
362 |
+
width:100%;
|
363 |
+
}
|
364 |
+
|
365 |
+
#wpsc_checkout_list .wpsc-field-options-table th {
|
366 |
+
background:none;
|
367 |
+
border-top:none;
|
368 |
+
color:#000;
|
369 |
+
font-family:sans-serif;
|
370 |
+
font-size:12px;
|
371 |
+
font-weight:bold;
|
372 |
+
padding:0 5px;
|
373 |
+
}
|
374 |
+
|
375 |
+
#wpsc_checkout_list .wpsc-field-options-table input {
|
376 |
+
width:100%;
|
377 |
+
}
|
378 |
+
|
379 |
+
#wpsc_checkout_list .wpsc-field-options-table td {
|
380 |
+
border:none;
|
381 |
+
padding:0 5px;
|
382 |
+
}
|
383 |
+
|
384 |
+
.js #wpsc_checkout_list .edit-options {
|
385 |
+
display:none;
|
386 |
+
}
|
387 |
+
|
388 |
+
.js .form-field-options {
|
389 |
+
display:none;
|
390 |
+
}
|
391 |
+
|
392 |
+
#wpsc_checkout_list .form-field-options td {
|
393 |
+
border-top:none;
|
394 |
+
}
|
395 |
+
|
396 |
+
#wpsc_checkout_list tr.editing-options td {
|
397 |
+
border-bottom:none;
|
398 |
+
}
|
399 |
+
|
400 |
+
#wpsc_checkout_list .wpsc-field-options-table td .field-option-cell-wrapper {
|
401 |
+
padding:7px 0;
|
402 |
+
}
|
403 |
+
|
404 |
+
#wpsc_checkout_list .wpsc-field-options-table .column-actions {
|
405 |
+
width:65px;
|
406 |
+
}
|
407 |
+
|
408 |
+
#wpsc_checkout_list .wpsc-field-options-table .column-actions .field-option-cell-wrapper {
|
409 |
+
float:right;
|
410 |
+
}
|
411 |
+
|
412 |
+
.js #wpsc_checkout_list .new-field {
|
413 |
+
display:none;
|
414 |
+
}
|
415 |
+
|
416 |
+
/* shipping options start here */
|
417 |
+
div.wpsc_shipping_options, div.wpsc-select-gateway {
|
418 |
+
border-top: 1px solid #e9e9e9;
|
419 |
+
width:100%;
|
420 |
+
padding:3px 0;
|
421 |
+
}
|
422 |
+
.wpsc-shipping-actions, .wpsc-gateway-actions {
|
423 |
+
visibility:hidden;
|
424 |
+
font-size: 10px;
|
425 |
+
line-height: 16px;
|
426 |
+
margin:0px 9em 0 0;
|
427 |
+
float:right;
|
428 |
+
}
|
429 |
+
div.wpsc_shipping_options:hover .wpsc-shipping-actions, div.wpsc-select-gateway:hover .wpsc-gateway-actions {
|
430 |
+
font-size:10px;
|
431 |
+
visibility:visible;
|
432 |
+
}
|
433 |
+
div.wpsc-select-gateway p, div.wpsc_shipping_options p {
|
434 |
+
margin: 0px 15px 4px 5px;
|
435 |
+
}
|
436 |
+
#wpsc-payment-gateway-settings-panel input[type=text], #wpsc-payment-gateway-settings-panel textarea {
|
437 |
+
width:265px;
|
438 |
}
|
wpsc-admin/display-coupons.php
CHANGED
@@ -27,9 +27,36 @@ function wpsc_display_coupons_page() {
|
|
27 |
unset( $new_rule[$key] );
|
28 |
}
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
}
|
35 |
|
@@ -40,7 +67,7 @@ function wpsc_display_coupons_page() {
|
|
40 |
$coupon_id = (int)$coupon_id;
|
41 |
$coupon_data['start'] = $coupon_data['start'] . " 00:00:00";
|
42 |
$coupon_data['expiry'] = $coupon_data['expiry'] . " 00:00:00";
|
43 |
-
$check_values = $wpdb->get_row( "SELECT `id`, `coupon_code`, `value`, `is-percentage`, `use-once`, `active`, `start`, `expiry`,`every_product` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` =
|
44 |
|
45 |
// Sort both arrays to make sure that if they contain the same stuff,
|
46 |
// that they will compare to be the same, may not need to do this, but what the heck
|
@@ -66,7 +93,7 @@ function wpsc_display_coupons_page() {
|
|
66 |
$insert_array[] = "`every_product` = '$coupon_data[add_every_product]'";
|
67 |
|
68 |
if ( count( $insert_array ) > 0 )
|
69 |
-
|
70 |
|
71 |
unset( $insert_array );
|
72 |
$rules = $_POST['rules'];
|
@@ -83,7 +110,7 @@ function wpsc_display_coupons_page() {
|
|
83 |
}
|
84 |
}
|
85 |
|
86 |
-
$conditions = $wpdb->get_var( "SELECT `condition` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` =
|
87 |
$conditions = unserialize( $conditions );
|
88 |
$new_cond = array();
|
89 |
|
@@ -93,22 +120,42 @@ function wpsc_display_coupons_page() {
|
|
93 |
$new_cond['value'] = $_POST['rules']['value'][0];
|
94 |
$conditions [] = $new_cond;
|
95 |
}
|
96 |
-
|
97 |
-
$
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
|
103 |
if ( isset( $_POST['delete_condition'] ) ) {
|
104 |
|
105 |
-
$conditions = $wpdb->get_var( "SELECT `condition` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` =
|
106 |
$conditions = unserialize( $conditions );
|
107 |
|
108 |
unset( $conditions[(int)$_POST['delete_condition']] );
|
109 |
|
110 |
-
$
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
if ( isset( $_POST['submit_condition'] ) ) {
|
@@ -120,9 +167,19 @@ function wpsc_display_coupons_page() {
|
|
120 |
$new_cond['logic'] = $_POST['rules']['logic'][0];
|
121 |
$new_cond['value'] = $_POST['rules']['value'][0];
|
122 |
$conditions[] = $new_cond;
|
123 |
-
|
124 |
-
$
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
} ?>
|
128 |
|
27 |
unset( $new_rule[$key] );
|
28 |
}
|
29 |
}
|
30 |
+
|
31 |
+
$insert = $wpdb->insert(
|
32 |
+
WPSC_TABLE_COUPON_CODES,
|
33 |
+
array(
|
34 |
+
'coupon_code' => $coupon_code,
|
35 |
+
'value' => $discount,
|
36 |
+
'is-percentage' => $discount_type,
|
37 |
+
'use-once' => $use_once,
|
38 |
+
'is-used' => 0,
|
39 |
+
'active' => $is_active,
|
40 |
+
'every_product' => $every_product,
|
41 |
+
'start' => $start_date,
|
42 |
+
'expiry' => $end_date,
|
43 |
+
'condition' => serialize( $new_rule )
|
44 |
+
),
|
45 |
+
array(
|
46 |
+
'%s',
|
47 |
+
'%f',
|
48 |
+
'%d',
|
49 |
+
'%s',
|
50 |
+
'%s',
|
51 |
+
'%s',
|
52 |
+
'%s',
|
53 |
+
'%s',
|
54 |
+
'%s',
|
55 |
+
'%s'
|
56 |
+
)
|
57 |
+
);
|
58 |
+
if ( $insert )
|
59 |
+
echo "<div class='updated'><p align='center'>" . __( 'Thanks, the coupon has been added.', 'wpsc' ) . "</p></div>";
|
60 |
|
61 |
}
|
62 |
|
67 |
$coupon_id = (int)$coupon_id;
|
68 |
$coupon_data['start'] = $coupon_data['start'] . " 00:00:00";
|
69 |
$coupon_data['expiry'] = $coupon_data['expiry'] . " 00:00:00";
|
70 |
+
$check_values = $wpdb->get_row( $wpdb->prepare( "SELECT `id`, `coupon_code`, `value`, `is-percentage`, `use-once`, `active`, `start`, `expiry`,`every_product` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` = %d", $coupon_id ), ARRAY_A );
|
71 |
|
72 |
// Sort both arrays to make sure that if they contain the same stuff,
|
73 |
// that they will compare to be the same, may not need to do this, but what the heck
|
93 |
$insert_array[] = "`every_product` = '$coupon_data[add_every_product]'";
|
94 |
|
95 |
if ( count( $insert_array ) > 0 )
|
96 |
+
$wpdb->query( $wpdb->prepare( "UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET " . implode( ", ", $insert_array ) . " WHERE `id` = %d LIMIT 1;", $coupon_id ) );
|
97 |
|
98 |
unset( $insert_array );
|
99 |
$rules = $_POST['rules'];
|
110 |
}
|
111 |
}
|
112 |
|
113 |
+
$conditions = $wpdb->get_var( $wpdb->prepare( "SELECT `condition` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` = %d LIMIT 1", $_POST['coupon_id'] ) );
|
114 |
$conditions = unserialize( $conditions );
|
115 |
$new_cond = array();
|
116 |
|
120 |
$new_cond['value'] = $_POST['rules']['value'][0];
|
121 |
$conditions [] = $new_cond;
|
122 |
}
|
123 |
+
|
124 |
+
$wpdb->update(
|
125 |
+
WPSC_TABLE_COUPON_CODES,
|
126 |
+
array(
|
127 |
+
'condition' => serialize( $conditions ),
|
128 |
+
|
129 |
+
),
|
130 |
+
array(
|
131 |
+
'id' => $_POST['coupon_id']
|
132 |
+
),
|
133 |
+
'%s',
|
134 |
+
'%d'
|
135 |
+
);
|
136 |
}
|
137 |
}
|
138 |
}
|
139 |
|
140 |
if ( isset( $_POST['delete_condition'] ) ) {
|
141 |
|
142 |
+
$conditions = $wpdb->get_var( $wpdb->prepare( "SELECT `condition` FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE `id` = %d LIMIT 1", $_POST['coupon_id'] ) );
|
143 |
$conditions = unserialize( $conditions );
|
144 |
|
145 |
unset( $conditions[(int)$_POST['delete_condition']] );
|
146 |
|
147 |
+
$wpdb->update(
|
148 |
+
WPSC_TABLE_COUPON_CODES,
|
149 |
+
array(
|
150 |
+
'condition' => serialize( $conditions ),
|
151 |
+
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'id' => $_POST['coupon_id']
|
155 |
+
),
|
156 |
+
'%s',
|
157 |
+
'%d'
|
158 |
+
);
|
159 |
}
|
160 |
|
161 |
if ( isset( $_POST['submit_condition'] ) ) {
|
167 |
$new_cond['logic'] = $_POST['rules']['logic'][0];
|
168 |
$new_cond['value'] = $_POST['rules']['value'][0];
|
169 |
$conditions[] = $new_cond;
|
170 |
+
|
171 |
+
$wpdb->update(
|
172 |
+
WPSC_TABLE_COUPON_CODES,
|
173 |
+
array(
|
174 |
+
'condition' => serialize( $conditions )
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'id' => $_POST['coupon_id']
|
178 |
+
),
|
179 |
+
'%s',
|
180 |
+
'%d'
|
181 |
+
);
|
182 |
+
|
183 |
}
|
184 |
} ?>
|
185 |
|
wpsc-admin/display-debug.page.php
CHANGED
@@ -13,7 +13,7 @@ function wpsc_debug_page() {
|
|
13 |
if ( !current_user_can('manage_options') )
|
14 |
wp_die("You don't look like an administrator.");
|
15 |
global $wpdb;
|
16 |
-
$fixpage =
|
17 |
?>
|
18 |
<div class="wrap">
|
19 |
<h2>Debugging Page</h2>
|
13 |
if ( !current_user_can('manage_options') )
|
14 |
wp_die("You don't look like an administrator.");
|
15 |
global $wpdb;
|
16 |
+
$fixpage = admin_url( 'admin.php?page=wpsc-sales-logs&subpage=upgrade-purchase-logs' );
|
17 |
?>
|
18 |
<div class="wrap">
|
19 |
<h2>Debugging Page</h2>
|
wpsc-admin/display-items.page.php
CHANGED
@@ -64,23 +64,9 @@ function wpsc_additional_column_name_variations( $columns ){
|
|
64 |
|
65 |
//For BC for 3.0 (hoping to remove for WPEC 3.9)
|
66 |
register_column_headers( 'wpsc-product_variants', $columns );
|
67 |
-
|
68 |
-
add_filter( 'get_user_option_managewpsc-product_variantscolumnshidden', 'wpsc_variation_form_hidden_columns' );
|
69 |
-
|
70 |
return apply_filters( 'wpsc_variation_column_headers', $columns);
|
71 |
}
|
72 |
|
73 |
-
function wpsc_variation_form_hidden_columns( $return ) {
|
74 |
-
global $post;
|
75 |
-
|
76 |
-
if ( isset( $post ) && $post->post_parent == 0 && ! is_numeric( get_post_meta( $post->ID, '_wpsc_stock', true ) ) )
|
77 |
-
$return = array(
|
78 |
-
'stock',
|
79 |
-
);
|
80 |
-
|
81 |
-
return $return;
|
82 |
-
}
|
83 |
-
|
84 |
/**
|
85 |
* wpsc_additional_column_data.
|
86 |
*
|
@@ -196,7 +182,7 @@ function wpsc_additional_column_data( $column ) {
|
|
196 |
$price = get_post_meta( $post->ID, '_wpsc_special_price', true );
|
197 |
if( !$is_parent ) {
|
198 |
echo wpsc_currency_display( $price );
|
199 |
-
echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price
|
200 |
} else
|
201 |
echo wpsc_product_variation_price_available( $post->ID ).'+';
|
202 |
break;
|
64 |
|
65 |
//For BC for 3.0 (hoping to remove for WPEC 3.9)
|
66 |
register_column_headers( 'wpsc-product_variants', $columns );
|
|
|
|
|
|
|
67 |
return apply_filters( 'wpsc_variation_column_headers', $columns);
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
/**
|
71 |
* wpsc_additional_column_data.
|
72 |
*
|
182 |
$price = get_post_meta( $post->ID, '_wpsc_special_price', true );
|
183 |
if( !$is_parent ) {
|
184 |
echo wpsc_currency_display( $price );
|
185 |
+
echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price . '</div>';
|
186 |
} else
|
187 |
echo wpsc_product_variation_price_available( $post->ID ).'+';
|
188 |
break;
|
wpsc-admin/display-options-settings.page.php
CHANGED
@@ -3,100 +3,8 @@
|
|
3 |
* Display Settings page
|
4 |
*/
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
if( $_GET['tab'] == 'shipping' )
|
9 |
-
if( isset( $_GET['shipping_module'] ) )
|
10 |
-
$_SESSION['previous_shipping_name'] = $_GET['shipping_module'];
|
11 |
-
|
12 |
-
function wpsc_display_settings_page() { ?>
|
13 |
-
|
14 |
-
<div id="wpsc_options" class="wrap">
|
15 |
-
<div id="icon_card" class="icon32"></div>
|
16 |
-
<?php
|
17 |
-
|
18 |
-
wpsc_the_settings_tabs();
|
19 |
-
|
20 |
-
if ( isset( $_GET['tab'] ) )
|
21 |
-
$page = $_GET['tab'];
|
22 |
-
else
|
23 |
-
$page = 'general';
|
24 |
-
|
25 |
-
if ( !isset( $_GET['isocode'] ) )
|
26 |
-
$_GET['isocode'] = '';
|
27 |
-
|
28 |
-
if ( preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ) {
|
29 |
-
include(WPSC_FILE_PATH . '/wpsc-admin/includes/tax_and_shipping.php');
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
|
33 |
-
if ( isset( $_GET['googlecheckoutshipping'] ) ) {
|
34 |
-
include(WPSC_FILE_PATH . '/wpsc-merchants/library/google_shipping_country.php');
|
35 |
-
return;
|
36 |
-
exit();
|
37 |
-
}
|
38 |
-
|
39 |
-
if ( isset( $_GET['selected_all'] ) )
|
40 |
-
wpsc_submit_options( $_GET['selected_all'] );
|
41 |
-
|
42 |
-
?>
|
43 |
-
|
44 |
-
<div id='wpsc_options_page'>
|
45 |
-
|
46 |
-
<?php
|
47 |
-
switch ( $page ) {
|
48 |
-
case 'checkout' :
|
49 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/checkout.php' );
|
50 |
-
wpsc_options_checkout();
|
51 |
-
break;
|
52 |
-
|
53 |
-
case 'gateway' :
|
54 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/gateway.php' );
|
55 |
-
wpsc_options_gateway();
|
56 |
-
break;
|
57 |
-
|
58 |
-
case 'shipping' :
|
59 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/shipping.php' );
|
60 |
-
wpsc_options_shipping();
|
61 |
-
break;
|
62 |
-
|
63 |
-
case 'admin' :
|
64 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/admin.php' );
|
65 |
-
wpsc_options_admin();
|
66 |
-
break;
|
67 |
-
|
68 |
-
case 'presentation' :
|
69 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/presentation.php' );
|
70 |
-
wpsc_options_presentation();
|
71 |
-
break;
|
72 |
-
|
73 |
-
case 'taxes' :
|
74 |
-
wpec_taxes_settings_page();
|
75 |
-
break;
|
76 |
-
|
77 |
-
case 'marketing' :
|
78 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/marketing.php' );
|
79 |
-
wpsc_options_marketing();
|
80 |
-
break;
|
81 |
-
|
82 |
-
case 'import' :
|
83 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/import.php' );
|
84 |
-
wpsc_options_import();
|
85 |
-
break;
|
86 |
-
|
87 |
-
case 'general' :
|
88 |
-
default :
|
89 |
-
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/settings-pages/general.php' );
|
90 |
-
wpsc_options_general();
|
91 |
-
break;
|
92 |
-
}
|
93 |
-
|
94 |
-
$_SESSION['wpsc_settings_curr_page'] = $page; ?>
|
95 |
-
|
96 |
-
</div>
|
97 |
-
</div>
|
98 |
-
|
99 |
-
<?php
|
100 |
}
|
101 |
|
102 |
/*
|
@@ -104,19 +12,7 @@ function wpsc_display_settings_page() { ?>
|
|
104 |
*/
|
105 |
|
106 |
function wpsc_settings_tabs() {
|
107 |
-
|
108 |
-
'general' => _x( 'General', 'General settings tab in Settings->Store page', 'wpsc' ),
|
109 |
-
'presentation' => _x( 'Presentation', 'Presentation settings tab in Settings->Store page', 'wpsc' ),
|
110 |
-
'admin' => _x( 'Admin', 'Admin settings tab in Settings->Store page', 'wpsc' ),
|
111 |
-
'taxes' => _x( 'Taxes', 'Taxes settings tab in Settings->Store page', 'wpsc' ),
|
112 |
-
'shipping' => _x( 'Shipping', 'Shipping settings tab in Settings->Store page', 'wpsc' ),
|
113 |
-
'gateway' => _x( 'Payments', 'Payments settings tab in Settings->Store page', 'wpsc' ),
|
114 |
-
'checkout' => _x( 'Checkout', 'Checkout settings tab in Settings->Store page', 'wpsc' ),
|
115 |
-
'marketing' => _x( 'Marketing', 'Marketing settings tab in Settings->Store page', 'wpsc' ),
|
116 |
-
'import' => _x( 'Import', 'Import settings tab in Settings->Store page', 'wpsc' )
|
117 |
-
);
|
118 |
-
|
119 |
-
return apply_filters( 'wpsc_settings_tabs', $_default_tabs );
|
120 |
}
|
121 |
|
122 |
/*
|
@@ -124,37 +20,7 @@ function wpsc_settings_tabs() {
|
|
124 |
*/
|
125 |
|
126 |
function wpsc_the_settings_tabs() {
|
127 |
-
|
128 |
-
|
129 |
-
$tabs = wpsc_settings_tabs();
|
130 |
-
|
131 |
-
if ( !empty( $tabs ) ) {
|
132 |
-
echo '<h2 class="nav-tab-wrapper">';
|
133 |
-
|
134 |
-
if ( isset( $redir_tab ) && array_key_exists( $redir_tab, $tabs ) ) {
|
135 |
-
$current = $redir_tab;
|
136 |
-
} elseif ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ) {
|
137 |
-
$current = $_GET['tab'];
|
138 |
-
} else {
|
139 |
-
$keys = array_keys( $tabs );
|
140 |
-
$current = array_shift( $keys );
|
141 |
-
}
|
142 |
-
|
143 |
-
foreach ( $tabs as $callback => $text ) {
|
144 |
-
$class = ' class="nav-tab"';
|
145 |
-
|
146 |
-
if ( $current == $callback )
|
147 |
-
$class = ' class="nav-tab nav-tab-active"';
|
148 |
-
|
149 |
-
$href = add_query_arg( array( 'tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false ) );
|
150 |
-
$href = remove_query_arg( 'isocode', $href );
|
151 |
-
$href = wp_nonce_url( $href, "tab-$callback" );
|
152 |
-
$link = "<a href='" . esc_url( $href ) . "'$class>$text</a>";
|
153 |
-
|
154 |
-
echo $link;
|
155 |
-
}
|
156 |
-
echo '</h2>';
|
157 |
-
}
|
158 |
}
|
159 |
|
160 |
function country_list( $selected_country = null ) {
|
@@ -176,89 +42,6 @@ function country_list( $selected_country = null ) {
|
|
176 |
return $output;
|
177 |
}
|
178 |
|
179 |
-
/*
|
180 |
-
* Get Shipping Form for wp-admin
|
181 |
-
*/
|
182 |
-
function wpsc_get_shipping_form( $shippingname ) {
|
183 |
-
global $wpsc_shipping_modules;
|
184 |
-
|
185 |
-
if ( array_key_exists( $shippingname, $wpsc_shipping_modules ) ) {
|
186 |
-
$shipping_forms = $wpsc_shipping_modules[$shippingname]->getForm();
|
187 |
-
$shipping_module_name = $wpsc_shipping_modules[$shippingname]->name;
|
188 |
-
$output = array( 'name' => $shipping_module_name, 'form_fields' => $shipping_forms, 'has_submit_button' => 1 );
|
189 |
-
} else {
|
190 |
-
$output = array( 'name' => ' ', 'form_fields' => __( 'To configure a shipping module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
|
191 |
-
}
|
192 |
-
|
193 |
-
return $output;
|
194 |
-
}
|
195 |
-
|
196 |
-
/***
|
197 |
-
* Get Payment Form for wp-admin
|
198 |
-
*/
|
199 |
-
function wpsc_get_payment_form( $paymentname ,$selected_gateway_data='') {
|
200 |
-
global $nzshpcrt_gateways;
|
201 |
-
|
202 |
-
$payment_gateway_names = get_option('payment_gateway_names');
|
203 |
-
$form = array();
|
204 |
-
$output = array( 'name' => ' ', 'form_fields' => __( 'To configure a payment module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
|
205 |
-
|
206 |
-
foreach ( $nzshpcrt_gateways as $gateway ) {
|
207 |
-
if ( $gateway["internalname"] != $paymentname ) {
|
208 |
-
continue;
|
209 |
-
} else {
|
210 |
-
$selected_gateway_data = $gateway;
|
211 |
-
$form = $gateway;
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
if ( $form ) {
|
216 |
-
$output ='';
|
217 |
-
$output .="<tr>
|
218 |
-
<td style='border-top: none;'>
|
219 |
-
".__("Display Name", 'wpsc')."
|
220 |
-
</td>
|
221 |
-
<td style='border-top: none;'>";
|
222 |
-
|
223 |
-
if (isset($payment_gateway_names[$paymentname]) ) {
|
224 |
-
$display_name = $payment_gateway_names[$paymentname];
|
225 |
-
} elseif(!empty($selected_gateway_data['display_name'])){
|
226 |
-
$display_name =$selected_gateway_data['display_name'];
|
227 |
-
}else{
|
228 |
-
switch($selected_gateway_data['payment_type']) {
|
229 |
-
case "paypal";
|
230 |
-
$display_name = "PayPal";
|
231 |
-
break;
|
232 |
-
|
233 |
-
case "manual_payment":
|
234 |
-
$display_name = "Manual Payment";
|
235 |
-
break;
|
236 |
-
|
237 |
-
case "google_checkout":
|
238 |
-
$display_name = "Google Checkout";
|
239 |
-
break;
|
240 |
-
|
241 |
-
case "credit_card":
|
242 |
-
default:
|
243 |
-
$display_name = "Credit Card";
|
244 |
-
break;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
$output .="<input type='text' name='user_defined_name[".$paymentname."]' value='". $display_name ."' /><br />
|
249 |
-
<span class='small description'>".__('The text that people see when making a purchase', 'wpsc')."</span>
|
250 |
-
</td>
|
251 |
-
</tr>";
|
252 |
-
$payment_forms = $form["form"]();
|
253 |
-
$payment_module_name = $form["name"];
|
254 |
-
|
255 |
-
$output = array( 'name' => $payment_module_name, 'form_fields' => $output.$payment_forms, 'has_submit_button' => 1 );
|
256 |
-
} else {
|
257 |
-
$output = array( 'name' => ' ', 'form_fields' => __( 'To configure a payment module select one on the left.', 'wpsc' ), 'has_submit_button' => 0 );
|
258 |
-
}
|
259 |
-
|
260 |
-
return $output;
|
261 |
-
}
|
262 |
|
263 |
function wpsc_settings_page_update_notification() {
|
264 |
|
@@ -268,22 +51,22 @@ function wpsc_settings_page_update_notification() {
|
|
268 |
<?php
|
269 |
|
270 |
if ( isset( $_GET['updated'] ) && (int)$_GET['updated'] ) {
|
271 |
-
printf( _n( '%s Setting options updated.', ' %s Settings options updated.', $_GET['updated'] ), absint( $_GET['updated'] ) );
|
272 |
unset( $_GET['updated'] );
|
273 |
$message = true;
|
274 |
}
|
275 |
if ( isset( $_GET['deleted'] ) && (int)$_GET['deleted'] ) {
|
276 |
-
printf( _n( '%s Setting option deleted.', '%s Setting option deleted.', $_GET['deleted'] ), absint( $_GET['deleted'] ) );
|
277 |
unset( $_GET['deleted'] );
|
278 |
$message = true;
|
279 |
}
|
280 |
if ( isset( $_GET['shipadd'] ) && (int)$_GET['shipadd'] ) {
|
281 |
-
printf( _n( '%s Shipping option updated.', '%s Shipping option updated.', $_GET['shipadd'] ), absint( $_GET['shipadd'] ) );
|
282 |
unset( $_GET['shipadd'] );
|
283 |
$message = true;
|
284 |
}
|
285 |
if ( isset( $_GET['added'] ) && (int)$_GET['added'] ) {
|
286 |
-
printf( _n( '%s Checkout field added.', '%s Checkout fields added.', $_GET['added'] ), absint( $_GET['added'] ) );
|
287 |
unset( $_GET['added'] );
|
288 |
$message = true;
|
289 |
}
|
3 |
* Display Settings page
|
4 |
*/
|
5 |
|
6 |
+
function wpsc_display_settings_page() {
|
7 |
+
WPSC_Settings_Page::get_instance()->display();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
}
|
9 |
|
10 |
/*
|
12 |
*/
|
13 |
|
14 |
function wpsc_settings_tabs() {
|
15 |
+
return WPSC_Settings_Page::get_instance()->get_tabs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
/*
|
20 |
*/
|
21 |
|
22 |
function wpsc_the_settings_tabs() {
|
23 |
+
WPSC_Settings_Page::get_instance()->output_tabs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
function country_list( $selected_country = null ) {
|
42 |
return $output;
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
function wpsc_settings_page_update_notification() {
|
47 |
|
51 |
<?php
|
52 |
|
53 |
if ( isset( $_GET['updated'] ) && (int)$_GET['updated'] ) {
|
54 |
+
printf( _n( '%s Setting options updated.', ' %s Settings options updated.', $_GET['updated'], 'wpsc' ), absint( $_GET['updated'] ) );
|
55 |
unset( $_GET['updated'] );
|
56 |
$message = true;
|
57 |
}
|
58 |
if ( isset( $_GET['deleted'] ) && (int)$_GET['deleted'] ) {
|
59 |
+
printf( _n( '%s Setting option deleted.', '%s Setting option deleted.', $_GET['deleted'], 'wpsc' ), absint( $_GET['deleted'] ) );
|
60 |
unset( $_GET['deleted'] );
|
61 |
$message = true;
|
62 |
}
|
63 |
if ( isset( $_GET['shipadd'] ) && (int)$_GET['shipadd'] ) {
|
64 |
+
printf( _n( '%s Shipping option updated.', '%s Shipping option updated.', $_GET['shipadd'], 'wpsc' ), absint( $_GET['shipadd'] ) );
|
65 |
unset( $_GET['shipadd'] );
|
66 |
$message = true;
|
67 |
}
|
68 |
if ( isset( $_GET['added'] ) && (int)$_GET['added'] ) {
|
69 |
+
printf( _n( '%s Checkout field added.', '%s Checkout fields added.', $_GET['added'], 'wpsc' ), absint( $_GET['added'] ) );
|
70 |
unset( $_GET['added'] );
|
71 |
$message = true;
|
72 |
}
|
wpsc-admin/display-sales-logs.php
CHANGED
@@ -5,599 +5,381 @@
|
|
5 |
* These are the main WPSC sales page functions
|
6 |
*
|
7 |
* @package wp-e-commerce
|
8 |
-
* @since 3.
|
9 |
*/
|
10 |
-
global $purchlogs;
|
11 |
-
if(!isset($purchlogs)){
|
12 |
-
$purchlogs = new wpsc_purchaselogs();
|
13 |
-
}
|
14 |
-
|
15 |
-
function wpsc_display_sales_logs() {
|
16 |
-
$subpage = empty( $_GET['subpage'] ) ? '' : $_GET['subpage'];
|
17 |
|
18 |
-
switch( $subpage ) {
|
19 |
-
case 'upgrade-purchase-logs':
|
20 |
-
wpsc_upgrade_purchase_logs();
|
21 |
-
break;
|
22 |
|
23 |
-
case 'update-purchase-logs-3.8':
|
24 |
-
wpsc_update_purchase_logs_3dot8();
|
25 |
-
break;
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
}
|
32 |
|
33 |
-
function
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
</div>
|
42 |
-
<?php
|
43 |
-
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
return true;
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
|
|
|
|
60 |
|
61 |
-
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
<
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<?php
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
unset($_GET['locked']);
|
103 |
-
}
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
unset($_GET['deleted']);
|
108 |
-
}
|
109 |
-
?>
|
110 |
-
</p></div>
|
111 |
-
<?php }
|
112 |
-
|
113 |
-
if(get_option('wpsc_purchaselogs_fixed')== false || (wpsc_check_uniquenames()) ){ ?>
|
114 |
-
<div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __('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 <a href="%s">Click Here</a>', 'wpsc'), $fixpage); ?></span></div>
|
115 |
-
<?php }
|
116 |
-
|
117 |
-
if ( _wpsc_purchlogs_need_update() ) {
|
118 |
-
?>
|
119 |
-
<div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __('It has been detected that some of your purchase logs were not updated properly when you upgrade to WP e-Commerce %s. Please <a href="%s">click here</a> to fix this problem.', 'wpsc'), WPSC_VERSION, add_query_arg( 'subpage', 'update-purchase-logs-3.8' ) ); ?></span></div>
|
120 |
-
<?php
|
121 |
-
}
|
122 |
-
|
123 |
-
///// end of update message section //////?>
|
124 |
-
<div id='dashboard-widgets' style='min-width: 825px;'>
|
125 |
-
<?php /* end of sidebar start of main column */ ?>
|
126 |
-
<div id='post-body' class='has-sidebar metabox-holder' style='width:95%;'>
|
127 |
-
<div id='dashboard-widgets-main-content-wpsc' class='has-sidebar-content'>
|
128 |
-
|
129 |
-
<?php
|
130 |
-
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
131 |
-
do_meta_boxes('dashboard_page_wpsc-sales-logs', 'top', true);
|
132 |
-
?>
|
133 |
-
</div><br />
|
134 |
-
<div id='wpsc_purchlog_searchbox'>
|
135 |
-
<?php wpsc_purchaselogs_searchbox(); ?>
|
136 |
-
</div><br />
|
137 |
-
<?php wpsc_purchaselogs_displaylist(); ?>
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
</div>
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
if(isset($_REQUEST['purchaselog_id'])){
|
147 |
-
$purchlogitem = new wpsc_purchaselogs_items((int)$_REQUEST['purchaselog_id']);
|
148 |
-
}
|
149 |
-
if (isset($_GET['cleared']) || isset($_GET['cleared'])) { ?>
|
150 |
-
<div id="message" class="updated fade"><p>
|
151 |
-
<?php
|
152 |
-
if ( isset($_GET['cleared']) && $_GET['cleared']==true ) {
|
153 |
-
_e('Downloads for this log have been released.', 'wpsc' );
|
154 |
-
unset($_GET['cleared']);
|
155 |
-
}
|
156 |
-
if ( isset($_GET['sent']) && (int) $_GET['sent'] ) {
|
157 |
-
_e( 'Receipt has been resent ', 'wpsc' );
|
158 |
-
unset($_GET['sent']);
|
159 |
-
}
|
160 |
-
?> </p></div>
|
161 |
-
<?php
|
162 |
-
}
|
163 |
-
?>
|
164 |
|
|
|
|
|
165 |
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
$columns = array(
|
170 |
-
|
171 |
-
'sku'
|
172 |
-
'quantity' => __('Quantity','wpsc'),
|
173 |
-
'price'
|
174 |
-
'shipping' => __('Shipping','wpsc'),
|
175 |
-
'tax' => '',
|
176 |
-
'total' => __('Total','wpsc')
|
177 |
);
|
178 |
|
179 |
-
if(wpec_display_product_tax())
|
180 |
-
|
181 |
-
|
182 |
-
}// if
|
183 |
|
184 |
-
|
185 |
-
?>
|
186 |
-
<div id='post-body' class='has-sidebar' style='width:95%;'>
|
187 |
-
<?php if(wpsc_has_purchlog_shipping()) { ?>
|
188 |
-
<div id='wpsc_shipping_details_box'>
|
189 |
-
<h3><?php _e('Shipping Address','wpsc'); ?></h3>
|
190 |
-
<p><strong><?php echo wpsc_display_purchlog_shipping_name(); ?></strong></p>
|
191 |
-
<p>
|
192 |
-
<?php echo wpsc_display_purchlog_shipping_address(); ?><br />
|
193 |
-
<?php echo wpsc_display_purchlog_shipping_city(); ?><br />
|
194 |
-
<?php echo wpsc_display_purchlog_shipping_state_and_postcode(); ?><br />
|
195 |
-
<?php echo wpsc_display_purchlog_shipping_country(); ?><br />
|
196 |
-
</p>
|
197 |
-
<strong><?php _e('Shipping Options','wpsc'); ?></strong>
|
198 |
-
<p>
|
199 |
-
|
200 |
-
<?php _e('Shipping Method:','wpsc'); ?> <?php echo wpsc_display_purchlog_shipping_method(); ?><br />
|
201 |
-
<?php _e('Shipping Option:','wpsc'); ?> <?php echo wpsc_display_purchlog_shipping_option(); ?><br />
|
202 |
-
<?php if(wpsc_purchlogs_has_tracking()) : ?>
|
203 |
-
<?php _e('Tracking ID:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackid(); ?><br />
|
204 |
-
<?php _e('Shipping Status:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackstatus(); ?><br />
|
205 |
-
<?php _e('Track History:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackhistory(); ?>
|
206 |
-
<?php endif; ?>
|
207 |
-
</p>
|
208 |
-
</div>
|
209 |
-
<?php } ?>
|
210 |
-
<div id='wpsc_billing_details_box'>
|
211 |
-
<?php do_action( 'wpsc_billing_details_top'); ?>
|
212 |
-
<h3><?php _e('Billing Details','wpsc'); ?></h3>
|
213 |
-
<p><strong><?php _e('Purchase Log Date:','wpsc'); ?> </strong><?php echo wpsc_purchaselog_details_date(); ?> </p>
|
214 |
-
<p><strong><?php _e('Purchase Number:','wpsc'); ?> </strong><?php echo wpsc_purchaselog_details_purchnumber(); ?> </p>
|
215 |
-
<p><strong><?php _e('Buyers Name:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_buyers_name(); ?></p>
|
216 |
-
<p><strong><?php _e('Address:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_buyers_address(); ?></p>
|
217 |
-
|
218 |
-
<p><strong><?php _e('Phone:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_buyers_phone(); ?></p>
|
219 |
-
<p><strong><?php _e('Email:','wpsc'); ?> </strong><a href="mailto:<?php echo wpsc_display_purchlog_buyers_email(); ?>?subject=Message From '<?php echo get_option('siteurl'); ?>'"><?php echo wpsc_display_purchlog_buyers_email(); ?></a></p>
|
220 |
-
<p><strong><?php _e('Payment Method:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_paymentmethod(); ?></p>
|
221 |
-
<?php if(wpsc_display_purchlog_display_howtheyfoundus()) : ?>
|
222 |
-
<p><strong><?php _e('How User Found Us:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_howtheyfoundus(); ?></p>
|
223 |
-
<?php endif; ?>
|
224 |
-
<?php do_action( 'wpsc_billing_details_bottom'); ?>
|
225 |
-
</div>
|
226 |
|
227 |
-
|
228 |
-
<br />
|
229 |
-
<h3><?php _e('Items Ordered','wpsc'); ?></h3>
|
230 |
-
<table class="widefat" cellspacing="0">
|
231 |
-
<thead>
|
232 |
-
<tr>
|
233 |
-
<?php print_column_headers('display-purchaselog-details'); ?>
|
234 |
-
</tr>
|
235 |
-
</thead>
|
236 |
-
|
237 |
-
<tbody>
|
238 |
-
<?php wpsc_display_purchlog_details(); ?>
|
239 |
-
|
240 |
-
<tr class="wpsc_purchaselog_start_totals">
|
241 |
-
<td colspan="5">
|
242 |
-
<?php if ( wpsc_purchlog_has_discount_data() ) { ?>
|
243 |
-
<?php _e('Coupon Code','wpsc'); ?>: <?php echo wpsc_display_purchlog_discount_data(); ?>
|
244 |
-
<?php } ?>
|
245 |
-
</td>
|
246 |
-
<th><?php _e('Discount','wpsc'); ?> </th>
|
247 |
-
<td><?php echo wpsc_display_purchlog_discount(); ?></td>
|
248 |
-
</tr>
|
249 |
-
|
250 |
-
<?php if(!wpec_display_product_tax()) { ?>
|
251 |
-
<tr>
|
252 |
-
<td colspan='5'></td>
|
253 |
-
<th><?php _e('Taxes','wpsc'); ?> </th>
|
254 |
-
<td><?php echo wpsc_display_purchlog_taxes(); ?></td>
|
255 |
-
</tr>
|
256 |
-
<?php } ?>
|
257 |
-
|
258 |
-
<tr>
|
259 |
-
<td colspan='5'></td>
|
260 |
-
<th><?php _e('Shipping','wpsc'); ?> </th>
|
261 |
-
<td><?php echo wpsc_display_purchlog_shipping(); ?></td>
|
262 |
-
</tr>
|
263 |
-
<tr>
|
264 |
-
<td colspan='5'></td>
|
265 |
-
<th><?php _e('Total','wpsc'); ?> </th>
|
266 |
-
<td><?php echo wpsc_display_purchlog_totalprice(); ?></td>
|
267 |
-
</tr>
|
268 |
-
</tbody>
|
269 |
-
</table>
|
270 |
-
<div id='wpsc_purchlog_order_status'>
|
271 |
-
<form action='' method='post'>
|
272 |
-
<p><label for='purchaselog-<?php echo absint( $_GET['purchaselog_id'] ); ?>'><?php _e('Order Status:','wpsc'); ?></label><select id='purchaselog-<?php echo absint( $_GET['purchaselog_id'] ); ?>' class='selector' name='<?php echo absint( $_GET['purchaselog_id'] ); ?>' title='<?php echo absint( $_GET['purchaselog_id'] ); ?>' >
|
273 |
-
<?php while(wpsc_have_purch_items_statuses()) : wpsc_the_purch_status(); ?>
|
274 |
-
<option value='<?php echo wpsc_the_purch_status_id(); ?>' <?php echo wpsc_purchlog_is_checked_status(); ?> ><?php echo wpsc_the_purch_status_name(); ?> </option>
|
275 |
-
<?php endwhile; ?>
|
276 |
-
</select></p>
|
277 |
-
</form>
|
278 |
-
</div>
|
279 |
-
<br style="clear: both;" />
|
280 |
-
<?php wpsc_purchlogs_custom_fields(); ?>
|
281 |
|
|
|
|
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
|
287 |
-
|
288 |
|
289 |
-
|
290 |
-
</div>
|
291 |
|
292 |
-
|
293 |
-
<h3><?php _e('Actions','wpsc'); ?></h3>
|
294 |
-
<?php do_action( 'wpsc_purchlogitem_links_start' ); ?>
|
295 |
-
<?php if(wpsc_purchlogs_have_downloads_locked() != false): ?>
|
296 |
-
<img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/lock_open.png' alt='clear lock icon' /> <a href='<?php echo $_SERVER['REQUEST_URI'].'&wpsc_admin_action=clear_locks'; ?>'><?php echo wpsc_purchlogs_have_downloads_locked(); ?></a><br /><br class='small' />
|
297 |
-
<?php endif; ?>
|
298 |
-
<img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/printer.png' alt='printer icon' /> <a href='<?php echo add_query_arg('wpsc_admin_action','wpsc_display_invoice'); ?>'><?php _e('View Packing Slip', 'wpsc'); ?></a>
|
299 |
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
-
|
|
|
|
|
303 |
|
304 |
-
|
305 |
-
<br /><br />
|
306 |
-
</div>
|
307 |
-
<br />
|
308 |
-
<?php } ?>
|
309 |
-
</div>
|
310 |
-
<?php
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
function wpsc_purchaselogs_displaylist(){
|
315 |
-
global $purchlogs;
|
316 |
-
?>
|
317 |
-
<form method='post' action=''>
|
318 |
-
<div class='wpsc_purchaselogs_options'>
|
319 |
-
<select id='purchlog_multiple_status_change' name='purchlog_multiple_status_change' class='purchlog_multiple_status_change'>
|
320 |
-
<option selected='selected' value='-1'><?php _e('Bulk Actions', 'wpsc'); ?></option>
|
321 |
-
<?php while(wpsc_have_purch_items_statuses()) : wpsc_the_purch_status(); ?>
|
322 |
-
<option value='<?php echo wpsc_the_purch_status_id(); ?>' >
|
323 |
-
<?php echo wpsc_the_purch_status_name(); ?>
|
324 |
-
</option>
|
325 |
-
<?php endwhile; ?>
|
326 |
-
<option value="delete"><?php _e('Delete', 'wpsc'); ?></option>
|
327 |
-
</select>
|
328 |
-
<input type='hidden' value='purchlog_bulk_modify' name='wpsc_admin_action2' />
|
329 |
-
<input type="submit" value="<?php _e('Apply', 'wpsc'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
330 |
-
<?php /* View functions for purchlogs */?>
|
331 |
-
<label for='view_purchlogs_by'><?php _e('View:'); ?></label>
|
332 |
|
333 |
-
|
334 |
-
<?php
|
335 |
-
$date_is_selected['3mnths'] = '';
|
336 |
-
$date_is_selected['all'] = '';
|
337 |
-
if( !isset($_GET['view_purchlogs_by']) )
|
338 |
-
$_GET['view_purchlogs_by'] = '';
|
339 |
-
switch($_GET['view_purchlogs_by']) {
|
340 |
-
case 'all':
|
341 |
-
$date_is_selected['all'] = 'selected="selected"';
|
342 |
-
break;
|
343 |
-
|
344 |
-
default:
|
345 |
-
case '3mnths':
|
346 |
-
case '':
|
347 |
-
$date_is_selected['3mnths'] = 'selected="selected"';
|
348 |
-
break;
|
349 |
-
}
|
350 |
-
|
351 |
-
?>
|
352 |
-
<option value='all' <?php echo $date_is_selected['all']; ?>><?php echo _x('All', 'all sales', 'wpsc'); ?></option>
|
353 |
-
<option value='3mnths' <?php echo $date_is_selected['3mnths']; ?>><?php _e('Three Months', 'wpsc'); ?></option>
|
354 |
-
<?php echo wpsc_purchlogs_getfirstdates(); ?>
|
355 |
-
</select>
|
356 |
-
<select id='view_purchlogs_by_status' name='view_purchlogs_by_status'>
|
357 |
-
<option value='-1'><?php _e('Status: All', 'wpsc'); ?></option>
|
358 |
-
|
359 |
-
<?php while(wpsc_have_purch_items_statuses()) : wpsc_the_purch_status(); ?>
|
360 |
-
|
361 |
-
<?php
|
362 |
-
|
363 |
-
$current_status = wpsc_the_purch_status_id();
|
364 |
-
$is_selected = '';
|
365 |
-
if(isset($_GET['view_purchlogs_by_status']) && $_GET['view_purchlogs_by_status'] == $current_status) {
|
366 |
-
$is_selected = 'selected="selected"';
|
367 |
-
}
|
368 |
-
?>
|
369 |
-
<option value='<?php echo $current_status; ?>' <?php echo $is_selected; ?> >
|
370 |
-
<?php echo wpsc_the_purch_status_name(); ?>
|
371 |
-
</option>
|
372 |
-
<?php endwhile; ?>
|
373 |
-
</select>
|
374 |
-
<input type='hidden' value='purchlog_filter_by' name='wpsc_admin_action' />
|
375 |
-
<input type="submit" value="<?php _e('Filter', 'wpsc'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
376 |
-
</div>
|
377 |
-
<?php if( isset( $_POST['purchlogs_searchbox'] ) && wpsc_have_purch_items() == false ): ?>
|
378 |
-
<div class="updated settings-error"><p><?php _e('There are no purchase logs for your selection, please try again.', 'wpsc'); ?></p></div>
|
379 |
-
<?php endif;?>
|
380 |
-
<table class="widefat page fixed" cellspacing="0">
|
381 |
-
<thead>
|
382 |
-
<tr>
|
383 |
-
<?php print_column_headers('display-sales-list'); ?>
|
384 |
-
</tr>
|
385 |
-
</thead>
|
386 |
-
<tfoot>
|
387 |
-
<tr>
|
388 |
-
<?php print_column_headers('display-sales-list', false); ?>
|
389 |
-
</tr>
|
390 |
-
</tfoot>
|
391 |
-
<tbody>
|
392 |
-
<?php get_purchaselogs_content(); ?>
|
393 |
-
</tbody>
|
394 |
-
</table>
|
395 |
-
<p><strong><?php _e('Total:', 'wpsc'); ?></strong> <?php echo wpsc_currency_display( wpsc_the_purch_total() ); ?></p>
|
396 |
-
<?php
|
397 |
-
if(!isset($purchlogs->current_start_timestamp) && !isset($purchlogs->current_end_timestamp)){
|
398 |
-
$purchlogs->current_start_timestamp = $purchlogs->earliest_timestamp;
|
399 |
-
$purchlogs->current_end_timestamp = $purchlogs->current_timestamp;
|
400 |
-
}
|
401 |
-
$arr_params = array('wpsc_admin_action' => 'wpsc_downloadcsv',
|
402 |
-
'rss_key' => 'key',
|
403 |
-
'start_timestamp' => $purchlogs->current_start_timestamp,
|
404 |
-
'end_timestamp' => $purchlogs->current_end_timestamp);
|
405 |
|
406 |
-
|
407 |
-
?>
|
408 |
-
<br />
|
409 |
-
<p><a class='admin_download' href='<?php echo htmlentities(add_query_arg($arr_params), ENT_QUOTES, 'UTF-8') ; ?>' ><img class='wpsc_pushdown_img' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/download.gif' alt='' title='' /> <span> <?php _e('Download CSV', 'wpsc'); ?></span></a>
|
410 |
-
<a target="_blank" class='admin_download' href='<?php echo htmlentities( $piggy_url, ENT_QUOTES, 'UTF-8') ; ?>'><img class='wpsc_pushdown_img' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/mobile.png' alt='' title='' /> <span> <?php _e('Mobile Sales App', 'wpsc'); ?></span></a></p>
|
411 |
-
</form>
|
412 |
-
<br />
|
413 |
-
<script type="text/javascript">
|
414 |
-
/* <![CDATA[ */
|
415 |
-
(function($){
|
416 |
-
$(document).ready(function(){
|
417 |
-
$('#doaction, #doaction2').click(function(){
|
418 |
-
if ( $('select[name^="purchlog_multiple_status_change"]').val() == 'delete' ) {
|
419 |
-
var m = '<?php echo esc_js(__("You are about to delete the selected purchase logs.\n 'Cancel' to stop, 'OK' to delete.", "wpsc")); ?>';
|
420 |
-
return showNotice.warn(m);
|
421 |
-
}
|
422 |
-
});
|
423 |
-
});
|
424 |
-
})(jQuery);
|
425 |
-
//columns.init('edit');
|
426 |
-
/* ]]> */
|
427 |
-
</script>
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
function get_purchaselogs_content(){
|
434 |
-
while(wpsc_have_purch_items()) : wpsc_the_purch_item();
|
435 |
-
?>
|
436 |
-
<tr>
|
437 |
-
<th class="check-column" scope="row"><input type='checkbox' name='purchlogids[]' class='editcheckbox' value='<?php echo wpsc_the_purch_item_id(); ?>' /></th>
|
438 |
-
<td><?php echo wpsc_the_purch_item_id(); ?></td><!-- purchase ID -->
|
439 |
-
<td><?php echo wpsc_the_purch_item_date(); ?></td> <!--Date -->
|
440 |
-
<td><?php echo wpsc_the_purch_item_name(); ?></td> <!--Name/email -->
|
441 |
-
<td><?php echo wpsc_currency_display( wpsc_the_purch_item_price() ); ?></td><!-- Amount -->
|
442 |
-
<td><a href='<?php echo htmlentities(add_query_arg('purchaselog_id', wpsc_the_purch_item_id()), ENT_QUOTES, 'UTF-8') ; ?>'><?php
|
443 |
-
$number_of_items = wpsc_the_purch_item_details();
|
444 |
-
printf( _n( '%s Item', '%s Items', $number_of_items, 'wpsc' ), $number_of_items );
|
445 |
-
?></a></td><!-- Details -->
|
446 |
-
<td>
|
447 |
-
<?php if(!wpsc_purchlogs_is_google_checkout()){ ?>
|
448 |
-
<img src="<?php echo admin_url('images/wpspin_light.gif'); ?>" class="ajax-loading" alt="" style="position:relative; top:3px;" />
|
449 |
-
<select class='selector' name='<?php echo wpsc_the_purch_item_id(); ?>' title='<?php echo wpsc_the_purch_item_id(); ?>' >
|
450 |
-
<?php while(wpsc_have_purch_items_statuses()) : wpsc_the_purch_status(); ?>
|
451 |
-
<option value='<?php echo wpsc_the_purch_status_id(); ?>' <?php echo wpsc_is_checked_status(); ?> ><?php echo wpsc_the_purch_status_name(); ?> </option>
|
452 |
-
<?php endwhile; ?>
|
453 |
-
</select>
|
454 |
-
<?php }else { ?>
|
455 |
-
<a href='http://checkout.google.com/' rel=''><img class='google_checkout_logo' src='<?php echo WPSC_CORE_IMAGES_URL . "/checkout_logo.jpg"; ?>' alt='google checkout' /></a>
|
456 |
-
<?php } ?>
|
457 |
-
</td><!-- Status -->
|
458 |
-
<td><a class='submitdelete' title='<?php echo esc_attr(__('Delete this log', 'wpsc')); ?>' href='<?php echo wp_nonce_url("admin.php?wpsc_admin_action=delete_purchlog&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'), wpsc_the_purch_item_date() )) ?>') ) { return true;}return false;"><img class='wpsc_pushdown_img' src='<?php echo WPSC_CORE_IMAGES_URL . "/cross.png"; ?>' alt='delete icon' /></a></td><!-- Delete -->
|
459 |
-
<td>
|
460 |
-
<a class='wpsc_show_trackingid' title='<?php echo wpsc_the_purch_item_id(); ?>' href=''><?php echo wpsc_display_tracking_id(); ?></a>
|
461 |
-
</td>
|
462 |
-
</tr>
|
463 |
-
<tr class='log<?php echo wpsc_the_purch_item_id(); ?> wpsc_trackingid_row'>
|
464 |
-
<td class='wpsc_trackingid_row' colspan='2'>
|
465 |
-
|
466 |
-
<label for='wpsc_trackingid<?php echo wpsc_the_purch_item_id(); ?>'><?php _e('Tracking ID','wpsc');?> :</label>
|
467 |
-
</td>
|
468 |
-
<td class='wpsc_trackingid_row' colspan='2'>
|
469 |
-
<input type='text' name='wpsc_trackingid<?php echo wpsc_the_purch_item_id(); ?>' value='<?php echo wpsc_trackingid_value(); ?>' size='20' />
|
470 |
-
<input type='submit' name='submit' class='button' value='Add Tracking ID' />
|
471 |
-
</td>
|
472 |
-
<td colspan='4'>
|
473 |
-
<img src="<?php echo admin_url('images/wpspin_light.gif'); ?>" class="ajax-loading" alt="" style="position:relative; top:3px;" />
|
474 |
-
<a href='' title='<?php echo wpsc_the_purch_item_id(); ?>' class='sendTrackingEmail'><?php _e( 'Send Custom Message', 'wpsc' ); ?></a>
|
475 |
-
</td>
|
476 |
-
</tr>
|
477 |
-
|
478 |
-
<?php
|
479 |
-
endwhile;
|
480 |
-
}
|
481 |
-
function wpsc_purchaselogs_searchbox(){
|
482 |
-
?>
|
483 |
-
<form action='' method='post'>
|
484 |
-
<input type='hidden' name='wpsc_admin_action' value='purchlogs_search' />
|
485 |
-
<input type='text' value='<?php if(isset($_POST['purchlogs_searchbox'])) echo $_POST['purchlogs_searchbox']; ?>' name='purchlogs_searchbox' id='purchlogs_searchbox' />
|
486 |
-
<input type="submit" value="<?php _e('Search Logs', 'wpsc'); ?>" class="button-secondary action" />
|
487 |
-
</form>
|
488 |
-
<?php
|
489 |
-
}
|
490 |
-
|
491 |
-
function wpsc_display_purchlog_details(){
|
492 |
-
while( wpsc_have_purchaselog_details() ) : wpsc_the_purchaselog_item(); ?>
|
493 |
-
<tr>
|
494 |
-
<td><?php echo wpsc_purchaselog_details_name(); ?></td> <!-- NAME! -->
|
495 |
-
<td><?php echo wpsc_purchaselog_details_SKU(); ?></td> <!-- SKU! -->
|
496 |
-
<td><?php echo wpsc_purchaselog_details_quantity(); ?></td> <!-- QUANTITY! -->
|
497 |
-
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_price() ); ?></td> <!-- PRICE! -->
|
498 |
-
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_shipping() ); ?></td> <!-- SHIPPING! -->
|
499 |
-
<td><?php if(wpec_display_product_tax()) { echo wpsc_currency_display(wpsc_purchaselog_details_tax()); } ?></td> <!-- TAX! -->
|
500 |
-
<!-- <td><?php echo wpsc_currency_display( wpsc_purchaselog_details_discount() ); ?></td> --> <!-- DISCOUNT! -->
|
501 |
-
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_total() ); ?></td> <!-- TOTAL! -->
|
502 |
-
</tr>
|
503 |
-
<?php
|
504 |
-
endwhile;
|
505 |
-
}
|
506 |
|
507 |
-
function
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
<?php $files = wpsc_purchlogs_customfiles(); ?>
|
515 |
-
<?php if(count($files) > 0){ ?>
|
516 |
-
<h4><?php _e( 'Cart Items with Custom Files' , 'wpsc' ); ?>:</h4>
|
517 |
-
<?php
|
518 |
-
foreach($files as $file){
|
519 |
-
echo "<p>".esc_html($file)."</p>";
|
520 |
-
}
|
521 |
-
}?>
|
522 |
-
<?php if(count($messages) > 0){ ?>
|
523 |
-
<h4><?php _e( 'Cart Items with Custom Messages' , 'wpsc' ); ?>:</h4>
|
524 |
-
<?php
|
525 |
-
foreach($messages as $message){
|
526 |
-
echo "<p>".esc_html($message)."</p>";
|
527 |
-
}
|
528 |
-
} ?>
|
529 |
-
</div>
|
530 |
-
</div>
|
531 |
-
</div>
|
532 |
-
<?php }
|
533 |
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
|
|
|
|
|
|
|
|
536 |
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
if ( true ) { // Need to check if notes column exists in DB and plugin version? ?>
|
541 |
-
<div class="metabox-holder">
|
542 |
-
<div id="purchlogs_notes" class="postbox">
|
543 |
-
<h3 class='hndle'><?php _e( 'Order Notes' , 'wpsc' ); ?></h3>
|
544 |
-
<div class='inside'>
|
545 |
-
<form method="post" action="">
|
546 |
-
<input type='hidden' name='wpsc_admin_action' value='purchlogs_update_notes' />
|
547 |
-
<input type="hidden" name="wpsc_purchlogs_update_notes_nonce" id="wpsc_purchlogs_update_notes_nonce" value="<?php echo wp_create_nonce( 'wpsc_purchlogs_update_notes' ); ?>" />
|
548 |
-
<input type='hidden' name='purchlog_id' value='<?php echo absint( $_GET['purchaselog_id'] ); ?>' />
|
549 |
-
<p><textarea name="purchlog_notes" rows="3" wrap="virtual" id="purchlog_notes" style="width:100%;"><?php if ( isset($_POST['purchlog_notes']) ) { echo stripslashes($_POST['purchlog_notes']); } else { echo wpsc_display_purchlog_notes(); } ?></textarea></p>
|
550 |
-
<p><input class="button" type="submit" name="button" id="button" value="<?php _e( 'Update Notes', 'wpsc' ); ?>" /></p>
|
551 |
-
</form>
|
552 |
-
</div>
|
553 |
-
</div>
|
554 |
-
</div>
|
555 |
-
<?php }
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
<div id="custom_checkout_fields" class="postbox">
|
565 |
-
<h3 class='hndle'><?php _e( 'Additional Checkout Fields' , 'wpsc' ); ?></h3>
|
566 |
-
<div class='inside'>
|
567 |
-
<?php
|
568 |
-
foreach((array)$purchlogitem->customcheckoutfields as $key=>$value){
|
569 |
-
$value['value'] = maybe_unserialize($value['value']);
|
570 |
-
if(is_array($value['value'])){
|
571 |
-
?>
|
572 |
-
<p><strong><?php echo $key; ?> :</strong> <?php echo implode(stripslashse($value['value']), ','); ?></p>
|
573 |
-
<?php
|
574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
|
|
|
|
|
|
|
|
|
|
587 |
}
|
588 |
-
}
|
589 |
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
**/
|
594 |
-
function wpec_display_product_tax()
|
595 |
-
{
|
596 |
-
global $purchlogitem;
|
597 |
-
return ($purchlogitem->extrainfo->wpec_taxes_total == 0.00) ? true : false;
|
598 |
-
}// wpec_display_product_tax
|
599 |
|
600 |
-
function
|
601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
}
|
603 |
-
?>
|
5 |
* These are the main WPSC sales page functions
|
6 |
*
|
7 |
* @package wp-e-commerce
|
8 |
+
* @since 3.8.8
|
9 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
|
|
|
|
|
|
|
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
+
class WPSC_Purchase_Log_Page
|
14 |
+
{
|
15 |
+
private $list_table;
|
16 |
+
private $output;
|
|
|
17 |
|
18 |
+
public function __construct() {
|
19 |
+
$controller = 'default';
|
20 |
+
$controller_method = 'controller_default';
|
21 |
|
22 |
+
if ( isset( $_REQUEST['c'] ) && method_exists( $this, 'controller_' . $_REQUEST['c'] ) ) {
|
23 |
+
$controller = $_REQUEST['c'];
|
24 |
+
$controller_method = 'controller_' . $controller;
|
25 |
+
}
|
|
|
|
|
|
|
26 |
|
27 |
+
$this->$controller_method();
|
28 |
+
}
|
29 |
|
30 |
+
private function needs_update() {
|
31 |
+
global $wpdb;
|
32 |
|
33 |
+
if ( get_option( '_wpsc_purchlogs_3.8_updated' ) )
|
34 |
+
return false;
|
|
|
35 |
|
36 |
+
$c = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE plugin_version IN ('3.6', '3.7')" );
|
37 |
+
if ( $c > 0 )
|
38 |
+
return true;
|
39 |
|
40 |
+
update_option( '_wpsc_purchlogs_3.8_updated', true );
|
41 |
+
return false;
|
42 |
+
}
|
43 |
|
44 |
+
public function controller_upgrade_purchase_logs_3_7() {
|
45 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_upgrade_purchase_logs_3_7' ) );
|
46 |
+
}
|
47 |
|
48 |
+
private function purchase_logs_fix_options( $id ) {
|
49 |
+
?>
|
50 |
+
<select name='<?php echo $id; ?>'>
|
51 |
+
<option value='-1'><?php _ex( 'Select an Option', 'Dropdown default when called in uniquename dropdown', 'wpsc' ); ?>'</option>
|
52 |
+
<option value='billingfirstname'><?php _e( 'Billing First Name', 'wpsc' ); ?></option>
|
53 |
+
<option value='billinglastname'><?php _e( 'Billing Last Name', 'wpsc' ); ?></option>
|
54 |
+
<option value='billingaddress'><?php _e( 'Billing Address', 'wpsc' ); ?></option>
|
55 |
+
<option value='billingcity'><?php _e( 'Billing City', 'wpsc' ); ?></option>
|
56 |
+
<option value='billingstate'><?php _e( 'Billing State', 'wpsc' ); ?></option>
|
57 |
+
<option value='billingcountry'><?php _e( 'Billing Country', 'wpsc' ); ?></option>
|
58 |
+
<option value='billingemail'><?php _e( 'Billing Email', 'wpsc' ); ?></option>
|
59 |
+
<option value='billingphone'><?php _e( 'Billing Phone', 'wpsc' ); ?></option>
|
60 |
+
<option value='billingpostcode'><?php _e( 'Billing Post Code', 'wpsc' ); ?></option>
|
61 |
+
<option value='shippingfirstname'><?php _e( 'Shipping First Name', 'wpsc' ); ?></option>
|
62 |
+
<option value='shippinglastname'><?php _e( 'Shipping Last Name', 'wpsc' ); ?></option>
|
63 |
+
<option value='shippingaddress'><?php _e( 'Shipping Address', 'wpsc' ); ?></option>
|
64 |
+
<option value='shippingcity'><?php _e( 'Shipping City', 'wpsc' ); ?></option>
|
65 |
+
<option value='shippingstate'><?php _e( 'Shipping State', 'wpsc' ); ?></option>
|
66 |
+
<option value='shippingcountry'><?php _e( 'Shipping Country', 'wpsc' ); ?></option>
|
67 |
+
<option value='shippingpostcode'><?php _e( 'Shipping Post Code', 'wpsc' ); ?></option>
|
68 |
+
</select>
|
69 |
<?php
|
70 |
+
}
|
71 |
+
|
72 |
+
public function display_upgrade_purchase_logs_3_7() {
|
73 |
+
global $wpdb;
|
74 |
+
$numChanged = 0;
|
75 |
+
$numQueries = 0;
|
76 |
+
$purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
|
77 |
+
$id = $wpdb->get_var($purchlog);
|
78 |
+
$usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`" ;
|
79 |
+
$formfields = $wpdb->get_results($usersql);
|
80 |
+
|
81 |
+
if(count($formfields) < 1){
|
82 |
+
$usersql = "SELECT DISTINCT `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` != 'heading'";
|
83 |
+
$formfields = $wpdb->get_results($usersql);
|
84 |
+
}
|
85 |
+
|
86 |
+
if(isset($_POST)){
|
87 |
+
foreach($_POST as $key=>$value){
|
88 |
+
if($value != '-1'){
|
89 |
+
$complete = $wpdb->update(
|
90 |
+
WPSC_TABLE_CHECKOUT_FORMS,
|
91 |
+
array(
|
92 |
+
'unique_name' => $value
|
93 |
+
),
|
94 |
+
array(
|
95 |
+
'id' => $key
|
96 |
+
),
|
97 |
+
'%s',
|
98 |
+
'%d'
|
99 |
+
);
|
100 |
+
}
|
101 |
+
$numChanged++;
|
102 |
+
$numQueries ++;
|
103 |
}
|
104 |
|
105 |
+
$sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='delivertoafriend' WHERE `name` = '2. Shipping details'";
|
106 |
+
$wpdb->query($sql);
|
107 |
|
108 |
+
add_option('wpsc_purchaselogs_fixed',true);
|
109 |
+
}
|
|
|
|
|
110 |
|
111 |
+
include( 'includes/purchase-logs-page/upgrade.php' );
|
112 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
public function display_upgrade_purchase_logs_3_8() {
|
115 |
+
?>
|
116 |
+
<div class="wrap">
|
117 |
+
<h2><?php echo esc_html( __('Sales', 'wpsc') ); ?> </h2>
|
118 |
+
<div class="updated">
|
119 |
+
<p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), remove_query_arg( 'c' ) ); ?></p>
|
120 |
+
</div>
|
121 |
</div>
|
122 |
+
<?php
|
123 |
+
}
|
124 |
+
|
125 |
+
public function controller_upgrade_purchase_logs_3_8() {
|
126 |
+
if ( $this->needs_update() )
|
127 |
+
wpsc_update_purchase_logs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_upgrade_purchase_logs_3_8' ) );
|
130 |
+
}
|
131 |
|
132 |
+
function purchase_logs_checkout_fields(){
|
133 |
+
global $purchlogitem;
|
134 |
+
if ( ! empty($purchlogitem->customcheckoutfields ) ) {
|
135 |
+
?>
|
136 |
+
<div class="metabox-holder">
|
137 |
+
<div id="custom_checkout_fields" class="postbox">
|
138 |
+
<h3 class='hndle'><?php _e( 'Additional Checkout Fields' , 'wpsc' ); ?></h3>
|
139 |
+
<div class='inside'>
|
140 |
+
<?php
|
141 |
+
foreach((array)$purchlogitem->customcheckoutfields as $key=>$value){
|
142 |
+
$value['value'] = maybe_unserialize($value['value']);
|
143 |
+
if(is_array($value['value'])){
|
144 |
+
?>
|
145 |
+
<p><strong><?php echo $key; ?> :</strong> <?php echo implode(stripslashse($value['value']), ','); ?></p>
|
146 |
+
<?php
|
147 |
+
}else{
|
148 |
+
?>
|
149 |
+
<p><strong><?php echo $key; ?> :</strong> <?php echo stripslashes($value['value']); ?></p>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
}
|
153 |
+
?>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
<?php
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
private function purchase_log_custom_fields(){
|
162 |
+
if( wpsc_purchlogs_has_customfields() ){?>
|
163 |
+
<div class='metabox-holder'>
|
164 |
+
<div id='purchlogs_customfields' class='postbox'>
|
165 |
+
<h3 class='hndle'><?php _e( 'Users Custom Fields' , 'wpsc' ); ?></h3>
|
166 |
+
<div class='inside'>
|
167 |
+
<?php $messages = wpsc_purchlogs_custommessages(); ?>
|
168 |
+
<?php $files = wpsc_purchlogs_customfiles(); ?>
|
169 |
+
<?php if(count($files) > 0){ ?>
|
170 |
+
<h4><?php _e( 'Cart Items with Custom Files' , 'wpsc' ); ?>:</h4>
|
171 |
+
<?php
|
172 |
+
foreach($files as $file){
|
173 |
+
echo $file;
|
174 |
+
}
|
175 |
+
}?>
|
176 |
+
<?php if(count($messages) > 0){ ?>
|
177 |
+
<h4><?php _e( 'Cart Items with Custom Messages' , 'wpsc' ); ?>:</h4>
|
178 |
+
<?php
|
179 |
+
foreach($messages as $message){
|
180 |
+
echo $message;
|
181 |
+
}
|
182 |
+
} ?>
|
183 |
+
</div>
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
private function purchase_log_cart_items() {
|
191 |
+
while( wpsc_have_purchaselog_details() ) : wpsc_the_purchaselog_item(); ?>
|
192 |
+
<tr>
|
193 |
+
<td><?php echo wpsc_purchaselog_details_name(); ?></td> <!-- NAME! -->
|
194 |
+
<td><?php echo wpsc_purchaselog_details_SKU(); ?></td> <!-- SKU! -->
|
195 |
+
<td><?php echo wpsc_purchaselog_details_quantity(); ?></td> <!-- QUANTITY! -->
|
196 |
+
<td>
|
197 |
+
<?php
|
198 |
+
echo wpsc_currency_display( wpsc_purchaselog_details_price() );
|
199 |
+
do_action( 'wpsc_additional_sales_amount_info', wpsc_purchaselog_details_id() );
|
200 |
+
?>
|
201 |
+
</td> <!-- PRICE! -->
|
202 |
+
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_shipping() ); ?></td> <!-- SHIPPING! -->
|
203 |
+
<?php if( wpec_display_product_tax() ): ?>
|
204 |
+
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_tax() ); ?></td> <!-- TAX! -->
|
205 |
+
<?php endif; ?>
|
206 |
+
<!-- <td><?php echo wpsc_currency_display( wpsc_purchaselog_details_discount() ); ?></td> --> <!-- DISCOUNT! -->
|
207 |
+
<td class="amount"><?php echo wpsc_currency_display( wpsc_purchaselog_details_total() ); ?></td> <!-- TOTAL! -->
|
208 |
+
</tr>
|
209 |
+
<?php
|
210 |
+
endwhile;
|
211 |
+
}
|
212 |
+
|
213 |
+
public function controller_item_details() {
|
214 |
+
if ( ! isset( $_REQUEST['id'] ) )
|
215 |
+
die( 'Invalid sales log ID' );
|
216 |
+
|
217 |
+
global $purchlogitem;
|
218 |
+
|
219 |
+
$this->log_id = (int) $_REQUEST['id'];
|
220 |
+
|
221 |
+
// TODO: seriously get rid of all these badly coded purchaselogs.class.php functions in 4.0
|
222 |
+
$purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
|
223 |
|
224 |
$columns = array(
|
225 |
+
'title' => __( 'Name','wpsc' ),
|
226 |
+
'sku' => __( 'SKU','wpsc' ),
|
227 |
+
'quantity' => __( 'Quantity','wpsc' ),
|
228 |
+
'price' => __( 'Price','wpsc' ),
|
229 |
+
'shipping' => __( 'Item Shipping','wpsc'),
|
|
|
|
|
230 |
);
|
231 |
|
232 |
+
if ( wpec_display_product_tax() ) {
|
233 |
+
$columns['tax'] = __( 'Item Tax', 'wpsc' );
|
234 |
+
}
|
|
|
235 |
|
236 |
+
$columns['total'] = __( 'Item Total','wpsc' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
+
register_column_headers( 'wpsc_purchase_log_item_details', $columns );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_purchase_log' ) );
|
241 |
+
}
|
242 |
|
243 |
+
public function controller_packing_slip() {
|
244 |
+
if ( ! isset( $_REQUEST['id'] ) )
|
245 |
+
die( 'Invalid sales log ID' );
|
246 |
|
247 |
+
global $purchlogitem;
|
248 |
|
249 |
+
$this->log_id = (int) $_REQUEST['id'];
|
|
|
250 |
|
251 |
+
$purchlogitem = new wpsc_purchaselogs_items( $this->log_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
+
$columns = array(
|
254 |
+
'title' => __( 'Item Name','wpsc' ),
|
255 |
+
'sku' => __( 'SKU','wpsc' ),
|
256 |
+
'quantity' => __( 'Quantity','wpsc' ),
|
257 |
+
'price' => __( 'Price','wpsc' ),
|
258 |
+
'shipping' => __( 'Item Shipping','wpsc'),
|
259 |
+
);
|
260 |
|
261 |
+
if ( wpec_display_product_tax() ) {
|
262 |
+
$columns['tax'] = __( 'Item Tax', 'wpsc' );
|
263 |
+
}
|
264 |
|
265 |
+
$columns['total'] = __( 'Item Total','wpsc' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
267 |
+
$cols = count( $columns ) - 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
|
269 |
+
register_column_headers( 'wpsc_purchase_log_item_details', $columns );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
+
include( 'includes/purchase-logs-page/packing-slip.php' );
|
272 |
+
exit;
|
273 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
+
public function controller_default() {
|
276 |
+
//Create an instance of our package class...
|
277 |
+
$this->list_table = new WPSC_Purchase_Log_List_Table();
|
278 |
+
$this->process_bulk_action();
|
279 |
+
$this->list_table->prepare_items();
|
280 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_list_table' ) );
|
281 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
+
public function display_purchase_log() {
|
284 |
+
if ( wpec_display_product_tax() )
|
285 |
+
$cols = 5;
|
286 |
+
else
|
287 |
+
$cols = 4;
|
288 |
+
include( 'includes/purchase-logs-page/item-details.php' );
|
289 |
+
}
|
290 |
|
291 |
+
public function download_csv() {
|
292 |
+
$_REQUEST['rss_key'] = 'key';
|
293 |
+
wpsc_purchase_log_csv();
|
294 |
+
}
|
295 |
|
296 |
+
public function process_bulk_action() {
|
297 |
+
global $wpdb;
|
298 |
+
$current_action = $this->list_table->current_action();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
+
do_action( 'wpsc_sales_log_process_bulk_action', $current_action );
|
301 |
+
|
302 |
+
if ( ! $current_action || ( 'download_csv' != $current_action && empty( $_REQUEST['post'] ) ) ) {
|
303 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
304 |
+
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'action', 'action2' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
|
305 |
+
exit;
|
306 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
308 |
+
unset( $_REQUEST['post'] );
|
309 |
+
return;
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( 'download_csv' == $current_action ) {
|
313 |
+
$this->download_csv();
|
314 |
+
exit;
|
315 |
+
}
|
316 |
+
|
317 |
+
$sendback = remove_query_arg( array(
|
318 |
+
'_wpnonce',
|
319 |
+
'_wp_http_referer',
|
320 |
+
'action',
|
321 |
+
'action2',
|
322 |
+
'confirm',
|
323 |
+
'post',
|
324 |
+
'last_paged'
|
325 |
+
) );
|
326 |
+
|
327 |
+
if ( 'delete' == $current_action ) {
|
328 |
+
|
329 |
+
// delete action
|
330 |
+
if ( empty( $_REQUEST['confirm'] ) ) {
|
331 |
+
$this->list_table->disable_search_box();
|
332 |
+
$this->list_table->disable_bulk_actions();
|
333 |
+
$this->list_table->disable_sortable();
|
334 |
+
$this->list_table->disable_month_filter();
|
335 |
+
$this->list_table->disable_views();
|
336 |
+
$this->list_table->set_per_page(0);
|
337 |
+
add_action( 'wpsc_purchase_logs_list_table_before', array( $this, 'action_list_table_before' ) );
|
338 |
+
return;
|
339 |
+
} else {
|
340 |
+
if ( empty( $_REQUEST['post'] ) )
|
341 |
+
return;
|
342 |
+
|
343 |
+
$ids = array_map( 'intval', $_REQUEST['post'] );
|
344 |
+
$in = implode( ', ', $ids );
|
345 |
+
$wpdb->query( "DELETE FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE id IN ($in)" );
|
346 |
+
$wpdb->query( "DELETE FROM " . WPSC_TABLE_CLAIMED_STOCK . " WHERE cart_id IN ($in)" );
|
347 |
+
$wpdb->query( "DELETE FROM " . WPSC_TABLE_CART_CONTENTS . " WHERE purchaseid IN ($in)" );
|
348 |
+
$wpdb->query( "DELETE FROM " . WPSC_TABLE_SUBMITED_FORM_DATA . " WHERE log_id IN ($in)" );
|
349 |
+
|
350 |
+
$sendback = add_query_arg( array(
|
351 |
+
'paged' => $_REQUEST['last_paged'],
|
352 |
+
'deleted' => count( $_REQUEST['post'] ),
|
353 |
+
), $sendback );
|
354 |
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
// change status actions
|
359 |
+
if ( is_numeric( $current_action ) && $current_action < 7 && ! empty( $_REQUEST['post'] ) ) {
|
360 |
+
|
361 |
+
foreach ( $_REQUEST['post'] as $id )
|
362 |
+
wpsc_purchlog_edit_status( $id, $current_action );
|
363 |
+
|
364 |
+
$sendback = add_query_arg( array(
|
365 |
+
'updated' => count( $_REQUEST['post'] ),
|
366 |
+
), $sendback );
|
367 |
+
}
|
368 |
+
|
369 |
+
wp_redirect( $sendback );
|
370 |
+
exit;
|
371 |
}
|
|
|
372 |
|
373 |
+
public function action_list_table_before() {
|
374 |
+
include( 'includes/purchase-logs-page/bulk-delete-confirm.php' );
|
375 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
|
377 |
+
public function display_list_table() {
|
378 |
+
if ( ! empty( $this->output ) ) {
|
379 |
+
echo $this->output;
|
380 |
+
return;
|
381 |
+
}
|
382 |
+
|
383 |
+
include( 'includes/purchase-logs-page/list-table.php' );
|
384 |
+
}
|
385 |
}
|
|
wpsc-admin/display-update.page.php
CHANGED
@@ -54,7 +54,7 @@ if ( version_compare( PHP_VERSION, '5.0.0', '<' ) ) {
|
|
54 |
|
55 |
function wpsc_display_php_version_notice() {
|
56 |
?>
|
57 |
-
<div id='wpsc-warning' class='error fade'><p><?php printf( __(
|
58 |
<?php
|
59 |
}
|
60 |
|
54 |
|
55 |
function wpsc_display_php_version_notice() {
|
56 |
?>
|
57 |
+
<div id='wpsc-warning' class='error fade'><p><?php printf( __( 'You are using PHP %s. WP e-Commerce %s requires PHP 5.0 or above. Please contact your hosting provider for further assistance.', 'wpsc' ), PHP_VERSION, WPSC_VERSION ); ?></p></div>
|
58 |
<?php
|
59 |
}
|
60 |
|
wpsc-admin/includes/display-items-functions.php
CHANGED
@@ -355,7 +355,7 @@ function wpsc_product_taxes_forms() {
|
|
355 |
}
|
356 |
}// if
|
357 |
|
358 |
-
?>
|
359 |
<p><?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ); ?></p>
|
360 |
<p>
|
361 |
<?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ): ?>
|
@@ -384,35 +384,52 @@ function wpsc_product_variation_forms() {
|
|
384 |
|
385 |
$siteurl = get_option( 'siteurl' );
|
386 |
$output = '';
|
387 |
-
|
388 |
-
// Get variation data from WP Terms
|
389 |
-
$product_term_data = wp_get_object_terms( $post->ID, 'wpsc-variation' );
|
390 |
-
if ( !empty( $product_term_data ) ) {
|
391 |
-
foreach ( $product_term_data as $product_term )
|
392 |
-
$product_terms[] = $product_term->term_id;
|
393 |
-
} else {
|
394 |
-
$product_terms = array();
|
395 |
-
}
|
396 |
?>
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
</div>
|
|
|
416 |
<?php
|
417 |
$parent_product = $post->ID;
|
418 |
|
@@ -440,10 +457,7 @@ function wpsc_product_variation_forms() {
|
|
440 |
if ( !isset( $parent_product_data ) )
|
441 |
$parent_product_data = null;
|
442 |
?>
|
443 |
-
|
444 |
-
<p><a name='variation_control'> </a><?php _e( 'Check or uncheck variation boxes and then click Update Variations to add or remove variations.', 'wpsc' ) ?></p>
|
445 |
-
|
446 |
-
<table class="widefat page" id='wpsc_product_list' cellspacing="0">
|
447 |
<thead>
|
448 |
<tr>
|
449 |
<?php print_column_headers( 'wpsc-product_variants' ); ?>
|
@@ -525,7 +539,7 @@ function wpsc_product_shipping_forms() {
|
|
525 |
}
|
526 |
if( !isset( $product_meta['no_shipping'] ) )
|
527 |
$product_meta['no_shipping'] = '';
|
528 |
-
?>
|
529 |
<table>
|
530 |
|
531 |
<!--USPS shipping changes-->
|
@@ -804,6 +818,7 @@ function wpsc_product_download_forms() {
|
|
804 |
$upload_max = wpsc_get_max_upload_size();
|
805 |
?>
|
806 |
<?php echo wpsc_select_product_file( $post->ID ); ?>
|
|
|
807 |
<h4><?php _e( 'Upload New File', 'wpsc' ); ?>:</h4>
|
808 |
<input type='file' name='file' value='' /><br /><?php _e( 'Max Upload Size', 'wpsc' ); ?>:<span><?php echo $upload_max; ?></span><br /><br />
|
809 |
<h4><a href="admin.php?wpsc_admin_action=product_files_existing&product_id=<?php echo $post->ID; ?>" class="thickbox" title="<?php printf( __( 'Select all downloadable files for %s', 'wpsc' ), $post->post_title ); ?>"><?php _e( 'Select from existing files', 'wpsc' ); ?></a></h4>
|
@@ -896,9 +911,9 @@ function wpsc_filter_gettex_with_context( $translation, $text, $context, $domain
|
|
896 |
|
897 |
if ( 'Taxonomy Parent' == $context && 'Parent' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ) {
|
898 |
$translations = &get_translations_for_domain( $domain );
|
899 |
-
return $translations->translate( 'Variation
|
900 |
//this will never happen, this is here only for gettex to pick up the translation
|
901 |
-
return __( 'Variation
|
902 |
}
|
903 |
return $translation;
|
904 |
}
|
@@ -923,12 +938,14 @@ function wpsc_filter_feature_image_text( $translation, $text, $domain ) {
|
|
923 |
//this will never happen, this is here only for gettex to pick up the translation
|
924 |
return __( 'Use as Product Thumbnail', 'wpsc' );
|
925 |
}
|
|
|
926 |
if ( 'The name is how it appears on your site.' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ){
|
927 |
$translations = &get_translations_for_domain( $domain );
|
928 |
-
return $translations->translate( 'The name is how it appears on your site. <br><div class="error"><strong>Please read this carefully before starting to work with variations:</strong><br />Variations in WP e-Commerce are divided into sets. For example set <strong>Color</strong> could have variations <strong>Red, Green,</strong> and <strong>Blue</strong>. To create a variation set simply enter the <strong>name</strong> and push Enter key on your keyboard or click <strong>Add New Variation/Set</strong> button in the bottom of this page. Then you will be able to select it from <strong>Variation set</strong> drop-down menu and add some variations to it. To add a new variation set just select <strong>
|
929 |
//this will never happen, this is here only for gettex to pick up the translation
|
930 |
return __( 'The name is how it appears on your site. <br><div class="error"><strong>Please read this carefully before starting to work with variations:</strong><br />Variations in WP e-Commerce are divided into sets. For example set <strong>Color</strong> could have variations <strong>Red, Green,</strong> and <strong>Blue</strong>. To create a set simply enter <strong>Name</strong> and push Enter key on your keyboard or click <strong>Add New Variation/Set</strong> button in the bottom of this page. Now you can select the variation set that you\'ve just created from <strong>Variation set</strong> drop-down menu and add some variations to it.</div>', 'wpsc' );
|
931 |
}
|
|
|
932 |
|
933 |
return $translation;
|
934 |
}
|
@@ -1265,4 +1282,4 @@ function wpsc_remove_bulk_edit($options){
|
|
1265 |
add_action( 'quick_edit_custom_box', 'wpsc_quick_edit_boxes', 10, 2 );
|
1266 |
add_action( 'save_post', 'wpsc_save_quickedit_box' );
|
1267 |
add_action( 'bulk_actions-edit-wpsc-product', 'wpsc_remove_bulk_edit');
|
1268 |
-
?>
|
355 |
}
|
356 |
}// if
|
357 |
|
358 |
+
?> <a name="wpsc_tax"></a>
|
359 |
<p><?php echo $wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ); ?></p>
|
360 |
<p>
|
361 |
<?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ): ?>
|
384 |
|
385 |
$siteurl = get_option( 'siteurl' );
|
386 |
$output = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
?>
|
388 |
+
<a name="#wpsc_variation_metabox"></a>
|
389 |
+
<?php if ( empty( $post->post_title ) ) : ?>
|
390 |
+
<p><?php _e( 'You must first save this Product as a Draft before adding variations.', 'wpsc' ); ?></p>
|
391 |
+
<h4><a href="<?php echo get_admin_url(); ?>/edit-tags.php?taxonomy=wpsc-variation&post_type=wpsc-product" target="_blank">+ Add New Variation Set</a></h4>
|
392 |
+
<?php else : ?>
|
393 |
+
<div id="product_variations">
|
394 |
+
<p><a name='variation_control'> </a><?php _e( 'Select the Variation sets and then the corresponding Variants you want to add to this product.', 'wpsc' ) ?></p>
|
395 |
+
|
396 |
+
<ul class="variation_checkboxes">
|
397 |
+
<?php
|
398 |
+
|
399 |
+
wp_terms_checklist( $post->ID, array(
|
400 |
+
'taxonomy' => 'wpsc-variation',
|
401 |
+
'walker' => new WPSC_Walker_Variation_Checklist(),
|
402 |
+
'checked_ontop' => false,
|
403 |
+
) );
|
404 |
+
|
405 |
+
?>
|
406 |
+
</ul>
|
407 |
+
|
408 |
+
<p class="update-variations">
|
409 |
+
<a class="button update_variations_action" href='#'><?php _e( 'Apply Variations →', 'wpsc' ); ?></a>
|
410 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
411 |
+
</p>
|
412 |
|
413 |
+
<div class="clear"></div>
|
414 |
+
<h4><a href="#wpsc_variation_metabox" class="add_variation_set_action"><?php esc_html_e( '+ Add New Variants', 'wpsc' ) ?></a></h4>
|
415 |
+
|
416 |
+
<div id="add-new-variation-set">
|
417 |
+
<p>
|
418 |
+
<label for="new-variation-set-name"><?php esc_html_e( "Enter variation set's name", 'wpsc' ); ?></label>
|
419 |
+
<input type="text" class="text-field" id="new-variation-set-name" /><br />
|
420 |
+
</p>
|
421 |
+
<p class="howto"><?php esc_html_e( "Example: Color. If you want to add variants to an existing set, you can enter the name of that set here.", 'wpsc' ); ?></p>
|
422 |
+
<p>
|
423 |
+
<label for="new-variants"><?php esc_html_e( "Enter new variants", 'wpsc' ); ?></label>
|
424 |
+
<input type="text" class="text-field" id="new-variants" /><br />
|
425 |
+
</p>
|
426 |
+
<p class="howto"><?php esc_html_e( "Example: Red, Green, Blue. Separate variants with commas.", 'wpsc' ); ?></p>
|
427 |
+
<p>
|
428 |
+
<a class="button" href="#"><?php esc_html_e( 'Add New Variants', 'wpsc' ); ?></a>
|
429 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
430 |
+
</p>
|
431 |
</div>
|
432 |
+
</div>
|
433 |
<?php
|
434 |
$parent_product = $post->ID;
|
435 |
|
457 |
if ( !isset( $parent_product_data ) )
|
458 |
$parent_product_data = null;
|
459 |
?>
|
460 |
+
<table class="widefat page" id='wpsc_product_list' cellspacing="0">
|
|
|
|
|
|
|
461 |
<thead>
|
462 |
<tr>
|
463 |
<?php print_column_headers( 'wpsc-product_variants' ); ?>
|
539 |
}
|
540 |
if( !isset( $product_meta['no_shipping'] ) )
|
541 |
$product_meta['no_shipping'] = '';
|
542 |
+
?> <a name="wpsc_shipping"></a>
|
543 |
<table>
|
544 |
|
545 |
<!--USPS shipping changes-->
|
818 |
$upload_max = wpsc_get_max_upload_size();
|
819 |
?>
|
820 |
<?php echo wpsc_select_product_file( $post->ID ); ?>
|
821 |
+
<a name="wpsc_downloads"></a>
|
822 |
<h4><?php _e( 'Upload New File', 'wpsc' ); ?>:</h4>
|
823 |
<input type='file' name='file' value='' /><br /><?php _e( 'Max Upload Size', 'wpsc' ); ?>:<span><?php echo $upload_max; ?></span><br /><br />
|
824 |
<h4><a href="admin.php?wpsc_admin_action=product_files_existing&product_id=<?php echo $post->ID; ?>" class="thickbox" title="<?php printf( __( 'Select all downloadable files for %s', 'wpsc' ), $post->post_title ); ?>"><?php _e( 'Select from existing files', 'wpsc' ); ?></a></h4>
|
911 |
|
912 |
if ( 'Taxonomy Parent' == $context && 'Parent' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ) {
|
913 |
$translations = &get_translations_for_domain( $domain );
|
914 |
+
return $translations->translate( 'Variation Set', 'wpsc' );
|
915 |
//this will never happen, this is here only for gettex to pick up the translation
|
916 |
+
return __( 'Variation Set', 'wpsc' );
|
917 |
}
|
918 |
return $translation;
|
919 |
}
|
938 |
//this will never happen, this is here only for gettex to pick up the translation
|
939 |
return __( 'Use as Product Thumbnail', 'wpsc' );
|
940 |
}
|
941 |
+
/*
|
942 |
if ( 'The name is how it appears on your site.' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ){
|
943 |
$translations = &get_translations_for_domain( $domain );
|
944 |
+
return $translations->translate( 'The name is how it appears on your site. <br><div class="error"><strong>Please read this carefully before starting to work with variations:</strong><br />Variations in WP e-Commerce are divided into sets. For example set <strong>Color</strong> could have variations <strong>Red, Green,</strong> and <strong>Blue</strong>. To create a variation set simply enter the <strong>name</strong> and push Enter key on your keyboard or click <strong>Add New Variation/Set</strong> button in the bottom of this page. Then you will be able to select it from <strong>Variation set</strong> drop-down menu and add some variations to it. To add a new variation set just select <strong>New Variation Set</strong> in <strong>Variation set</strong> drop-down menu.</div>', 'wpsc' );
|
945 |
//this will never happen, this is here only for gettex to pick up the translation
|
946 |
return __( 'The name is how it appears on your site. <br><div class="error"><strong>Please read this carefully before starting to work with variations:</strong><br />Variations in WP e-Commerce are divided into sets. For example set <strong>Color</strong> could have variations <strong>Red, Green,</strong> and <strong>Blue</strong>. To create a set simply enter <strong>Name</strong> and push Enter key on your keyboard or click <strong>Add New Variation/Set</strong> button in the bottom of this page. Now you can select the variation set that you\'ve just created from <strong>Variation set</strong> drop-down menu and add some variations to it.</div>', 'wpsc' );
|
947 |
}
|
948 |
+
*/
|
949 |
|
950 |
return $translation;
|
951 |
}
|
1282 |
add_action( 'quick_edit_custom_box', 'wpsc_quick_edit_boxes', 10, 2 );
|
1283 |
add_action( 'save_post', 'wpsc_save_quickedit_box' );
|
1284 |
add_action( 'bulk_actions-edit-wpsc-product', 'wpsc_remove_bulk_edit');
|
1285 |
+
?>
|
wpsc-admin/includes/product-functions.php
CHANGED
@@ -15,7 +15,7 @@ function wpsc_get_max_upload_size(){
|
|
15 |
|
16 |
|
17 |
/**
|
18 |
-
* wpsc_product_has_children function
|
19 |
* Checks whether a product has variations or not
|
20 |
*
|
21 |
* @return boolean true if product does have variations, false otherwise
|
@@ -25,7 +25,7 @@ function wpsc_product_has_children($id){
|
|
25 |
'post_parent' => $id,
|
26 |
'post_type' => 'wpsc-product',
|
27 |
'post_status' => 'inherit publish'
|
28 |
-
);
|
29 |
$children = get_children($args);
|
30 |
if( empty($children) )
|
31 |
return false;
|
@@ -34,9 +34,9 @@ function wpsc_product_has_children($id){
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
-
* wpsc_admin_submit_product function
|
38 |
* @internal Was going to completely refactor sanitise forms and wpsc_insert_product, but they are also used by the import system
|
39 |
-
* which I'm not really familiar with...so I'm not touching them :) Erring on the side of redundancy and caution I'll just
|
40 |
* refactor this to do the job.
|
41 |
* @return nothing
|
42 |
*/
|
@@ -72,52 +72,52 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
|
|
72 |
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
73 |
if(!isset($post_data['special'])) $post_data['special'] = '';
|
74 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
|
75 |
-
|
76 |
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
77 |
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
78 |
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
79 |
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
|
80 |
-
|
81 |
// Product Weight
|
82 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
83 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
84 |
-
|
85 |
$weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
86 |
$post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
|
87 |
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
88 |
-
|
89 |
// table rate price
|
90 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
|
91 |
-
|
92 |
// if table_rate_price is unticked, wipe the table rate prices
|
93 |
if ( empty( $post_data['table_rate_price']['state'] ) ) {
|
94 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
|
95 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
|
96 |
}
|
97 |
-
|
98 |
if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
|
99 |
foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ){
|
100 |
if(empty($value)){
|
101 |
-
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
|
102 |
-
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
|
103 |
-
}
|
104 |
}
|
105 |
}
|
106 |
|
107 |
-
|
108 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
|
109 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
|
110 |
-
|
111 |
-
|
112 |
// Advanced Options
|
113 |
-
$post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
|
114 |
$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
|
115 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
|
116 |
$post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
|
117 |
-
|
118 |
$post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
|
119 |
$post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
|
120 |
-
|
121 |
$post_data['files'] = $_FILES;
|
122 |
|
123 |
if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
|
@@ -158,11 +158,11 @@ function wpsc_admin_submit_product( $post_ID, $post ) {
|
|
158 |
}
|
159 |
}
|
160 |
// if we succeed, we can do further editing (todo - if_wp_error)
|
161 |
-
|
162 |
// if we have no categories selected, assign one.
|
163 |
if( isset( $post_data['tax_input']['wpsc_product_category'] ) && count( $post_data['tax_input']['wpsc_product_category'] ) == 1 && $post_data['tax_input']['wpsc_product_category'][0] == 0){
|
164 |
$post_data['tax_input']['wpsc_product_category'][1] = wpsc_add_product_category_default($product_id);
|
165 |
-
|
166 |
}
|
167 |
// and the meta
|
168 |
wpsc_update_product_meta($product_id, $post_data['meta']);
|
@@ -235,28 +235,28 @@ function wpsc_variation_remove_metaboxes() {
|
|
235 |
global $post;
|
236 |
if ( ! $post->post_parent )
|
237 |
return;
|
238 |
-
|
239 |
remove_meta_box( 'wpsc_product_categorydiv', 'wpsc-product', 'side' );
|
240 |
}
|
241 |
add_action( 'add_meta_boxes_wpsc-product', 'wpsc_variation_remove_metaboxes', 99 );
|
242 |
|
243 |
function wpsc_admin_submit_notices() {
|
244 |
global $current_screen, $post;
|
245 |
-
|
246 |
if( $current_screen->id != 'wpsc-product' || !isset( $_SESSION['product_error_messages'] ) )
|
247 |
return;
|
248 |
foreach ( $_SESSION['product_error_messages'] as $error )
|
249 |
echo "<div id=\"message\" class=\"updated below-h2\"><p>".$error."</p></div>";
|
250 |
unset( $_SESSION['product_error_messages'] );
|
251 |
}
|
252 |
-
|
253 |
/**
|
254 |
* wpsc_add_product_category_default, if there is no category assigned assign first product category as default
|
255 |
*
|
256 |
* @since 3.8
|
257 |
* @param $product_id (int) the Post ID
|
258 |
* @return null
|
259 |
-
*/
|
260 |
function wpsc_add_product_category_default( $product_id ){
|
261 |
$terms = get_terms( 'wpsc_product_category', array( 'orderby' => 'id', 'hide_empty' => 0 ) );
|
262 |
if ( ! empty( $terms ) ) {
|
@@ -265,17 +265,17 @@ function wpsc_add_product_category_default( $product_id ){
|
|
265 |
}
|
266 |
}
|
267 |
/**
|
268 |
-
* wpsc_sanitise_product_forms function
|
269 |
-
*
|
270 |
* @return array - Sanitised product details
|
271 |
*/
|
272 |
function wpsc_sanitise_product_forms($post_data = null) {
|
273 |
if ( empty($post_data) ) {
|
274 |
$post_data = &$_POST;
|
275 |
}
|
276 |
-
|
277 |
$product = get_post(absint($post_data['post_ID']));
|
278 |
-
|
279 |
$post_data['name'] = isset($post_data['post_title']) ? $post_data['post_title'] : '';
|
280 |
$post_data['title'] = $post_data['name'];
|
281 |
$post_data['description'] = isset($post_data['content']) ? $post_data['content'] : '';
|
@@ -286,11 +286,11 @@ function wpsc_sanitise_product_forms($post_data = null) {
|
|
286 |
} else {
|
287 |
$post_data['post_status'] = 'draft';
|
288 |
}
|
289 |
-
|
290 |
if(isset($post_data['save']) && $product->post_status == 'inherit' && ( $product->post_parent == 0 || $product->post_parent == $product->ID ) ) {
|
291 |
$post_data['post_status'] = 'draft';
|
292 |
} else if(isset($post_data['publish'])) {
|
293 |
-
$post_data['post_status'] = 'publish';
|
294 |
} else if(isset($post_data['unpublish'])) {
|
295 |
$post_data['post_status'] = 'draft';
|
296 |
}
|
@@ -298,7 +298,7 @@ function wpsc_sanitise_product_forms($post_data = null) {
|
|
298 |
|
299 |
|
300 |
$post_meta['meta'] = (array)$_POST['meta'];
|
301 |
-
|
302 |
$post_data['meta']['_wpsc_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_price'] );
|
303 |
$post_data['meta']['_wpsc_special_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_special_price'] );
|
304 |
$post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
|
@@ -315,20 +315,20 @@ function wpsc_sanitise_product_forms($post_data = null) {
|
|
315 |
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
316 |
if(!isset($post_data['special'])) $post_data['special'] = '';
|
317 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
|
318 |
-
|
319 |
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
320 |
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
321 |
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
322 |
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
|
323 |
-
|
324 |
// Product Weight
|
325 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
326 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
327 |
-
|
328 |
$weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
329 |
$post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
|
330 |
-
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
331 |
-
|
332 |
// table rate price
|
333 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
|
334 |
// if table_rate_price is unticked, wipe the table rate prices
|
@@ -339,38 +339,38 @@ function wpsc_sanitise_product_forms($post_data = null) {
|
|
339 |
}
|
340 |
foreach((array)$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value){
|
341 |
if(empty($value)){
|
342 |
-
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
|
343 |
-
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
|
344 |
-
}
|
345 |
}
|
346 |
|
347 |
-
|
348 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
|
349 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
|
350 |
-
|
351 |
-
|
352 |
// Advanced Options
|
353 |
-
$post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
|
354 |
$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
|
355 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
|
356 |
$post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
|
357 |
$post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
|
358 |
$post_data['meta']['_wpsc_product_metadata']['external_link_text'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_text'];
|
359 |
$post_data['meta']['_wpsc_product_metadata']['external_link_target'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_target'];
|
360 |
-
|
361 |
$post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
|
362 |
$post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
|
363 |
-
|
364 |
$post_data['files'] = $_FILES;
|
365 |
return $post_data;
|
366 |
}
|
367 |
-
|
368 |
/**
|
369 |
-
* wpsc_insert_product function
|
370 |
*
|
371 |
-
* @param unknown
|
372 |
* @return unknown
|
373 |
-
*/
|
374 |
function wpsc_insert_product($post_data, $wpsc_error = false) {
|
375 |
global $wpdb, $user_ID;
|
376 |
$adding = false;
|
@@ -382,7 +382,7 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
382 |
$product_id = absint($post_data['product_id']);
|
383 |
$update = true;
|
384 |
}
|
385 |
-
|
386 |
$product_columns = array(
|
387 |
'name' => '',
|
388 |
'description' => '',
|
@@ -407,19 +407,19 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
407 |
'thumbnail_image' => null,
|
408 |
'thumbnail_state' => null
|
409 |
);
|
410 |
-
|
411 |
-
|
412 |
-
foreach($product_columns as $column => $default)
|
413 |
{
|
414 |
-
if (!isset($post_data[$column])) $post_data[$column] = '';
|
415 |
-
|
416 |
if($post_data[$column] !== null) {
|
417 |
$update_values[$column] = stripslashes($post_data[$column]);
|
418 |
} else if(($update != true) && ($default !== null)) {
|
419 |
$update_values[$column] = stripslashes($default);
|
420 |
}
|
421 |
}
|
422 |
-
|
423 |
$product_post_values = array(
|
424 |
'ID' => $product_id,
|
425 |
'post_author' => $user_ID,
|
@@ -435,13 +435,13 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
435 |
}else {
|
436 |
$product_post_values["comment_status"] = "open";
|
437 |
}
|
438 |
-
|
439 |
if(isset($sku) && ($sku != '')) {
|
440 |
$product_post_array['guid'] = $sku;
|
441 |
}
|
442 |
|
443 |
|
444 |
-
|
445 |
if($update === true) {
|
446 |
$where = array( 'id' => $product_id );
|
447 |
$product_id = wp_update_post($product_post_values);
|
@@ -456,7 +456,7 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
456 |
} else {
|
457 |
return false;
|
458 |
}
|
459 |
-
}
|
460 |
} else {
|
461 |
$product_post_values += array(
|
462 |
'post_date' => $product['date_added']
|
@@ -476,15 +476,15 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
476 |
}
|
477 |
$adding = true;
|
478 |
}
|
479 |
-
|
480 |
// if we succeed, we can do further editing
|
481 |
-
|
482 |
// and the meta
|
483 |
wpsc_update_product_meta($product_id, $post_data['meta']);
|
484 |
-
|
485 |
// and the custom meta
|
486 |
wpsc_update_custom_meta($product_id, $post_data);
|
487 |
-
|
488 |
//and the alt currency
|
489 |
foreach((array)$post_data['newCurrency'] as $key =>$value){
|
490 |
wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
|
@@ -496,7 +496,7 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
496 |
if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
|
497 |
wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
|
498 |
}
|
499 |
-
|
500 |
if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
|
501 |
wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
|
502 |
}
|
@@ -506,7 +506,7 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
506 |
}
|
507 |
|
508 |
/**
|
509 |
-
* term_id_price function
|
510 |
* Retreives associated price, if any, with term_id
|
511 |
* @param integer term ID
|
512 |
* @param integer parent product price
|
@@ -516,16 +516,16 @@ function wpsc_insert_product($post_data, $wpsc_error = false) {
|
|
516 |
function term_id_price($term_id, $parent_price) {
|
517 |
|
518 |
$term_price_arr = get_option( 'term_prices' );
|
519 |
-
|
520 |
if ( isset($term_price_arr[$term_id]) ) {
|
521 |
-
$price = $term_price_arr[$term_id]["price"];
|
522 |
} else {
|
523 |
$price = 0;
|
524 |
}
|
525 |
-
|
526 |
//Check for flat, percentile or differential
|
527 |
$var_price_type = '';
|
528 |
-
|
529 |
if (flat_price($price)) {
|
530 |
$var_price_type = 'flat';
|
531 |
$price = floatval($price);
|
@@ -534,15 +534,15 @@ function term_id_price($term_id, $parent_price) {
|
|
534 |
} elseif (percentile_price($price)) {
|
535 |
$var_price_type = 'percentile';
|
536 |
}
|
537 |
-
|
538 |
if (strchr($price, '-') ) {
|
539 |
$negative = true;
|
540 |
} else {
|
541 |
$positive = true;
|
542 |
}
|
543 |
-
|
544 |
if ($positive) {
|
545 |
-
|
546 |
if ( $var_price_type == 'differential' ) {
|
547 |
$differential = (floatval($price));
|
548 |
$price = $parent_price + $differential;
|
@@ -550,10 +550,10 @@ function term_id_price($term_id, $parent_price) {
|
|
550 |
$percentage = (floatval($price) / 100);
|
551 |
$price = $parent_price + ($parent_price * $percentage);
|
552 |
}
|
553 |
-
|
554 |
} else {
|
555 |
|
556 |
-
if ( $var_price_type == 'differential' ) {
|
557 |
$differential = (floatval($price));
|
558 |
$price = $parent_price - $differential;
|
559 |
} elseif ( $var_price_type == 'percentile' ) {
|
@@ -578,10 +578,10 @@ function term_id_price($term_id, $parent_price) {
|
|
578 |
function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
579 |
$flat = array();
|
580 |
$diff = 0;
|
581 |
-
|
582 |
$variation = get_post( $variation_id );
|
583 |
$price = (float) get_product_meta( $variation->post_parent, 'price', true );
|
584 |
-
|
585 |
if ( ! $term_ids )
|
586 |
$term_ids = wp_get_object_terms( $variation_id, 'wpsc-variation', array( 'fields' => 'ids' ) );
|
587 |
|
@@ -590,7 +590,7 @@ function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
|
590 |
if ( isset( $term_price_arr[$term_id] ) )
|
591 |
$term_price = trim( $term_price_arr[$term_id]['price'] );
|
592 |
else
|
593 |
-
continue;
|
594 |
if ( flat_price( $term_price ) ) {
|
595 |
$flat[] = $term_price;
|
596 |
} elseif ( differential_price( $term_price ) ) {
|
@@ -608,7 +608,7 @@ function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
|
608 |
|
609 |
/**
|
610 |
* wpsc_edit_product_variations function.
|
611 |
-
* this is the function to make child products using variations
|
612 |
*
|
613 |
* @access public
|
614 |
* @param mixed $product_id
|
@@ -616,35 +616,38 @@ function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
|
616 |
* @return void
|
617 |
*/
|
618 |
function wpsc_edit_product_variations($product_id, $post_data) {
|
619 |
-
global $
|
620 |
-
|
621 |
-
|
|
|
|
|
622 |
return;
|
|
|
623 |
$variations = array();
|
624 |
$product_children = array();
|
625 |
if (!isset($post_data['edit_var_val']))
|
626 |
$post_data['edit_var_val'] = '';
|
627 |
-
|
628 |
$variations = (array)$post_data['edit_var_val'];
|
629 |
|
630 |
// Generate the arrays for variation sets, values and combinations
|
631 |
$wpsc_combinator = new wpsc_variation_combinator($variations);
|
632 |
-
|
633 |
// Retrieve the array containing the variation set IDs
|
634 |
$variation_sets = $wpsc_combinator->return_variation_sets();
|
635 |
-
|
636 |
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
637 |
$variation_values = $wpsc_combinator->return_variation_values();
|
638 |
-
|
639 |
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
640 |
$combinations = $wpsc_combinator->return_combinations();
|
641 |
-
|
642 |
$product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
|
643 |
-
|
644 |
$variation_sets_and_values = array_merge($variation_sets, $variation_values);
|
645 |
-
$variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
|
646 |
-
wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
|
647 |
-
|
648 |
$child_product_template = array(
|
649 |
'post_author' => $user_ID,
|
650 |
'post_content' => $post_data['description'],
|
@@ -655,9 +658,9 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
655 |
'post_name' => sanitize_title($post_data['name']),
|
656 |
'post_parent' => $product_id
|
657 |
);
|
658 |
-
|
659 |
$child_product_meta = get_post_custom($product_id);
|
660 |
-
|
661 |
// here we loop through the combinations, get the term data and generate custom product names
|
662 |
foreach($combinations as $combination) {
|
663 |
$term_names = array();
|
@@ -670,7 +673,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
670 |
'include' => implode(",", $combination),
|
671 |
'orderby' => 'parent',
|
672 |
));
|
673 |
-
|
674 |
foreach($combination_terms as $term) {
|
675 |
$term_ids[] = $term->term_id;
|
676 |
$term_slugs[] = $term->slug;
|
@@ -693,9 +696,9 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
693 |
if($child_product_id == false) {
|
694 |
$already_a_variation = false;
|
695 |
if($selected_post != null) {
|
696 |
-
$child_product_id = $selected_post->ID;
|
697 |
} else {
|
698 |
-
$child_product_id =
|
699 |
}
|
700 |
} else {
|
701 |
// sometimes there have been problems saving the variations, this gets the correct product ID
|
@@ -716,16 +719,16 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
716 |
} else {
|
717 |
update_post_meta($child_product_id, $meta_key, $meta_value[0]);
|
718 |
}
|
719 |
-
|
720 |
endforeach;
|
721 |
-
|
722 |
if ( is_array( $term_ids ) && $price = wpsc_determine_variation_price( $child_product_id, $term_ids ) )
|
723 |
update_product_meta( $child_product_id, 'price', $price );
|
724 |
}
|
725 |
}
|
726 |
-
|
727 |
|
728 |
-
|
|
|
729 |
//Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
|
730 |
//Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
|
731 |
$posted_term = $variations;
|
@@ -735,17 +738,17 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
735 |
foreach ($currently_associated_var as $current) {
|
736 |
$currently_associated_vars[] = $current->term_id;
|
737 |
}
|
738 |
-
|
739 |
foreach ($posted_term as $term=>$val) {
|
740 |
$posted_terms[] = $term;
|
741 |
if(is_array($val)) {
|
742 |
foreach($val as $term2=>$val2) {
|
743 |
-
$posted_terms[] = $term2;
|
744 |
}
|
745 |
}
|
746 |
}
|
747 |
-
if(!empty($currently_associated_vars)){
|
748 |
-
$term_ids_to_delete = array();
|
749 |
$term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
|
750 |
}
|
751 |
if(isset($_REQUEST["post_ID"]))
|
@@ -754,10 +757,10 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
754 |
$post_id = $_REQUEST["product_id"];
|
755 |
if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
|
756 |
$post_ids_to_delete = array();
|
757 |
-
|
758 |
// Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
|
759 |
$post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
|
760 |
-
|
761 |
if(is_array($post_ids_to_delete) && !empty($post_ids_to_delete)) {
|
762 |
foreach($post_ids_to_delete as $object_ids) {
|
763 |
foreach($object_ids as $object_id) {
|
@@ -765,7 +768,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
765 |
}
|
766 |
}
|
767 |
}
|
768 |
-
}
|
769 |
$current_children = query_posts(array(
|
770 |
'post_parent' => $post_id,
|
771 |
'post_type' => "wpsc-product",
|
@@ -777,7 +780,7 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
777 |
}
|
778 |
if(!empty($childs)){
|
779 |
$old_ids_to_delete = array_diff($childs, $product_children);
|
780 |
-
$old_ids_to_delete = apply_filters('wpsc_edit_product_variations_deletion', $old_ids_to_delete);
|
781 |
if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
|
782 |
foreach($old_ids_to_delete as $object_ids) {
|
783 |
wp_delete_post($object_ids);
|
@@ -788,11 +791,11 @@ function wpsc_edit_product_variations($product_id, $post_data) {
|
|
788 |
|
789 |
function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
|
790 |
global $wpdb;
|
791 |
-
|
792 |
$old_curr = get_product_meta($product_id, 'currency',true);
|
793 |
-
$sql = "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`="
|
794 |
$isocode = $wpdb->get_var($sql);
|
795 |
-
|
796 |
$newCurrency = 'currency';
|
797 |
$old_curr[$isocode] = $newPrice;
|
798 |
if(($newPrice != '') && ($newPrice > 0.00)){
|
@@ -805,7 +808,7 @@ function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
|
|
805 |
}
|
806 |
|
807 |
}
|
808 |
-
|
809 |
/**
|
810 |
* wpsc_update_product_meta function
|
811 |
*
|
@@ -846,9 +849,9 @@ function wpsc_update_custom_meta($product_id, $post_data) {
|
|
846 |
}
|
847 |
}
|
848 |
}
|
849 |
-
|
850 |
if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
|
851 |
-
if($post_data['custom_meta'] != null) {
|
852 |
foreach((array)$post_data['custom_meta'] as $key => $values) {
|
853 |
if(($values['name'] != '') && ($values['value'] != '')) {
|
854 |
update_post_meta($product_id, $values['name'], $values['value']);
|
@@ -858,10 +861,10 @@ function wpsc_update_custom_meta($product_id, $post_data) {
|
|
858 |
}
|
859 |
|
860 |
/**
|
861 |
-
* wpsc_item_process_file function
|
862 |
*
|
863 |
* @param integer product ID
|
864 |
-
* @param array the file array from $_FILES
|
865 |
* @param array the preview file array from $_FILES
|
866 |
*/
|
867 |
function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
|
@@ -896,7 +899,7 @@ function wpsc_item_process_file($product_id, $submitted_file, $preview_file = nu
|
|
896 |
'post_title' => $title,
|
897 |
'post_content' => $content,
|
898 |
'post_type' => "wpsc-product-file",
|
899 |
-
'post_status' => 'inherit'
|
900 |
);
|
901 |
|
902 |
// Save the data
|
@@ -912,20 +915,20 @@ function wpsc_modify_upload_directory($input) {
|
|
912 |
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
913 |
return $input;
|
914 |
}
|
915 |
-
|
916 |
function wpsc_modify_preview_directory($input) {
|
917 |
$previous_subdir = $input['subdir'];
|
918 |
$download_subdir = str_replace($input['basedir'], '', WPSC_PREVIEW_DIR);
|
919 |
-
|
920 |
$input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
|
921 |
$input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
|
922 |
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
923 |
-
|
924 |
return $input;
|
925 |
}
|
926 |
-
|
927 |
/**
|
928 |
-
* wpsc_item_reassign_file function
|
929 |
*
|
930 |
* @param integer product ID
|
931 |
* @param string the selected file name;
|
@@ -935,37 +938,37 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
|
|
935 |
$product_file_list = array();
|
936 |
// initialise $idhash to null to prevent issues with undefined variables and error logs
|
937 |
$idhash = null;
|
938 |
-
|
939 |
$args = array(
|
940 |
'post_type' => 'wpsc-product-file',
|
941 |
'post_parent' => $product_id,
|
942 |
'numberposts' => -1,
|
943 |
'post_status' => 'any'
|
944 |
);
|
945 |
-
|
946 |
$attached_files = (array)get_posts($args);
|
947 |
-
|
948 |
foreach($attached_files as $key => $attached_file) {
|
949 |
$attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
|
950 |
}
|
951 |
-
|
952 |
-
/* if we are editing, grab the current file and ID hash */
|
953 |
if(!$selected_files) {
|
954 |
// unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
|
955 |
return null;
|
956 |
}
|
957 |
-
|
958 |
-
|
959 |
|
960 |
foreach($selected_files as $selected_file) {
|
961 |
// if we already use this file, there is no point doing anything more.
|
962 |
-
$file_is_attached = false;
|
963 |
$selected_file_path = WPSC_FILE_DIR.basename($selected_file);
|
964 |
-
|
965 |
if(isset($attached_files_by_file[$selected_file])) {
|
966 |
$file_is_attached = true;
|
967 |
}
|
968 |
-
|
969 |
if($file_is_attached == false ) {
|
970 |
$type = wpsc_get_mimetype($selected_file_path);
|
971 |
$attachment = array(
|
@@ -982,11 +985,11 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
|
|
982 |
'ID' => $attached_files_by_file[$selected_file]->ID,
|
983 |
'post_status' => 'inherit'
|
984 |
);
|
985 |
-
wp_update_post($product_post_values);
|
986 |
}
|
987 |
}
|
988 |
-
|
989 |
-
|
990 |
foreach($attached_files as $attached_file) {
|
991 |
if(!in_array($attached_file->post_title, $selected_files)) {
|
992 |
$product_post_values = array(
|
@@ -1001,11 +1004,11 @@ function wpsc_item_reassign_file($product_id, $selected_files) {
|
|
1001 |
}
|
1002 |
|
1003 |
/**
|
1004 |
-
* wpsc_delete_preview_file
|
1005 |
*
|
1006 |
* @param integer product ID
|
1007 |
*/
|
1008 |
-
|
1009 |
function wpsc_delete_preview_file($product_id) {
|
1010 |
|
1011 |
$args = array(
|
@@ -1014,9 +1017,9 @@ function wpsc_delete_preview_file($product_id) {
|
|
1014 |
'numberposts' => -1,
|
1015 |
'post_status' => 'all'
|
1016 |
);
|
1017 |
-
|
1018 |
$preview_files = (array)get_posts( $args );
|
1019 |
-
|
1020 |
foreach( $preview_files as $preview ) {
|
1021 |
$preview_id = $preview->ID;
|
1022 |
wp_delete_post($preview_id);
|
@@ -1025,16 +1028,16 @@ function wpsc_delete_preview_file($product_id) {
|
|
1025 |
}
|
1026 |
|
1027 |
/**
|
1028 |
-
* wpsc_item_add_preview_file function
|
1029 |
*
|
1030 |
* @param integer product ID
|
1031 |
* @param array the preview file array from $_FILES
|
1032 |
*/
|
1033 |
function wpsc_item_add_preview_file($product_id, $preview_file) {
|
1034 |
global $wpdb;
|
1035 |
-
|
1036 |
wpsc_delete_preview_file($product_id);
|
1037 |
-
|
1038 |
add_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1039 |
$overrides = array('test_form'=>false);
|
1040 |
|
@@ -1066,14 +1069,14 @@ function wpsc_item_add_preview_file($product_id, $preview_file) {
|
|
1066 |
'post_title' => $title,
|
1067 |
'post_content' => $content,
|
1068 |
'post_type' => "wpsc-preview-file",
|
1069 |
-
'post_status' => 'inherit'
|
1070 |
);
|
1071 |
|
1072 |
// Save the data
|
1073 |
$id = wp_insert_post($attachment, $file, $product_id);
|
1074 |
remove_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1075 |
return $id;
|
1076 |
-
|
1077 |
|
1078 |
}
|
1079 |
|
@@ -1088,8 +1091,8 @@ class wpsc_variation_combinator {
|
|
1088 |
var $variation_sets = array();
|
1089 |
var $variation_values = array();
|
1090 |
var $reprocessed_array = array();
|
1091 |
-
var $combinations= array();
|
1092 |
-
|
1093 |
function wpsc_variation_combinator($variation_sets) {
|
1094 |
if( $variation_sets ) {
|
1095 |
foreach($variation_sets as $variation_set_id => $variation_set) {
|
@@ -1108,49 +1111,49 @@ function wpsc_variation_combinator($variation_sets) {
|
|
1108 |
$this->get_combinations(array(), $this->reprocessed_array, 0);
|
1109 |
}
|
1110 |
}
|
1111 |
-
|
1112 |
-
|
1113 |
function get_combinations($batch, $elements, $i) {
|
1114 |
if ($i >= count($elements)) {
|
1115 |
$this->combinations[] = $batch;
|
1116 |
-
} else {
|
1117 |
foreach ($elements[$i] as $element) {
|
1118 |
$this->get_combinations(array_merge($batch, $element), $elements, $i + 1);
|
1119 |
-
}
|
1120 |
-
}
|
1121 |
}
|
1122 |
-
|
1123 |
function return_variation_sets() {
|
1124 |
return $this->variation_sets;
|
1125 |
}
|
1126 |
-
|
1127 |
function return_variation_values() {
|
1128 |
return $this->variation_values;
|
1129 |
}
|
1130 |
-
|
1131 |
function return_combinations() {
|
1132 |
return $this->combinations;
|
1133 |
-
|
1134 |
}
|
1135 |
-
}
|
1136 |
|
1137 |
function wpsc_variations_stock_remaining($product_id){
|
1138 |
global $wpdb;
|
1139 |
-
return $wpdb->get_var('
|
1140 |
-
SELECT
|
1141 |
-
sum(`pm`.`meta_value`)
|
1142 |
-
FROM
|
1143 |
-
`' . $wpdb->postmeta . '` `pm`
|
1144 |
-
JOIN
|
1145 |
-
`' . $wpdb->posts . '` `p`
|
1146 |
-
ON
|
1147 |
-
`pm`.`post_id` = `p`.`id`
|
1148 |
-
WHERE
|
1149 |
`p`.`post_type`= "wpsc-product"
|
1150 |
AND
|
1151 |
-
`p`.`post_parent` =
|
1152 |
AND
|
1153 |
`pm`.`meta_key` = "_wpsc_stock"
|
1154 |
-
');
|
1155 |
}
|
1156 |
?>
|
15 |
|
16 |
|
17 |
/**
|
18 |
+
* wpsc_product_has_children function
|
19 |
* Checks whether a product has variations or not
|
20 |
*
|
21 |
* @return boolean true if product does have variations, false otherwise
|
25 |
'post_parent' => $id,
|
26 |
'post_type' => 'wpsc-product',
|
27 |
'post_status' => 'inherit publish'
|
28 |
+
);
|
29 |
$children = get_children($args);
|
30 |
if( empty($children) )
|
31 |
return false;
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
+
* wpsc_admin_submit_product function
|
38 |
* @internal Was going to completely refactor sanitise forms and wpsc_insert_product, but they are also used by the import system
|
39 |
+
* which I'm not really familiar with...so I'm not touching them :) Erring on the side of redundancy and caution I'll just
|
40 |
* refactor this to do the job.
|
41 |
* @return nothing
|
42 |
*/
|
72 |
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
73 |
if(!isset($post_data['special'])) $post_data['special'] = '';
|
74 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
|
75 |
+
|
76 |
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
77 |
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
78 |
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
79 |
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
|
80 |
+
|
81 |
// Product Weight
|
82 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
83 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
84 |
+
|
85 |
$weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
86 |
$post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
|
87 |
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
88 |
+
|
89 |
// table rate price
|
90 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
|
91 |
+
|
92 |
// if table_rate_price is unticked, wipe the table rate prices
|
93 |
if ( empty( $post_data['table_rate_price']['state'] ) ) {
|
94 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
|
95 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
|
96 |
}
|
97 |
+
|
98 |
if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
|
99 |
foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ){
|
100 |
if(empty($value)){
|
101 |
+
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
|
102 |
+
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
|
103 |
+
}
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
|
108 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
|
109 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
|
110 |
+
|
111 |
+
|
112 |
// Advanced Options
|
113 |
+
$post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
|
114 |
$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
|
115 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
|
116 |
$post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
|
117 |
+
|
118 |
$post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
|
119 |
$post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
|
120 |
+
|
121 |
$post_data['files'] = $_FILES;
|
122 |
|
123 |
if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
|
158 |
}
|
159 |
}
|
160 |
// if we succeed, we can do further editing (todo - if_wp_error)
|
161 |
+
|
162 |
// if we have no categories selected, assign one.
|
163 |
if( isset( $post_data['tax_input']['wpsc_product_category'] ) && count( $post_data['tax_input']['wpsc_product_category'] ) == 1 && $post_data['tax_input']['wpsc_product_category'][0] == 0){
|
164 |
$post_data['tax_input']['wpsc_product_category'][1] = wpsc_add_product_category_default($product_id);
|
165 |
+
|
166 |
}
|
167 |
// and the meta
|
168 |
wpsc_update_product_meta($product_id, $post_data['meta']);
|
235 |
global $post;
|
236 |
if ( ! $post->post_parent )
|
237 |
return;
|
238 |
+
|
239 |
remove_meta_box( 'wpsc_product_categorydiv', 'wpsc-product', 'side' );
|
240 |
}
|
241 |
add_action( 'add_meta_boxes_wpsc-product', 'wpsc_variation_remove_metaboxes', 99 );
|
242 |
|
243 |
function wpsc_admin_submit_notices() {
|
244 |
global $current_screen, $post;
|
245 |
+
|
246 |
if( $current_screen->id != 'wpsc-product' || !isset( $_SESSION['product_error_messages'] ) )
|
247 |
return;
|
248 |
foreach ( $_SESSION['product_error_messages'] as $error )
|
249 |
echo "<div id=\"message\" class=\"updated below-h2\"><p>".$error."</p></div>";
|
250 |
unset( $_SESSION['product_error_messages'] );
|
251 |
}
|
252 |
+
|
253 |
/**
|
254 |
* wpsc_add_product_category_default, if there is no category assigned assign first product category as default
|
255 |
*
|
256 |
* @since 3.8
|
257 |
* @param $product_id (int) the Post ID
|
258 |
* @return null
|
259 |
+
*/
|
260 |
function wpsc_add_product_category_default( $product_id ){
|
261 |
$terms = get_terms( 'wpsc_product_category', array( 'orderby' => 'id', 'hide_empty' => 0 ) );
|
262 |
if ( ! empty( $terms ) ) {
|
265 |
}
|
266 |
}
|
267 |
/**
|
268 |
+
* wpsc_sanitise_product_forms function
|
269 |
+
*
|
270 |
* @return array - Sanitised product details
|
271 |
*/
|
272 |
function wpsc_sanitise_product_forms($post_data = null) {
|
273 |
if ( empty($post_data) ) {
|
274 |
$post_data = &$_POST;
|
275 |
}
|
276 |
+
|
277 |
$product = get_post(absint($post_data['post_ID']));
|
278 |
+
|
279 |
$post_data['name'] = isset($post_data['post_title']) ? $post_data['post_title'] : '';
|
280 |
$post_data['title'] = $post_data['name'];
|
281 |
$post_data['description'] = isset($post_data['content']) ? $post_data['content'] : '';
|
286 |
} else {
|
287 |
$post_data['post_status'] = 'draft';
|
288 |
}
|
289 |
+
|
290 |
if(isset($post_data['save']) && $product->post_status == 'inherit' && ( $product->post_parent == 0 || $product->post_parent == $product->ID ) ) {
|
291 |
$post_data['post_status'] = 'draft';
|
292 |
} else if(isset($post_data['publish'])) {
|
293 |
+
$post_data['post_status'] = 'publish';
|
294 |
} else if(isset($post_data['unpublish'])) {
|
295 |
$post_data['post_status'] = 'draft';
|
296 |
}
|
298 |
|
299 |
|
300 |
$post_meta['meta'] = (array)$_POST['meta'];
|
301 |
+
|
302 |
$post_data['meta']['_wpsc_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_price'] );
|
303 |
$post_data['meta']['_wpsc_special_price'] = (float)str_replace( ',','',$post_data['meta']['_wpsc_special_price'] );
|
304 |
$post_data['meta']['_wpsc_sku'] = $post_data['meta']['_wpsc_sku'];
|
315 |
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
316 |
if(!isset($post_data['special'])) $post_data['special'] = '';
|
317 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
|
318 |
+
|
319 |
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
320 |
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
321 |
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
322 |
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
|
323 |
+
|
324 |
// Product Weight
|
325 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
326 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
327 |
+
|
328 |
$weight = wpsc_convert_weight($post_data['meta']['_wpsc_product_metadata']['weight'], $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
329 |
$post_data['meta']['_wpsc_product_metadata']['weight'] = (float)$weight;
|
330 |
+
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
331 |
+
|
332 |
// table rate price
|
333 |
$post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = $post_data['table_rate_price'];
|
334 |
// if table_rate_price is unticked, wipe the table rate prices
|
339 |
}
|
340 |
foreach((array)$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value){
|
341 |
if(empty($value)){
|
342 |
+
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][$key]);
|
343 |
+
unset($post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][$key]);
|
344 |
+
}
|
345 |
}
|
346 |
|
347 |
+
|
348 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['local'];
|
349 |
$post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = (float)$post_data['meta']['_wpsc_product_metadata']['shipping']['international'];
|
350 |
+
|
351 |
+
|
352 |
// Advanced Options
|
353 |
+
$post_data['meta']['_wpsc_product_metadata']['engraved'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['engraved'];
|
354 |
$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'];
|
355 |
if(!isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
|
356 |
$post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
|
357 |
$post_data['meta']['_wpsc_product_metadata']['external_link'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link'];
|
358 |
$post_data['meta']['_wpsc_product_metadata']['external_link_text'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_text'];
|
359 |
$post_data['meta']['_wpsc_product_metadata']['external_link_target'] = (string)$post_data['meta']['_wpsc_product_metadata']['external_link_target'];
|
360 |
+
|
361 |
$post_data['meta']['_wpsc_product_metadata']['enable_comments'] = $post_data['meta']['_wpsc_product_metadata']['enable_comments'];
|
362 |
$post_data['meta']['_wpsc_product_metadata']['merchant_notes'] = $post_data['meta']['_wpsc_product_metadata']['merchant_notes'];
|
363 |
+
|
364 |
$post_data['files'] = $_FILES;
|
365 |
return $post_data;
|
366 |
}
|
367 |
+
|
368 |
/**
|
369 |
+
* wpsc_insert_product function
|
370 |
*
|
371 |
+
* @param unknown
|
372 |
* @return unknown
|
373 |
+
*/
|
374 |
function wpsc_insert_product($post_data, $wpsc_error = false) {
|
375 |
global $wpdb, $user_ID;
|
376 |
$adding = false;
|
382 |
$product_id = absint($post_data['product_id']);
|
383 |
$update = true;
|
384 |
}
|
385 |
+
|
386 |
$product_columns = array(
|
387 |
'name' => '',
|
388 |
'description' => '',
|
407 |
'thumbnail_image' => null,
|
408 |
'thumbnail_state' => null
|
409 |
);
|
410 |
+
|
411 |
+
|
412 |
+
foreach($product_columns as $column => $default)
|
413 |
{
|
414 |
+
if (!isset($post_data[$column])) $post_data[$column] = '';
|
415 |
+
|
416 |
if($post_data[$column] !== null) {
|
417 |
$update_values[$column] = stripslashes($post_data[$column]);
|
418 |
} else if(($update != true) && ($default !== null)) {
|
419 |
$update_values[$column] = stripslashes($default);
|
420 |
}
|
421 |
}
|
422 |
+
|
423 |
$product_post_values = array(
|
424 |
'ID' => $product_id,
|
425 |
'post_author' => $user_ID,
|
435 |
}else {
|
436 |
$product_post_values["comment_status"] = "open";
|
437 |
}
|
438 |
+
|
439 |
if(isset($sku) && ($sku != '')) {
|
440 |
$product_post_array['guid'] = $sku;
|
441 |
}
|
442 |
|
443 |
|
444 |
+
|
445 |
if($update === true) {
|
446 |
$where = array( 'id' => $product_id );
|
447 |
$product_id = wp_update_post($product_post_values);
|
456 |
} else {
|
457 |
return false;
|
458 |
}
|
459 |
+
}
|
460 |
} else {
|
461 |
$product_post_values += array(
|
462 |
'post_date' => $product['date_added']
|
476 |
}
|
477 |
$adding = true;
|
478 |
}
|
479 |
+
|
480 |
// if we succeed, we can do further editing
|
481 |
+
|
482 |
// and the meta
|
483 |
wpsc_update_product_meta($product_id, $post_data['meta']);
|
484 |
+
|
485 |
// and the custom meta
|
486 |
wpsc_update_custom_meta($product_id, $post_data);
|
487 |
+
|
488 |
//and the alt currency
|
489 |
foreach((array)$post_data['newCurrency'] as $key =>$value){
|
490 |
wpsc_update_alt_product_currency($product_id, $value, $post_data['newCurrPrice'][$key]);
|
496 |
if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
|
497 |
wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
|
498 |
}
|
499 |
+
|
500 |
if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
|
501 |
wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
|
502 |
}
|
506 |
}
|
507 |
|
508 |
/**
|
509 |
+
* term_id_price function
|
510 |
* Retreives associated price, if any, with term_id
|
511 |
* @param integer term ID
|
512 |
* @param integer parent product price
|
516 |
function term_id_price($term_id, $parent_price) {
|
517 |
|
518 |
$term_price_arr = get_option( 'term_prices' );
|
519 |
+
|
520 |
if ( isset($term_price_arr[$term_id]) ) {
|
521 |
+
$price = $term_price_arr[$term_id]["price"];
|
522 |
} else {
|
523 |
$price = 0;
|
524 |
}
|
525 |
+
|
526 |
//Check for flat, percentile or differential
|
527 |
$var_price_type = '';
|
528 |
+
|
529 |
if (flat_price($price)) {
|
530 |
$var_price_type = 'flat';
|
531 |
$price = floatval($price);
|
534 |
} elseif (percentile_price($price)) {
|
535 |
$var_price_type = 'percentile';
|
536 |
}
|
537 |
+
|
538 |
if (strchr($price, '-') ) {
|
539 |
$negative = true;
|
540 |
} else {
|
541 |
$positive = true;
|
542 |
}
|
543 |
+
|
544 |
if ($positive) {
|
545 |
+
|
546 |
if ( $var_price_type == 'differential' ) {
|
547 |
$differential = (floatval($price));
|
548 |
$price = $parent_price + $differential;
|
550 |
$percentage = (floatval($price) / 100);
|
551 |
$price = $parent_price + ($parent_price * $percentage);
|
552 |
}
|
553 |
+
|
554 |
} else {
|
555 |
|
556 |
+
if ( $var_price_type == 'differential' ) {
|
557 |
$differential = (floatval($price));
|
558 |
$price = $parent_price - $differential;
|
559 |
} elseif ( $var_price_type == 'percentile' ) {
|
578 |
function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
579 |
$flat = array();
|
580 |
$diff = 0;
|
581 |
+
|
582 |
$variation = get_post( $variation_id );
|
583 |
$price = (float) get_product_meta( $variation->post_parent, 'price', true );
|
584 |
+
|
585 |
if ( ! $term_ids )
|
586 |
$term_ids = wp_get_object_terms( $variation_id, 'wpsc-variation', array( 'fields' => 'ids' ) );
|
587 |
|
590 |
if ( isset( $term_price_arr[$term_id] ) )
|
591 |
$term_price = trim( $term_price_arr[$term_id]['price'] );
|
592 |
else
|
593 |
+
continue;
|
594 |
if ( flat_price( $term_price ) ) {
|
595 |
$flat[] = $term_price;
|
596 |
} elseif ( differential_price( $term_price ) ) {
|
608 |
|
609 |
/**
|
610 |
* wpsc_edit_product_variations function.
|
611 |
+
* this is the function to make child products using variations
|
612 |
*
|
613 |
* @access public
|
614 |
* @param mixed $product_id
|
616 |
* @return void
|
617 |
*/
|
618 |
function wpsc_edit_product_variations($product_id, $post_data) {
|
619 |
+
global $user_ID;
|
620 |
+
|
621 |
+
$parent = get_post_field( 'post_parent', $product_id );
|
622 |
+
|
623 |
+
if( ! empty( $parent ) )
|
624 |
return;
|
625 |
+
|
626 |
$variations = array();
|
627 |
$product_children = array();
|
628 |
if (!isset($post_data['edit_var_val']))
|
629 |
$post_data['edit_var_val'] = '';
|
630 |
+
|
631 |
$variations = (array)$post_data['edit_var_val'];
|
632 |
|
633 |
// Generate the arrays for variation sets, values and combinations
|
634 |
$wpsc_combinator = new wpsc_variation_combinator($variations);
|
635 |
+
|
636 |
// Retrieve the array containing the variation set IDs
|
637 |
$variation_sets = $wpsc_combinator->return_variation_sets();
|
638 |
+
|
639 |
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
640 |
$variation_values = $wpsc_combinator->return_variation_values();
|
641 |
+
|
642 |
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
643 |
$combinations = $wpsc_combinator->return_combinations();
|
644 |
+
|
645 |
$product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
|
646 |
+
|
647 |
$variation_sets_and_values = array_merge($variation_sets, $variation_values);
|
648 |
+
$variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
|
649 |
+
wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
|
650 |
+
|
651 |
$child_product_template = array(
|
652 |
'post_author' => $user_ID,
|
653 |
'post_content' => $post_data['description'],
|
658 |
'post_name' => sanitize_title($post_data['name']),
|
659 |
'post_parent' => $product_id
|
660 |
);
|
661 |
+
|
662 |
$child_product_meta = get_post_custom($product_id);
|
663 |
+
|
664 |
// here we loop through the combinations, get the term data and generate custom product names
|
665 |
foreach($combinations as $combination) {
|
666 |
$term_names = array();
|
673 |
'include' => implode(",", $combination),
|
674 |
'orderby' => 'parent',
|
675 |
));
|
676 |
+
|
677 |
foreach($combination_terms as $term) {
|
678 |
$term_ids[] = $term->term_id;
|
679 |
$term_slugs[] = $term->slug;
|
696 |
if($child_product_id == false) {
|
697 |
$already_a_variation = false;
|
698 |
if($selected_post != null) {
|
699 |
+
$child_product_id = $selected_post->ID;
|
700 |
} else {
|
701 |
+
$child_product_id = wp_insert_post($product_values);
|
702 |
}
|
703 |
} else {
|
704 |
// sometimes there have been problems saving the variations, this gets the correct product ID
|
719 |
} else {
|
720 |
update_post_meta($child_product_id, $meta_key, $meta_value[0]);
|
721 |
}
|
722 |
+
|
723 |
endforeach;
|
724 |
+
|
725 |
if ( is_array( $term_ids ) && $price = wpsc_determine_variation_price( $child_product_id, $term_ids ) )
|
726 |
update_product_meta( $child_product_id, 'price', $price );
|
727 |
}
|
728 |
}
|
|
|
729 |
|
730 |
+
|
731 |
+
//For reasons unknown, this code did not previously deal with variation deletions.
|
732 |
//Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
|
733 |
//Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
|
734 |
$posted_term = $variations;
|
738 |
foreach ($currently_associated_var as $current) {
|
739 |
$currently_associated_vars[] = $current->term_id;
|
740 |
}
|
741 |
+
|
742 |
foreach ($posted_term as $term=>$val) {
|
743 |
$posted_terms[] = $term;
|
744 |
if(is_array($val)) {
|
745 |
foreach($val as $term2=>$val2) {
|
746 |
+
$posted_terms[] = $term2;
|
747 |
}
|
748 |
}
|
749 |
}
|
750 |
+
if(!empty($currently_associated_vars)){
|
751 |
+
$term_ids_to_delete = array();
|
752 |
$term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
|
753 |
}
|
754 |
if(isset($_REQUEST["post_ID"]))
|
757 |
$post_id = $_REQUEST["product_id"];
|
758 |
if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
|
759 |
$post_ids_to_delete = array();
|
760 |
+
|
761 |
// Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
|
762 |
$post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
|
763 |
+
|
764 |
if(is_array($post_ids_to_delete) && !empty($post_ids_to_delete)) {
|
765 |
foreach($post_ids_to_delete as $object_ids) {
|
766 |
foreach($object_ids as $object_id) {
|
768 |
}
|
769 |
}
|
770 |
}
|
771 |
+
}
|
772 |
$current_children = query_posts(array(
|
773 |
'post_parent' => $post_id,
|
774 |
'post_type' => "wpsc-product",
|
780 |
}
|
781 |
if(!empty($childs)){
|
782 |
$old_ids_to_delete = array_diff($childs, $product_children);
|
783 |
+
$old_ids_to_delete = apply_filters('wpsc_edit_product_variations_deletion', $old_ids_to_delete);
|
784 |
if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
|
785 |
foreach($old_ids_to_delete as $object_ids) {
|
786 |
wp_delete_post($object_ids);
|
791 |
|
792 |
function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
|
793 |
global $wpdb;
|
794 |
+
|
795 |
$old_curr = get_product_meta($product_id, 'currency',true);
|
796 |
+
$sql = $wpdb->prepare( "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d", $newCurrency );
|
797 |
$isocode = $wpdb->get_var($sql);
|
798 |
+
|
799 |
$newCurrency = 'currency';
|
800 |
$old_curr[$isocode] = $newPrice;
|
801 |
if(($newPrice != '') && ($newPrice > 0.00)){
|
808 |
}
|
809 |
|
810 |
}
|
811 |
+
|
812 |
/**
|
813 |
* wpsc_update_product_meta function
|
814 |
*
|
849 |
}
|
850 |
}
|
851 |
}
|
852 |
+
|
853 |
if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
|
854 |
+
if($post_data['custom_meta'] != null) {
|
855 |
foreach((array)$post_data['custom_meta'] as $key => $values) {
|
856 |
if(($values['name'] != '') && ($values['value'] != '')) {
|
857 |
update_post_meta($product_id, $values['name'], $values['value']);
|
861 |
}
|
862 |
|
863 |
/**
|
864 |
+
* wpsc_item_process_file function
|
865 |
*
|
866 |
* @param integer product ID
|
867 |
+
* @param array the file array from $_FILES
|
868 |
* @param array the preview file array from $_FILES
|
869 |
*/
|
870 |
function wpsc_item_process_file($product_id, $submitted_file, $preview_file = null) {
|
899 |
'post_title' => $title,
|
900 |
'post_content' => $content,
|
901 |
'post_type' => "wpsc-product-file",
|
902 |
+
'post_status' => 'inherit'
|
903 |
);
|
904 |
|
905 |
// Save the data
|
915 |
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
916 |
return $input;
|
917 |
}
|
918 |
+
|
919 |
function wpsc_modify_preview_directory($input) {
|
920 |
$previous_subdir = $input['subdir'];
|
921 |
$download_subdir = str_replace($input['basedir'], '', WPSC_PREVIEW_DIR);
|
922 |
+
|
923 |
$input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
|
924 |
$input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
|
925 |
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
926 |
+
|
927 |
return $input;
|
928 |
}
|
929 |
+
|
930 |
/**
|
931 |
+
* wpsc_item_reassign_file function
|
932 |
*
|
933 |
* @param integer product ID
|
934 |
* @param string the selected file name;
|
938 |
$product_file_list = array();
|
939 |
// initialise $idhash to null to prevent issues with undefined variables and error logs
|
940 |
$idhash = null;
|
941 |
+
|
942 |
$args = array(
|
943 |
'post_type' => 'wpsc-product-file',
|
944 |
'post_parent' => $product_id,
|
945 |
'numberposts' => -1,
|
946 |
'post_status' => 'any'
|
947 |
);
|
948 |
+
|
949 |
$attached_files = (array)get_posts($args);
|
950 |
+
|
951 |
foreach($attached_files as $key => $attached_file) {
|
952 |
$attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
|
953 |
}
|
954 |
+
|
955 |
+
/* if we are editing, grab the current file and ID hash */
|
956 |
if(!$selected_files) {
|
957 |
// unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
|
958 |
return null;
|
959 |
}
|
960 |
+
|
961 |
+
|
962 |
|
963 |
foreach($selected_files as $selected_file) {
|
964 |
// if we already use this file, there is no point doing anything more.
|
965 |
+
$file_is_attached = false;
|
966 |
$selected_file_path = WPSC_FILE_DIR.basename($selected_file);
|
967 |
+
|
968 |
if(isset($attached_files_by_file[$selected_file])) {
|
969 |
$file_is_attached = true;
|
970 |
}
|
971 |
+
|
972 |
if($file_is_attached == false ) {
|
973 |
$type = wpsc_get_mimetype($selected_file_path);
|
974 |
$attachment = array(
|
985 |
'ID' => $attached_files_by_file[$selected_file]->ID,
|
986 |
'post_status' => 'inherit'
|
987 |
);
|
988 |
+
wp_update_post($product_post_values);
|
989 |
}
|
990 |
}
|
991 |
+
|
992 |
+
|
993 |
foreach($attached_files as $attached_file) {
|
994 |
if(!in_array($attached_file->post_title, $selected_files)) {
|
995 |
$product_post_values = array(
|
1004 |
}
|
1005 |
|
1006 |
/**
|
1007 |
+
* wpsc_delete_preview_file
|
1008 |
*
|
1009 |
* @param integer product ID
|
1010 |
*/
|
1011 |
+
|
1012 |
function wpsc_delete_preview_file($product_id) {
|
1013 |
|
1014 |
$args = array(
|
1017 |
'numberposts' => -1,
|
1018 |
'post_status' => 'all'
|
1019 |
);
|
1020 |
+
|
1021 |
$preview_files = (array)get_posts( $args );
|
1022 |
+
|
1023 |
foreach( $preview_files as $preview ) {
|
1024 |
$preview_id = $preview->ID;
|
1025 |
wp_delete_post($preview_id);
|
1028 |
}
|
1029 |
|
1030 |
/**
|
1031 |
+
* wpsc_item_add_preview_file function
|
1032 |
*
|
1033 |
* @param integer product ID
|
1034 |
* @param array the preview file array from $_FILES
|
1035 |
*/
|
1036 |
function wpsc_item_add_preview_file($product_id, $preview_file) {
|
1037 |
global $wpdb;
|
1038 |
+
|
1039 |
wpsc_delete_preview_file($product_id);
|
1040 |
+
|
1041 |
add_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1042 |
$overrides = array('test_form'=>false);
|
1043 |
|
1069 |
'post_title' => $title,
|
1070 |
'post_content' => $content,
|
1071 |
'post_type' => "wpsc-preview-file",
|
1072 |
+
'post_status' => 'inherit'
|
1073 |
);
|
1074 |
|
1075 |
// Save the data
|
1076 |
$id = wp_insert_post($attachment, $file, $product_id);
|
1077 |
remove_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1078 |
return $id;
|
1079 |
+
|
1080 |
|
1081 |
}
|
1082 |
|
1091 |
var $variation_sets = array();
|
1092 |
var $variation_values = array();
|
1093 |
var $reprocessed_array = array();
|
1094 |
+
var $combinations= array();
|
1095 |
+
|
1096 |
function wpsc_variation_combinator($variation_sets) {
|
1097 |
if( $variation_sets ) {
|
1098 |
foreach($variation_sets as $variation_set_id => $variation_set) {
|
1111 |
$this->get_combinations(array(), $this->reprocessed_array, 0);
|
1112 |
}
|
1113 |
}
|
1114 |
+
|
1115 |
+
|
1116 |
function get_combinations($batch, $elements, $i) {
|
1117 |
if ($i >= count($elements)) {
|
1118 |
$this->combinations[] = $batch;
|
1119 |
+
} else {
|
1120 |
foreach ($elements[$i] as $element) {
|
1121 |
$this->get_combinations(array_merge($batch, $element), $elements, $i + 1);
|
1122 |
+
}
|
1123 |
+
}
|
1124 |
}
|
1125 |
+
|
1126 |
function return_variation_sets() {
|
1127 |
return $this->variation_sets;
|
1128 |
}
|
1129 |
+
|
1130 |
function return_variation_values() {
|
1131 |
return $this->variation_values;
|
1132 |
}
|
1133 |
+
|
1134 |
function return_combinations() {
|
1135 |
return $this->combinations;
|
1136 |
+
|
1137 |
}
|
1138 |
+
}
|
1139 |
|
1140 |
function wpsc_variations_stock_remaining($product_id){
|
1141 |
global $wpdb;
|
1142 |
+
return $wpdb->get_var( $wpdb->prepare( '
|
1143 |
+
SELECT
|
1144 |
+
sum(`pm`.`meta_value`)
|
1145 |
+
FROM
|
1146 |
+
`' . $wpdb->postmeta . '` `pm`
|
1147 |
+
JOIN
|
1148 |
+
`' . $wpdb->posts . '` `p`
|
1149 |
+
ON
|
1150 |
+
`pm`.`post_id` = `p`.`id`
|
1151 |
+
WHERE
|
1152 |
`p`.`post_type`= "wpsc-product"
|
1153 |
AND
|
1154 |
+
`p`.`post_parent` = %d
|
1155 |
AND
|
1156 |
`pm`.`meta_key` = "_wpsc_stock"
|
1157 |
+
', $product_id ) );
|
1158 |
}
|
1159 |
?>
|
wpsc-admin/includes/products.php
CHANGED
@@ -14,20 +14,21 @@
|
|
14 |
*
|
15 |
*/
|
16 |
function wpsc_admin_product_listing($parent_product = null) {
|
17 |
-
global $wp_query
|
18 |
add_filter('the_title','esc_html');
|
19 |
$args = array_merge( $wp_query->query, array( 'posts_per_page' => '-1' ) );
|
20 |
-
$
|
21 |
-
if ( empty($wpsc_products) )
|
22 |
-
$wpsc_products = &$wpsc_temp_query;
|
23 |
|
24 |
-
foreach ( (array)$wpsc_products as $product ) {
|
25 |
wpsc_product_row($product, $parent_product);
|
26 |
}
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
* Adds the -trash status in the product row of manage products page
|
|
|
|
|
|
|
31 |
* @access public
|
32 |
*
|
33 |
* @since 3.8
|
@@ -41,7 +42,9 @@ function wpsc_trashed_post_status($post_status){
|
|
41 |
|
42 |
return $post_status;
|
43 |
}
|
44 |
-
|
|
|
|
|
45 |
|
46 |
/**
|
47 |
* Spits out the current products details in a table row for manage products page and variations on edit product page.
|
@@ -51,11 +54,23 @@ add_filter('display_post_states','wpsc_trashed_post_status');
|
|
51 |
* @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
|
52 |
*/
|
53 |
function wpsc_product_row(&$product, $parent_product = null) {
|
54 |
-
global $mode, $current_user;
|
55 |
-
|
56 |
//is this good practice? <v.bakaitis@gmail.com>
|
57 |
-
static $rowclass;
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
$global_product = $product;
|
60 |
setup_postdata($product);
|
61 |
$product_post_type_object = get_post_type_object('wpsc-product');
|
@@ -65,7 +80,12 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
65 |
$post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
|
66 |
$edit_link = get_edit_post_link( $product->ID );
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
if ( empty( $title ) )
|
71 |
$title = __('(no title)', 'wpsc');
|
@@ -75,16 +95,12 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
75 |
<tr id='post-<?php echo $product->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $product->post_status ); ?> iedit <?php if ( get_option ( 'wpsc_sort_by' ) == 'dragndrop') { echo 'product-edit'; } ?>' valign="top">
|
76 |
<?php
|
77 |
$posts_columns = get_column_headers( 'wpsc-product_variants' );
|
78 |
-
|
79 |
-
|
80 |
if(empty($posts_columns))
|
81 |
$posts_columns = array('image' => '', 'title' => __('Name', 'wpsc') , 'weight' => __('Weight', 'wpsc'), 'stock' => __('Stock', 'wpsc'), 'price' => __('Price', 'wpsc'), 'sale_price' => __('Sale Price', 'wpsc'), 'SKU' => __('SKU', 'wpsc'), 'hidden_alerts' => '');
|
82 |
|
83 |
foreach ( $posts_columns as $column_name=>$column_display_name ) {
|
84 |
$attributes = "class=\"$column_name column-$column_name\"";
|
85 |
-
|
86 |
-
if ( in_array( $column_name, $hidden_columns ) )
|
87 |
-
$attributes .= ' style="display:none;"';
|
88 |
|
89 |
switch ($column_name) {
|
90 |
|
@@ -126,17 +142,16 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
126 |
|
127 |
case 'title': /* !title case */
|
128 |
$attributes = 'class="post-title column-title"';
|
129 |
-
|
130 |
$edit_link = wp_nonce_url( $edit_link, 'edit-product_'.$product->ID );
|
131 |
?>
|
132 |
<td <?php echo $attributes ?>>
|
133 |
<strong>
|
134 |
<?php if ( $current_user_can_edit_this_product && $product->post_status != 'trash' ) { ?>
|
135 |
-
<a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”', 'wpsc'), $title)); ?>"><?php echo $title ?></a>
|
136 |
<?php if($parent_product): ?>
|
137 |
-
<
|
138 |
-
|
139 |
-
<div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php bloginfo('url') ?>/wp-admin/images/wpspin_light.gif" class="loading_indicator"><br/><input type="button" class="button-secondary cancel wpsc_ie_cancel" value="<?php _e('Cancel', 'wpsc'); ?>"></div>
|
140 |
<?php endif; ?>
|
141 |
<?php } else {
|
142 |
echo $title;
|
@@ -168,7 +183,8 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
168 |
$actions = array();
|
169 |
if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) {
|
170 |
$actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
|
171 |
-
|
|
|
172 |
}
|
173 |
|
174 |
$actions = apply_filters('post_row_actions', $actions, $product);
|
@@ -231,6 +247,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
231 |
<td <?php echo $attributes ?>>
|
232 |
<?php echo wpsc_currency_display( $price ); ?>
|
233 |
<input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php echo $price; ?>">
|
|
|
234 |
</td>
|
235 |
<?php
|
236 |
break;
|
@@ -255,6 +272,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
255 |
<td <?php echo $attributes ?>>
|
256 |
<span><?php echo $weight; ?></span>
|
257 |
<input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php echo $weight; ?>">
|
|
|
258 |
</td>
|
259 |
<?php
|
260 |
|
@@ -266,6 +284,7 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
266 |
<td <?php echo $attributes ?>>
|
267 |
<span><?php echo $stock ? $stock : __('N/A', 'wpsc') ; ?></span>
|
268 |
<input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php echo $stock; ?>">
|
|
|
269 |
</td>
|
270 |
<?php
|
271 |
break;
|
@@ -309,16 +328,18 @@ function wpsc_product_row(&$product, $parent_product = null) {
|
|
309 |
<td <?php echo $attributes ?>>
|
310 |
<span><?php echo $sku ? $sku : __('N/A', 'wpsc'); ?></span>
|
311 |
<input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php echo $sku; ?>">
|
|
|
|
|
312 |
</td>
|
313 |
<?php
|
314 |
break;
|
315 |
case 'sale_price':
|
316 |
|
317 |
-
$
|
318 |
?>
|
319 |
<td <?php echo $attributes ?>>
|
320 |
-
<span><?php echo wpsc_currency_display( $
|
321 |
-
<input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php echo $
|
322 |
</td>
|
323 |
<?php
|
324 |
|
14 |
*
|
15 |
*/
|
16 |
function wpsc_admin_product_listing($parent_product = null) {
|
17 |
+
global $wp_query;
|
18 |
add_filter('the_title','esc_html');
|
19 |
$args = array_merge( $wp_query->query, array( 'posts_per_page' => '-1' ) );
|
20 |
+
$GLOBALS['wpsc_products'] = query_posts( $args );
|
|
|
|
|
21 |
|
22 |
+
foreach ( (array)$GLOBALS['wpsc_products'] as $product ) {
|
23 |
wpsc_product_row($product, $parent_product);
|
24 |
}
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
* Adds the -trash status in the product row of manage products page
|
29 |
+
*
|
30 |
+
* Gary asks: Why do we need this?
|
31 |
+
*
|
32 |
* @access public
|
33 |
*
|
34 |
* @since 3.8
|
42 |
|
43 |
return $post_status;
|
44 |
}
|
45 |
+
|
46 |
+
// commenting this out because it seems unnecessary and producing PHP notices
|
47 |
+
// add_filter('display_post_states','wpsc_trashed_post_status');
|
48 |
|
49 |
/**
|
50 |
* Spits out the current products details in a table row for manage products page and variations on edit product page.
|
54 |
* @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused
|
55 |
*/
|
56 |
function wpsc_product_row(&$product, $parent_product = null) {
|
57 |
+
global $mode, $current_user, $wpsc_products;
|
58 |
+
|
59 |
//is this good practice? <v.bakaitis@gmail.com>
|
60 |
+
static $rowclass, $object_terms_cache = array();
|
61 |
+
|
62 |
+
// store terms associated with variants inside a cache array. This only requires 1 DB query.
|
63 |
+
if ( empty( $object_terms_cache ) ) {
|
64 |
+
$ids = wp_list_pluck( $wpsc_products, 'ID' );
|
65 |
+
$object_terms = wp_get_object_terms( $ids, 'wpsc-variation', array( 'fields' => 'all_with_object_id' ) );
|
66 |
+
foreach ( $object_terms as $term ) {
|
67 |
+
if ( ! array_key_exists( $term->object_id, $object_terms_cache ) )
|
68 |
+
$object_terms_cache[$term->object_id] = array();
|
69 |
+
|
70 |
+
$object_terms_cache[$term->object_id][$term->parent] = $term->name;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
$global_product = $product;
|
75 |
setup_postdata($product);
|
76 |
$product_post_type_object = get_post_type_object('wpsc-product');
|
80 |
$post_owner = ( $current_user->ID == $product->post_author ? 'self' : 'other' );
|
81 |
$edit_link = get_edit_post_link( $product->ID );
|
82 |
|
83 |
+
if ( isset( $object_terms_cache[$product->ID] ) ) {
|
84 |
+
ksort( $object_terms_cache[$product->ID] );
|
85 |
+
$title = implode( ', ', $object_terms_cache[$product->ID] );
|
86 |
+
} else {
|
87 |
+
$title = get_the_title( $product->ID );
|
88 |
+
}
|
89 |
|
90 |
if ( empty( $title ) )
|
91 |
$title = __('(no title)', 'wpsc');
|
95 |
<tr id='post-<?php echo $product->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $product->post_status ); ?> iedit <?php if ( get_option ( 'wpsc_sort_by' ) == 'dragndrop') { echo 'product-edit'; } ?>' valign="top">
|
96 |
<?php
|
97 |
$posts_columns = get_column_headers( 'wpsc-product_variants' );
|
98 |
+
|
|
|
99 |
if(empty($posts_columns))
|
100 |
$posts_columns = array('image' => '', 'title' => __('Name', 'wpsc') , 'weight' => __('Weight', 'wpsc'), 'stock' => __('Stock', 'wpsc'), 'price' => __('Price', 'wpsc'), 'sale_price' => __('Sale Price', 'wpsc'), 'SKU' => __('SKU', 'wpsc'), 'hidden_alerts' => '');
|
101 |
|
102 |
foreach ( $posts_columns as $column_name=>$column_display_name ) {
|
103 |
$attributes = "class=\"$column_name column-$column_name\"";
|
|
|
|
|
|
|
104 |
|
105 |
switch ($column_name) {
|
106 |
|
142 |
|
143 |
case 'title': /* !title case */
|
144 |
$attributes = 'class="post-title column-title"';
|
145 |
+
|
146 |
$edit_link = wp_nonce_url( $edit_link, 'edit-product_'.$product->ID );
|
147 |
?>
|
148 |
<td <?php echo $attributes ?>>
|
149 |
<strong>
|
150 |
<?php if ( $current_user_can_edit_this_product && $product->post_status != 'trash' ) { ?>
|
151 |
+
<span><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”', 'wpsc'), $title)); ?>"><?php echo $title ?></a></span>
|
152 |
<?php if($parent_product): ?>
|
153 |
+
<a href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”', 'wpsc'), $title)); ?>"><?php echo $title ?></a>
|
154 |
+
|
|
|
155 |
<?php endif; ?>
|
156 |
<?php } else {
|
157 |
echo $title;
|
183 |
$actions = array();
|
184 |
if ( $current_user_can_edit_this_product && 'trash' != $product->post_status ) {
|
185 |
$actions['edit'] = '<a class="edit-product" href="'.$edit_link.'" title="' . esc_attr(__('Edit this product', 'wpsc')) . '">'. __('Edit', 'wpsc') . '</a>';
|
186 |
+
//commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link.
|
187 |
+
//$actions['quick_edit'] = "<a class='wpsc_editinline ".$has_var."' title='".esc_attr(__('Quick Edit', 'wpsc'))."' href='#'>".__('Quick Edit', 'wpsc')."</a>";
|
188 |
}
|
189 |
|
190 |
$actions = apply_filters('post_row_actions', $actions, $product);
|
247 |
<td <?php echo $attributes ?>>
|
248 |
<?php echo wpsc_currency_display( $price ); ?>
|
249 |
<input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php echo $price; ?>">
|
250 |
+
<a href="<?php echo $edit_link?>/#wpsc_downloads">Variant Download Files</a>
|
251 |
</td>
|
252 |
<?php
|
253 |
break;
|
272 |
<td <?php echo $attributes ?>>
|
273 |
<span><?php echo $weight; ?></span>
|
274 |
<input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php echo $weight; ?>">
|
275 |
+
<a href="<?php echo $edit_link?>/#wpsc_tax">Set Variant Tax</a>
|
276 |
</td>
|
277 |
<?php
|
278 |
|
284 |
<td <?php echo $attributes ?>>
|
285 |
<span><?php echo $stock ? $stock : __('N/A', 'wpsc') ; ?></span>
|
286 |
<input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php echo $stock; ?>">
|
287 |
+
<a href="<?php echo $edit_link?>/#wpsc_shipping">Set Variant Shipping</a>
|
288 |
</td>
|
289 |
<?php
|
290 |
break;
|
328 |
<td <?php echo $attributes ?>>
|
329 |
<span><?php echo $sku ? $sku : __('N/A', 'wpsc'); ?></span>
|
330 |
<input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php echo $sku; ?>">
|
331 |
+
<input type="hidden" class="wpsc_ie_id wpsc_ie_field" value="<?php echo $product->ID ?>">
|
332 |
+
<div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php bloginfo('url') ?>/wp-admin/images/wpspin_light.gif" class="loading_indicator"><br/></div>
|
333 |
</td>
|
334 |
<?php
|
335 |
break;
|
336 |
case 'sale_price':
|
337 |
|
338 |
+
$sale_price = get_post_meta($product->ID, '_wpsc_special_price', true);
|
339 |
?>
|
340 |
<td <?php echo $attributes ?>>
|
341 |
+
<span><?php echo wpsc_currency_display( $sale_price ); ?></span>
|
342 |
+
<input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php echo $sale_price; ?>">
|
343 |
</td>
|
344 |
<?php
|
345 |
|
wpsc-admin/includes/purchase-log-list-table-class.php
ADDED
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* The WP_List_Table class isn't automatically available to plugins, so we need
|
3 |
+
* to check if it's available and load it if necessary.
|
4 |
+
*/
|
5 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
6 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
|
7 |
+
|
8 |
+
class WPSC_Purchase_Log_List_Table extends WP_List_Table
|
9 |
+
{
|
10 |
+
private $search_box = true;
|
11 |
+
private $bulk_actions = true;
|
12 |
+
private $sortable = true;
|
13 |
+
private $month_filter = true;
|
14 |
+
private $views = true;
|
15 |
+
private $per_page = 20;
|
16 |
+
|
17 |
+
public function __construct() {
|
18 |
+
WP_List_Table::__construct( array(
|
19 |
+
'plural' => 'purchase-logs',
|
20 |
+
) );
|
21 |
+
}
|
22 |
+
|
23 |
+
public function disable_sortable() {
|
24 |
+
$this->sortable = false;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function disable_search_box() {
|
28 |
+
$this->search_box = false;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function disable_bulk_actions() {
|
32 |
+
$this->bulk_actions = false;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function disable_month_filter() {
|
36 |
+
$this->month_filter = false;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function disable_views() {
|
40 |
+
$this->views = false;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function set_per_page( $per_page ) {
|
44 |
+
$this->per_page = (int) $per_page;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function prepare_items() {
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
$page = $this->get_pagenum();
|
51 |
+
$offset = ( $page - 1 ) * $this->per_page;
|
52 |
+
|
53 |
+
$checkout_fields_sql = "
|
54 |
+
SELECT id, unique_name FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE unique_name IN ('billingfirstname', 'billinglastname', 'billingemail')
|
55 |
+
";
|
56 |
+
$checkout_fields = $wpdb->get_results( $checkout_fields_sql );
|
57 |
+
|
58 |
+
$joins = array();
|
59 |
+
$where = array( '1 = 1' );
|
60 |
+
|
61 |
+
if ( isset( $_REQUEST['post'] ) )
|
62 |
+
$where[] = 'p.id IN (' . implode( ', ', $_REQUEST['post'] ) . ')';
|
63 |
+
|
64 |
+
$i = 1;
|
65 |
+
$selects = array( 'p.id', 'p.totalprice AS amount', 'p.processed AS status', 'p.track_id', 'p.date' );
|
66 |
+
$selects[] = '
|
67 |
+
(
|
68 |
+
SELECT COUNT(*) FROM ' . WPSC_TABLE_CART_CONTENTS . ' AS c
|
69 |
+
WHERE c.purchaseid = p.id
|
70 |
+
) AS item_count';
|
71 |
+
|
72 |
+
$search_terms = empty( $_REQUEST['s'] ) ? array() : explode( ' ', $_REQUEST['s'] );
|
73 |
+
$search_sql = array();
|
74 |
+
foreach ( $checkout_fields as $field ) {
|
75 |
+
$table_as = 's' . $i;
|
76 |
+
$select_as = str_replace('billing', '', $field->unique_name );
|
77 |
+
$selects[] = $table_as . '.value AS ' . $select_as;
|
78 |
+
$joins[] = $wpdb->prepare( "INNER JOIN " . WPSC_TABLE_SUBMITED_FORM_DATA . " AS {$table_as} ON {$table_as}.log_id = p.id AND {$table_as}.form_id = %d", $field->id );
|
79 |
+
|
80 |
+
// build search term queries for first name, last name, email
|
81 |
+
foreach ( $search_terms as $term ) {
|
82 |
+
$escaped_term = esc_sql( like_escape( $term ) );
|
83 |
+
if ( ! array_key_exists( $term, $search_sql ) )
|
84 |
+
$search_sql[$term] = array();
|
85 |
+
|
86 |
+
$search_sql[$term][] = $table_as . ".value LIKE '%" . $escaped_term . "%'";
|
87 |
+
}
|
88 |
+
|
89 |
+
$i++;
|
90 |
+
}
|
91 |
+
|
92 |
+
// combine query phrases into a single query string
|
93 |
+
foreach ( $search_terms as $term ) {
|
94 |
+
$search_sql[$term][] = "p.track_id = '" . esc_sql( $term ) . "'";
|
95 |
+
if ( is_numeric( $term ) )
|
96 |
+
$search_sql[$term][] = 'p.id = ' . esc_sql( $term );
|
97 |
+
$search_sql[$term] = '(' . implode( ' OR ', $search_sql[$term] ) . ')';
|
98 |
+
}
|
99 |
+
$search_sql = implode( ' AND ', array_values( $search_sql ) );
|
100 |
+
|
101 |
+
if ( $search_sql ) {
|
102 |
+
$where[] = $search_sql;
|
103 |
+
}
|
104 |
+
|
105 |
+
// filter by status
|
106 |
+
if ( ! empty( $_REQUEST['status'] ) ) {
|
107 |
+
$status = absint( $_REQUEST['status'] );
|
108 |
+
$where[] = 'processed = ' . $status;
|
109 |
+
}
|
110 |
+
|
111 |
+
// filter by month
|
112 |
+
if ( ! empty( $_REQUEST['m'] ) ) {
|
113 |
+
$year = (int) substr( $_REQUEST['m'], 0, 4);
|
114 |
+
$month = (int) substr( $_REQUEST['m'], -2 );
|
115 |
+
$where[] = "YEAR(FROM_UNIXTIME(date)) = " . esc_sql( $year );
|
116 |
+
$where[] = "MONTH(FROM_UNIXTIME(date)) = " . esc_sql( $month );
|
117 |
+
}
|
118 |
+
|
119 |
+
$selects = implode( ', ', $selects );
|
120 |
+
$joins = implode( ' ', $joins );
|
121 |
+
$where = implode( ' AND ', $where );
|
122 |
+
$limit = ( $this->per_page !== 0 ) ? "LIMIT {$offset}, {$this->per_page}" : '';
|
123 |
+
|
124 |
+
$orderby = empty( $_REQUEST['orderby'] ) ? 'p.id' : 'p.' . $_REQUEST['orderby'];
|
125 |
+
$order = empty( $_REQUEST['order'] ) ? 'DESC' : $_REQUEST['order'];
|
126 |
+
|
127 |
+
$orderby = esc_sql( $orderby );
|
128 |
+
$order = esc_sql( $order );
|
129 |
+
|
130 |
+
$submitted_data_log = WPSC_TABLE_SUBMITED_FORM_DATA;
|
131 |
+
$purchase_log_sql = "
|
132 |
+
SELECT SQL_CALC_FOUND_ROWS {$selects}
|
133 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
|
134 |
+
{$joins}
|
135 |
+
WHERE {$where}
|
136 |
+
ORDER BY {$orderby} {$order}
|
137 |
+
{$limit}
|
138 |
+
";
|
139 |
+
$this->items = $wpdb->get_results( $purchase_log_sql );
|
140 |
+
|
141 |
+
if ( $this->per_page ) {
|
142 |
+
$total_items = $wpdb->get_var( "SELECT FOUND_ROWS()" );
|
143 |
+
|
144 |
+
$this->set_pagination_args( array(
|
145 |
+
'total_items' => $total_items,
|
146 |
+
'per_page' => $this->per_page,
|
147 |
+
) );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
public function is_pagination_enabled() {
|
152 |
+
return $this->per_page !== 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
public function is_sortable() {
|
156 |
+
return $this->sortable;
|
157 |
+
}
|
158 |
+
|
159 |
+
public function is_views_enabled() {
|
160 |
+
return $this->views;
|
161 |
+
}
|
162 |
+
|
163 |
+
public function is_search_box_enabled() {
|
164 |
+
return $this->search_box;
|
165 |
+
}
|
166 |
+
|
167 |
+
public function get_columns() {
|
168 |
+
return array(
|
169 |
+
'cb' => '<input type="checkbox" />',
|
170 |
+
'id' => __( 'Order ID', 'wpsc' ),
|
171 |
+
'customer' => __( 'Customer', 'wpsc' ),
|
172 |
+
'amount' => __( 'Amount', 'wpsc' ),
|
173 |
+
'status' => _x( 'Status', 'sales log list table column', 'wpsc' ),
|
174 |
+
'date' => __( 'Date', 'wpsc' ),
|
175 |
+
'tracking' => __( 'Tracking ID', 'wpsc' ),
|
176 |
+
);
|
177 |
+
}
|
178 |
+
|
179 |
+
public function get_sortable_columns() {
|
180 |
+
if ( ! $this->sortable )
|
181 |
+
return array();
|
182 |
+
|
183 |
+
return array(
|
184 |
+
'date' => 'id',
|
185 |
+
'status' => 'processed',
|
186 |
+
'amount' => 'totalprice',
|
187 |
+
);
|
188 |
+
}
|
189 |
+
|
190 |
+
private function get_months() {
|
191 |
+
global $wpdb;
|
192 |
+
|
193 |
+
// "date" column is not indexed. Might be better to use transient just in case
|
194 |
+
// there are lots of logs
|
195 |
+
$today = getdate();
|
196 |
+
$transient_key = 'wpsc_purchase_logs_months_' . $today['year'] . $today['month'];
|
197 |
+
if ( $months = get_transient( $transient_key ) )
|
198 |
+
return $months;
|
199 |
+
|
200 |
+
$sql = "
|
201 |
+
SELECT DISTINCT YEAR(FROM_UNIXTIME(date)) AS year, MONTH(FROM_UNIXTIME(date)) AS month
|
202 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . "
|
203 |
+
ORDER BY date DESC
|
204 |
+
";
|
205 |
+
|
206 |
+
$months = $wpdb->get_results( $sql );
|
207 |
+
set_transient( $transient_key, $months, 60 * 24 * 7 );
|
208 |
+
return $months;
|
209 |
+
}
|
210 |
+
|
211 |
+
public function get_views() {
|
212 |
+
global $wpdb;
|
213 |
+
$view_labels = array(
|
214 |
+
1 => _nx_noop( 'Incomplete <span class="count">(%s)</span>', 'Incomplete <span class="count">(%s)</span>', 'purchase logs' ),
|
215 |
+
2 => _nx_noop( 'Received <span class="count">(%s)</span>', 'Received <span class="count">(%s)</span>', 'purchase logs' ),
|
216 |
+
3 => _nx_noop( 'Accepted <span class="count">(%s)</span>', 'Accepted <span class="count">(%s)</span>', 'purchase logs' ),
|
217 |
+
4 => _nx_noop( 'Dispatched <span class="count">(%s)</span>', 'Dispatched <span class="count">(%s)</span>', 'purchase logs' ),
|
218 |
+
5 => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'purchase logs' ),
|
219 |
+
6 => _nx_noop( 'Declined <span class="count">(%s)</span>', 'Declined <span class="count">(%s)</span>', 'purchase logs' ),
|
220 |
+
);
|
221 |
+
|
222 |
+
$sql = "SELECT DISTINCT processed, COUNT(*) AS count FROM " . WPSC_TABLE_PURCHASE_LOGS . " GROUP BY processed ORDER BY processed";
|
223 |
+
$results = $wpdb->get_results( $sql );
|
224 |
+
foreach ( $results as $status ) {
|
225 |
+
$statuses[$status->processed] = $status->count;
|
226 |
+
}
|
227 |
+
|
228 |
+
$total_count = array_sum( $statuses );
|
229 |
+
$all_text = sprintf(
|
230 |
+
_nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_count, 'purchase logs', 'wpsc' ),
|
231 |
+
number_format_i18n( $total_count )
|
232 |
+
);
|
233 |
+
$all_href = remove_query_arg( array(
|
234 |
+
'status',
|
235 |
+
'paged',
|
236 |
+
'action',
|
237 |
+
'action2',
|
238 |
+
'm',
|
239 |
+
'deleted',
|
240 |
+
'updated',
|
241 |
+
'paged',
|
242 |
+
's',
|
243 |
+
) );
|
244 |
+
$all_class = ( ( empty( $_REQUEST['status'] ) || $_REQUEST['status'] == 'all' ) && empty( $_REQUEST['m'] ) && empty( $_REQUEST['s'] ) ) ? 'class="current"' : '';
|
245 |
+
$views = array(
|
246 |
+
'all' => sprintf(
|
247 |
+
'<a href="%s" %s>%s</a>',
|
248 |
+
$all_href,
|
249 |
+
$all_class,
|
250 |
+
$all_text
|
251 |
+
),
|
252 |
+
);
|
253 |
+
|
254 |
+
foreach ( $statuses as $status => $count ) {
|
255 |
+
$text = sprintf(
|
256 |
+
translate_nooped_plural( $view_labels[$status], $count, 'wpsc' ),
|
257 |
+
number_format_i18n( $count )
|
258 |
+
);
|
259 |
+
$href = add_query_arg( 'status', $status );
|
260 |
+
$href = remove_query_arg( array(
|
261 |
+
'deleted',
|
262 |
+
'updated',
|
263 |
+
'action',
|
264 |
+
'action2',
|
265 |
+
'm',
|
266 |
+
'paged',
|
267 |
+
's',
|
268 |
+
), $href );
|
269 |
+
$class = ( ! empty( $_REQUEST['status'] ) && $_REQUEST['status'] == $status ) ? 'class="current"' : '';
|
270 |
+
$views[$status] = sprintf(
|
271 |
+
'<a href="%s" %s>%s</a>',
|
272 |
+
$href,
|
273 |
+
$class,
|
274 |
+
$text
|
275 |
+
);
|
276 |
+
}
|
277 |
+
|
278 |
+
return $views;
|
279 |
+
}
|
280 |
+
|
281 |
+
public function months_dropdown() {
|
282 |
+
global $wp_locale;
|
283 |
+
|
284 |
+
$m = isset( $_REQUEST['m'] ) ? $_REQUEST['m'] : 0;
|
285 |
+
|
286 |
+
if ( ! $this->month_filter ) {
|
287 |
+
if ( $m !== 0 )
|
288 |
+
echo '<input type="hidden" name="m" value="' . $m . '" />';
|
289 |
+
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
$months = $this->get_months();
|
294 |
+
if ( ! empty( $months ) ) {
|
295 |
+
?>
|
296 |
+
<select name="m">
|
297 |
+
<option <?php selected( 0, $m ); ?> value="0"><?php _e( 'Show all dates' ); ?></option>
|
298 |
+
<?php
|
299 |
+
foreach ( $months as $arc_row ) {
|
300 |
+
$month = zeroise( $arc_row->month, 2 );
|
301 |
+
$year = $arc_row->year;
|
302 |
+
|
303 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
304 |
+
selected( $arc_row->year . $month, $m, false ),
|
305 |
+
esc_attr( $arc_row->year . $month ),
|
306 |
+
$wp_locale->get_month( $month ) . ' ' . $year
|
307 |
+
);
|
308 |
+
}
|
309 |
+
?>
|
310 |
+
</select>
|
311 |
+
<?php
|
312 |
+
submit_button( _x( 'Filter', 'extra navigation in purchase log page', 'wpsc' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
public function extra_tablenav( $which ) {
|
317 |
+
if ( 'top' == $which ) {
|
318 |
+
echo '<div class="alignleft actions">';
|
319 |
+
$this->months_dropdown();
|
320 |
+
do_action( 'wpsc_sales_log_extra_tablenav' );
|
321 |
+
echo '</div>';
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
public function column_cb( $item ){
|
326 |
+
$checked = isset( $_REQUEST['post'] ) ? checked( in_array( $item->id, $_REQUEST['post'] ), true, false ) : '';
|
327 |
+
return sprintf(
|
328 |
+
'<input type="checkbox" ' . $checked . ' name="%1$s[]" value="%2$s" />',
|
329 |
+
/*$1%s*/ 'post',
|
330 |
+
/*$2%s*/ $item->id
|
331 |
+
);
|
332 |
+
}
|
333 |
+
|
334 |
+
private function item_url( $item ) {
|
335 |
+
$location = remove_query_arg( array(
|
336 |
+
'paged',
|
337 |
+
'order',
|
338 |
+
'orderby',
|
339 |
+
's',
|
340 |
+
'updated',
|
341 |
+
'deleted',
|
342 |
+
) );
|
343 |
+
$location = add_query_arg( array(
|
344 |
+
'c' => 'item_details',
|
345 |
+
'id' => $item->id,
|
346 |
+
), $location );
|
347 |
+
return $location;
|
348 |
+
}
|
349 |
+
|
350 |
+
public function column_customer( $item ) {
|
351 |
+
?>
|
352 |
+
<strong>
|
353 |
+
<a class="row-title" href="<?php echo esc_attr( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wpsc' ) ?>"><?php echo esc_html( $item->firstname . ' ' . $item->lastname ); ?></a>
|
354 |
+
</strong><br />
|
355 |
+
<small><?php echo make_clickable( $item->email ); ?></small>
|
356 |
+
<?php
|
357 |
+
}
|
358 |
+
|
359 |
+
private function delete_url( $item ) {
|
360 |
+
$nonce = wp_create_nonce( 'bulk-' . $this->_args['plural'] );
|
361 |
+
$location = add_query_arg( array(
|
362 |
+
'_wpnonce' => $nonce,
|
363 |
+
'_wp_http_referer' => urlencode( $_SERVER['REQUEST_URI'] ),
|
364 |
+
'action' => 'delete',
|
365 |
+
urlencode( 'post[]' ) => $item->id,
|
366 |
+
) );
|
367 |
+
$location = remove_query_arg( array(
|
368 |
+
'updated',
|
369 |
+
'deleted',
|
370 |
+
), $location );
|
371 |
+
return $location;
|
372 |
+
}
|
373 |
+
|
374 |
+
public function column_id( $item ) {
|
375 |
+
?>
|
376 |
+
<a href="<?php echo esc_attr( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wpsc' ) ?>"><?php echo esc_html( $item->id ); ?></a>
|
377 |
+
<?php if ( ! $this->current_action() == 'delete' ): ?>
|
378 |
+
<br />
|
379 |
+
<small><a class="delete" href="<?php echo esc_url( $this->delete_url( $item ) ); ?>"><?php echo esc_html( _x( 'Delete', 'Sales log page', 'wpsc' ) ); ?></a></small>
|
380 |
+
<?php endif ?>
|
381 |
+
<?php
|
382 |
+
}
|
383 |
+
|
384 |
+
public function column_date( $item ) {
|
385 |
+
$format = __( 'Y/m/d g:i:s A' );
|
386 |
+
$timestamp = (int) $item->date;
|
387 |
+
$full_time = date( $format, $timestamp );
|
388 |
+
$time_diff = time() - $timestamp;
|
389 |
+
if ( $time_diff > 0 && $time_diff < 24 * 60 * 60 )
|
390 |
+
$h_time = $h_time = sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
|
391 |
+
else
|
392 |
+
$h_time = date( __( get_option( 'date_format', 'Y/m/d' ) ), $timestamp );
|
393 |
+
|
394 |
+
echo '<abbr title="' . $full_time . '">' . $h_time . '</abbr>';
|
395 |
+
}
|
396 |
+
|
397 |
+
public function column_amount( $item ) {
|
398 |
+
echo '<a href="' . esc_attr( $this->item_url( $item ) ) . '" title="' . esc_attr__( 'View order details', 'wpsc' ) . '">';
|
399 |
+
echo wpsc_currency_display( $item->amount ) . "<br />";
|
400 |
+
echo '<small>' . sprintf( _n( '1 item', '%s items', $item->item_count, 'wpsc' ), number_format_i18n( $item->item_count ) ) . '</small>';
|
401 |
+
echo '</a>';
|
402 |
+
}
|
403 |
+
|
404 |
+
public function column_default( $item, $column_name ) {
|
405 |
+
return esc_html( $item->$column_name );
|
406 |
+
}
|
407 |
+
|
408 |
+
public function column_status( $item ) {
|
409 |
+
global $wpsc_purchlog_statuses;
|
410 |
+
$dropdown_options = array();
|
411 |
+
$current_status = false;
|
412 |
+
foreach ( $wpsc_purchlog_statuses as $status ) {
|
413 |
+
$selected = '';
|
414 |
+
if ( $status['order'] == $item->status ) {
|
415 |
+
$current_status = esc_html( $status['label'] );
|
416 |
+
$selected = 'selected="selected"';
|
417 |
+
}
|
418 |
+
$dropdown_options .= '<option value="' . esc_attr( $status['order'] ) . '" ' . $selected . '>' . esc_html( $status['label'] ) . '</option>';
|
419 |
+
}
|
420 |
+
|
421 |
+
echo '<span>' . $current_status . '</span>';
|
422 |
+
echo '<select class="wpsc-purchase-log-status" data-log-id="' . $item->id . '">';
|
423 |
+
echo $dropdown_options;
|
424 |
+
echo '</select>';
|
425 |
+
echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="ajax-feedback" title="" alt="" />';
|
426 |
+
}
|
427 |
+
|
428 |
+
public function column_tracking( $item ) {
|
429 |
+
$classes = array( 'wpsc-purchase-log-tracking-id' );
|
430 |
+
$empty = empty( $item->track_id );
|
431 |
+
?>
|
432 |
+
<div data-log-id="<?php echo esc_attr( $item->id ); ?>" <?php echo $empty ? ' class="empty"' : ''; ?>>
|
433 |
+
<a class="add" href="#"><?php echo esc_html( _x( 'Add Tracking ID', 'add purchase log tracking id', 'wpsc' ) ); ?></a>
|
434 |
+
<input type="text" class="wpsc-purchase-log-tracking-id" value="<?php echo esc_attr( $item->track_id ); ?>" />
|
435 |
+
<a class="button save" href="#"><?php echo esc_html( _x( 'Save', 'save sales log tracking id', 'wpsc' ) ); ?></a>
|
436 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
437 |
+
<small class="send-email"><a href="#"><?php echo esc_html( _x( 'Send Email', 'sales log', 'wpsc' ) ); ?></a></small>
|
438 |
+
</div>
|
439 |
+
<?php
|
440 |
+
}
|
441 |
+
|
442 |
+
public function get_bulk_actions() {
|
443 |
+
if ( ! $this->bulk_actions )
|
444 |
+
return array();
|
445 |
+
|
446 |
+
$actions = array(
|
447 |
+
'delete' => _x( 'Delete', 'bulk action', 'wpsc' ),
|
448 |
+
'1' => __( 'Incomplete Sale', 'wpsc' ),
|
449 |
+
'2' => __( 'Order Received', 'wpsc' ),
|
450 |
+
'3' => __( 'Accepted Payment', 'wpsc' ),
|
451 |
+
'4' => __( 'Job dispatched', 'wpsc' ),
|
452 |
+
'5' => __( 'Closed Order', 'wpsc' ),
|
453 |
+
'6' => __( 'Payment Declined', 'wpsc' ),
|
454 |
+
);
|
455 |
+
return $actions;
|
456 |
+
}
|
457 |
+
|
458 |
+
public function search_box( $text, $input_id ) {
|
459 |
+
if ( ! $this->search_box )
|
460 |
+
return '';
|
461 |
+
|
462 |
+
parent::search_box( $text, $input_id );
|
463 |
+
}
|
464 |
+
}
|
wpsc-admin/includes/purchase-logs-page/bulk-delete-confirm.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h3>
|
2 |
+
<?php esc_html_e( 'Are you sure you want to delete these purchase logs?', 'wpsc'); ?><br />
|
3 |
+
</h3>
|
4 |
+
<div>
|
5 |
+
<a href="<?php echo esc_url( wp_get_referer() ); ?>" class="button">Go Back</a>
|
6 |
+
<input class="button-primary" type="submit" value="Delete" />
|
7 |
+
<input type="hidden" name="confirm" value="1" />
|
8 |
+
<input type="hidden" name="action" value="delete" />
|
9 |
+
</div>
|
wpsc-admin/includes/purchase-logs-page/item-details.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<div id="icon-users" class="icon32"><br/></div>
|
3 |
+
<h2>
|
4 |
+
<?php esc_html_e( 'Sales Log Details', 'wpsc' ); ?>
|
5 |
+
<span class="subtitle">#<?php echo $this->log_id; ?></span>
|
6 |
+
</h2>
|
7 |
+
<div id='post-body'>
|
8 |
+
<?php if ( wpsc_has_purchlog_shipping() ): ?>
|
9 |
+
<div id='wpsc_shipping_details_box'>
|
10 |
+
<h3><?php esc_html_e( 'Shipping Address', 'wpsc' ); ?></h3>
|
11 |
+
<p><strong><?php echo wpsc_display_purchlog_shipping_name(); ?></strong></p>
|
12 |
+
<p>
|
13 |
+
<?php echo wpsc_display_purchlog_shipping_address(); ?><br />
|
14 |
+
<?php echo wpsc_display_purchlog_shipping_city(); ?><br />
|
15 |
+
<?php echo wpsc_display_purchlog_shipping_state_and_postcode(); ?><br />
|
16 |
+
<?php echo wpsc_display_purchlog_shipping_country(); ?><br />
|
17 |
+
</p>
|
18 |
+
<strong><?php esc_html_e( 'Shipping Options', 'wpsc' ); ?></strong>
|
19 |
+
<p>
|
20 |
+
<?php esc_html_e('Shipping Method:','wpsc'); ?> <?php echo wpsc_display_purchlog_shipping_method(); ?><br />
|
21 |
+
<?php esc_html_e('Shipping Option:','wpsc'); ?> <?php echo wpsc_display_purchlog_shipping_option(); ?><br />
|
22 |
+
<?php if( wpsc_purchlogs_has_tracking() ) : ?>
|
23 |
+
<?php esc_html_e('Tracking ID:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackid(); ?><br />
|
24 |
+
<?php esc_html_e('Shipping Status:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackstatus(); ?><br />
|
25 |
+
<?php esc_html_e('Track History:','wpsc'); ?> <?php echo wpsc_purchlogitem_trackhistory(); ?>
|
26 |
+
<?php endif; ?>
|
27 |
+
</p>
|
28 |
+
</div>
|
29 |
+
<?php endif ?>
|
30 |
+
|
31 |
+
<div id='wpsc_billing_details_box'>
|
32 |
+
<?php do_action( 'wpsc_billing_details_top' ); ?>
|
33 |
+
<h3><?php esc_html_e( 'Billing Details', 'wpsc' ); ?></h3>
|
34 |
+
<p><strong><?php esc_html_e( 'Purchase Log Date:' ,'wpsc'); ?> </strong><?php echo wpsc_purchaselog_details_date(); ?> </p>
|
35 |
+
<p><strong><?php esc_html_e('Purchase Number:','wpsc'); ?> </strong><?php echo wpsc_purchaselog_details_purchnumber(); ?> </p>
|
36 |
+
<p><strong><?php esc_html_e('Buyers Name:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_buyers_name(); ?></p>
|
37 |
+
<p>
|
38 |
+
<strong><?php esc_html_e('Address:','wpsc'); ?> </strong><br />
|
39 |
+
<?php echo wpsc_display_purchlog_buyers_address(); ?><br />
|
40 |
+
<?php echo wpsc_display_purchlog_buyers_city(); ?><br />
|
41 |
+
<?php echo wpsc_display_purchlog_buyers_state_and_postcode(); ?><br />
|
42 |
+
<?php echo wpsc_display_purchlog_buyers_country(); ?><br />
|
43 |
+
</p>
|
44 |
+
|
45 |
+
<p><strong><?php esc_html_e('Phone:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_buyers_phone(); ?></p>
|
46 |
+
<p><strong><?php esc_html_e('Email:','wpsc'); ?> </strong><a href="mailto:<?php echo wpsc_display_purchlog_buyers_email(); ?>?subject=Message From '<?php echo get_option('siteurl'); ?>'"><?php echo wpsc_display_purchlog_buyers_email(); ?></a></p>
|
47 |
+
<p><strong><?php esc_html_e('Payment Method:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_paymentmethod(); ?></p>
|
48 |
+
<?php if(wpsc_display_purchlog_display_howtheyfoundus()) : ?>
|
49 |
+
<p><strong><?php esc_html_e('How User Found Us:','wpsc'); ?> </strong><?php echo wpsc_display_purchlog_howtheyfoundus(); ?></p>
|
50 |
+
<?php endif; ?>
|
51 |
+
<?php do_action( 'wpsc_billing_details_bottom'); ?>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
<div id='wpsc_items_ordered'>
|
55 |
+
<h3><?php esc_html_e( 'Items Ordered', 'wpsc' ); ?></h3>
|
56 |
+
<table class="widefat" cellspacing="0">
|
57 |
+
<thead>
|
58 |
+
<tr>
|
59 |
+
<?php print_column_headers( 'wpsc_purchase_log_item_details' ); ?>
|
60 |
+
</tr>
|
61 |
+
</thead>
|
62 |
+
|
63 |
+
<tbody>
|
64 |
+
<?php $this->purchase_log_cart_items(); ?>
|
65 |
+
|
66 |
+
<tr class="wpsc_purchaselog_start_totals">
|
67 |
+
<td colspan="<?php echo $cols; ?>">
|
68 |
+
<?php if ( wpsc_purchlog_has_discount_data() ): ?>
|
69 |
+
<?php esc_html_e( 'Coupon Code', 'wpsc' ); ?>: <?php echo wpsc_display_purchlog_discount_data(); ?>
|
70 |
+
<?php endif; ?>
|
71 |
+
</td>
|
72 |
+
<th><?php esc_html_e( 'Discount', 'wpsc' ); ?> </th>
|
73 |
+
<td><?php echo wpsc_display_purchlog_discount(); ?></td>
|
74 |
+
</tr>
|
75 |
+
|
76 |
+
<?php if( ! wpec_display_product_tax() ): ?>
|
77 |
+
<tr>
|
78 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
79 |
+
<th><?php esc_html_e( 'Taxes', 'wpsc' ); ?> </th>
|
80 |
+
<td><?php echo wpsc_display_purchlog_taxes(); ?></td>
|
81 |
+
</tr>
|
82 |
+
<?php endif; ?>
|
83 |
+
|
84 |
+
<tr>
|
85 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
86 |
+
<th><?php esc_html_e( 'Shipping', 'wpsc' ); ?> </th>
|
87 |
+
<td><?php echo wpsc_display_purchlog_shipping(); ?></td>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
91 |
+
<th><?php esc_html_e( 'Total', 'wpsc' ); ?> </th>
|
92 |
+
<td><?php echo wpsc_display_purchlog_totalprice(); ?></td>
|
93 |
+
</tr>
|
94 |
+
</tbody>
|
95 |
+
</table>
|
96 |
+
|
97 |
+
<?php $this->purchase_log_custom_fields(); ?>
|
98 |
+
|
99 |
+
<div class="metabox-holder">
|
100 |
+
<div id="purchlogs_notes" class="postbox">
|
101 |
+
<h3 class='hndle'><?php _e( 'Order Notes' , 'wpsc' ); ?></h3>
|
102 |
+
<div class='inside'>
|
103 |
+
<form method="post" action="">
|
104 |
+
<input type='hidden' name='wpsc_admin_action' value='purchlogs_update_notes' />
|
105 |
+
<input type="hidden" name="wpsc_purchlogs_update_notes_nonce" id="wpsc_purchlogs_update_notes_nonce" value="<?php echo wp_create_nonce( 'wpsc_purchlogs_update_notes' ); ?>" />
|
106 |
+
<input type='hidden' name='purchlog_id' value='<?php echo $this->log_id; ?>' />
|
107 |
+
<p>
|
108 |
+
<textarea name="purchlog_notes" rows="3" wrap="virtual" id="purchlog_notes" style="width:100%;">
|
109 |
+
<?php
|
110 |
+
if ( isset( $_POST['purchlog_notes'] ) ) {
|
111 |
+
echo esc_html( $_POST['purchlog_notes'] );
|
112 |
+
} else {
|
113 |
+
echo wpsc_display_purchlog_notes();
|
114 |
+
}
|
115 |
+
?>
|
116 |
+
</textarea>
|
117 |
+
</p>
|
118 |
+
<p><input class="button" type="submit" name="button" id="button" value="<?php _e( 'Update Notes', 'wpsc' ); ?>" /></p>
|
119 |
+
</form>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
<!-- End Order Notes (by Ben) -->
|
124 |
+
|
125 |
+
<?php $this->purchase_logs_checkout_fields(); ?>
|
126 |
+
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<div id='wpsc_purchlogitems_links'>
|
131 |
+
<h3><?php esc_html_e( 'Actions', 'wpsc' ); ?></h3>
|
132 |
+
<?php do_action( 'wpsc_purchlogitem_links_start' ); ?>
|
133 |
+
<?php if ( wpsc_purchlogs_have_downloads_locked() != false ): ?>
|
134 |
+
<img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/lock_open.png' alt='clear lock icon' /> <a href='<?php echo $_SERVER['REQUEST_URI'].'&wpsc_admin_action=clear_locks'; ?>'><?php echo wpsc_purchlogs_have_downloads_locked(); ?></a><br /><br class='small' />
|
135 |
+
<?php endif; ?>
|
136 |
+
<img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/printer.png' alt='printer icon' /> <a target="_blank" href='<?php echo add_query_arg( 'c', 'packing_slip' ); ?>'><?php esc_html_e( 'View Packing Slip', 'wpsc' ); ?></a>
|
137 |
+
<br /><br class='small' />
|
138 |
+
<img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/email_go.png' alt='email icon' /> <a href='<?php echo add_query_arg( 'email_buyer_id', $this->log_id ); ?>'><?php esc_html_e('Resend Receipt to Buyer', 'wpsc'); ?></a>
|
139 |
+
|
140 |
+
<br /><br class='small' />
|
141 |
+
<a class='submitdelete' title='<?php echo esc_attr(__( 'Remove this log', 'wpsc' )); ?>' href='<?php echo wp_nonce_url("admin.php?wpsc_admin_action=delete_purchlog&purchlog_id=".$this->log_id, 'delete_purchlog_' .$this->log_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_CORE_IMAGES_URL . "/cross.png"; ?>' alt='delete icon' /> <?php _e('Remove this record', 'wpsc') ?></a>
|
142 |
+
|
143 |
+
<br /><br class='small' />   <a href='<?php echo esc_attr( wp_get_referer() ); ?>'><?php _e('Go Back', 'wpsc'); ?></a>
|
144 |
+
<br /><br />
|
145 |
+
</div>
|
146 |
+
<br />
|
147 |
+
|
148 |
+
</div>
|
wpsc-admin/includes/purchase-logs-page/list-table.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<div id="icon-users" class="icon32"><br/></div>
|
3 |
+
<h2>
|
4 |
+
<?php esc_html_e( 'Sales Log' ); ?>
|
5 |
+
|
6 |
+
<?php
|
7 |
+
if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
|
8 |
+
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes( $_REQUEST['s'] ) ) ); ?>
|
9 |
+
</h2>
|
10 |
+
|
11 |
+
<?php if ( ! empty( $_REQUEST['updated'] ) || ! empty( $_REQUEST['deleted'] ) ): ?>
|
12 |
+
<div id="message" class="updated">
|
13 |
+
<p>
|
14 |
+
<?php
|
15 |
+
if ( ! empty( $_REQUEST['updated'] ) )
|
16 |
+
printf( _n( '%s item updated.', '%s items updated.', $_REQUEST['updated'] ), number_format_i18n( $_REQUEST['updated'] ) );
|
17 |
+
?>
|
18 |
+
<?php
|
19 |
+
if ( ! empty( $_REQUEST['deleted'] ) )
|
20 |
+
printf( _n( '%s item deleted.', '%s items deleted.', $_REQUEST['deleted'] ), number_format_i18n( $_REQUEST['deleted'] ) );
|
21 |
+
?>
|
22 |
+
</p>
|
23 |
+
</div>
|
24 |
+
<?php endif ?>
|
25 |
+
|
26 |
+
<?php if( get_option( 'wpsc_purchaselogs_fixed' ) == false || ( wpsc_check_uniquenames() ) ): ?>
|
27 |
+
<div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __('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 <a href="%s">Click Here</a>', 'wpsc'), add_query_arg( 'c', 'upgrade_purchase_logs_3_7' ) ); ?></span></div>
|
28 |
+
<?php endif; ?>
|
29 |
+
|
30 |
+
<?php if ( $this->needs_update() ): ?>
|
31 |
+
<div class='error' style='padding:8px;line-spacing:8px;'><span ><?php printf( __('It has been detected that some of your purchase logs were not updated properly when you upgrade to WP e-Commerce %s. Please <a href="%s">click here</a> to fix this problem.', 'wpsc'), WPSC_VERSION, add_query_arg( 'c', 'upgrade_purchase_logs_3_8' ) ); ?></span></div>
|
32 |
+
<?php endif; ?>
|
33 |
+
|
34 |
+
<form id="purchase-logs-search" method-"get" action="">
|
35 |
+
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
|
36 |
+
<?php $this->list_table->search_box( 'Search Sales Logs', 'post' ); ?>
|
37 |
+
<?php if ( ! empty( $_REQUEST['status'] ) ): ?>
|
38 |
+
<input type="hidden" name="status" value="<?php echo esc_attr( $_REQUEST['status'] ); ?>" />
|
39 |
+
<?php endif ?>
|
40 |
+
</form>
|
41 |
+
|
42 |
+
|
43 |
+
<?php
|
44 |
+
if ( $this->list_table->is_views_enabled() )
|
45 |
+
$this->list_table->views();
|
46 |
+
?>
|
47 |
+
<br class="clear" />
|
48 |
+
|
49 |
+
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
|
50 |
+
<form id="purchase-logs-filter" method="get" action="">
|
51 |
+
<?php do_action( 'wpsc_purchase_logs_list_table_before' ); ?>
|
52 |
+
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
|
53 |
+
<!-- Now we can render the completed list table -->
|
54 |
+
|
55 |
+
<?php $this->list_table->display() ?>
|
56 |
+
<input type="hidden" name="page" value="wpsc-purchase-logs" />
|
57 |
+
|
58 |
+
<?php if ( ! $this->list_table->is_pagination_enabled() && $this->list_table->get_pagenum() ):?>
|
59 |
+
<input type="hidden" name="last_paged" value="<?php echo esc_attr( $this->list_table->get_pagenum() ); ?>" />
|
60 |
+
<?php endif ?>
|
61 |
+
|
62 |
+
<?php if ( ! $this->list_table->is_sortable() && isset( $_REQUEST['orderby'] ) && isset( $_REQUEST['order'] ) ): ?>
|
63 |
+
<input type="hidden" name="orderby" value="<?php echo esc_attr( $_REQUEST['orderby'] ); ?>" />
|
64 |
+
<input type="hidden" name="order" value="<?php echo esc_attr( $_REQUEST['order'] ); ?>" />
|
65 |
+
<?php endif; ?>
|
66 |
+
|
67 |
+
<?php if ( isset( $_REQUEST['s'] ) ): ?>
|
68 |
+
<input type="hidden" name="s" value="<?php echo esc_attr( $_REQUEST['s'] ); ?>" />
|
69 |
+
<?php endif; ?>
|
70 |
+
|
71 |
+
<?php if ( ! empty( $_REQUEST['status'] ) ): ?>
|
72 |
+
<input type="hidden" name="status" value="<?php echo esc_attr( $_REQUEST['status'] ); ?>" />
|
73 |
+
<?php endif ?>
|
74 |
+
<?php do_action( 'wpsc_purchase_logs_list_table_after' ); ?>
|
75 |
+
</form>
|
76 |
+
|
77 |
+
<?php
|
78 |
+
$piggy_url = 'http://www.bravenewcode.com/store/plugins/piggy/?utm_source=affiliate-6331&utm_medium=affiliates&utm_campaign=wpec#1';
|
79 |
+
?>
|
80 |
+
|
81 |
+
<p>
|
82 |
+
<a class='admin_download' href='<?php echo esc_url( add_query_arg( 'action', 'download_csv' ) ); ?>' >
|
83 |
+
<img class='wpsc_pushdown_img' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/download.gif' alt='' title='' />
|
84 |
+
<span><?php _e( 'Download CSV', 'wpsc' ); ?></span>
|
85 |
+
</a>
|
86 |
+
<a target="_blank" class='admin_download' href='<?php echo esc_url( $piggy_url) ; ?>'>
|
87 |
+
<img class='wpsc_pushdown_img' src='<?php echo esc_url( WPSC_CORE_IMAGES_URL ); ?>/mobile.png' alt='' title='' />
|
88 |
+
<span><?php _e( 'Mobile Sales App', 'wpsc' ); ?></span>
|
89 |
+
</a>
|
90 |
+
</p>
|
91 |
+
</div>
|
wpsc-admin/includes/purchase-logs-page/packing-slip.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3 |
+
<head>
|
4 |
+
<title><?php printf( esc_html__( 'Packing Slip for Order #%s', 'wpsc' ), $this->log_id ); ?></title>
|
5 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6 |
+
<style type="text/css">
|
7 |
+
body {
|
8 |
+
font-family:"Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
|
9 |
+
}
|
10 |
+
|
11 |
+
h1 span {
|
12 |
+
font-size:0.75em;
|
13 |
+
}
|
14 |
+
|
15 |
+
h2 {
|
16 |
+
color: #333;
|
17 |
+
}
|
18 |
+
|
19 |
+
#wrapper {
|
20 |
+
margin:0 auto;
|
21 |
+
width:95%;
|
22 |
+
}
|
23 |
+
|
24 |
+
#header {
|
25 |
+
}
|
26 |
+
|
27 |
+
#customer {
|
28 |
+
overflow:hidden;
|
29 |
+
}
|
30 |
+
|
31 |
+
#customer .shipping, #customer .billing {
|
32 |
+
float: left;
|
33 |
+
width: 50%;
|
34 |
+
}
|
35 |
+
|
36 |
+
table {
|
37 |
+
border:1px solid #000;
|
38 |
+
border-collapse:collapse;
|
39 |
+
margin-top:1em;
|
40 |
+
width:100%;
|
41 |
+
}
|
42 |
+
|
43 |
+
th {
|
44 |
+
background-color:#efefef;
|
45 |
+
text-align:center;
|
46 |
+
}
|
47 |
+
|
48 |
+
th, td {
|
49 |
+
padding:5px;
|
50 |
+
}
|
51 |
+
|
52 |
+
td {
|
53 |
+
text-align:center;
|
54 |
+
}
|
55 |
+
|
56 |
+
#cart-items td.amount {
|
57 |
+
text-align:right;
|
58 |
+
}
|
59 |
+
|
60 |
+
td, tbody th {
|
61 |
+
border-top:1px solid #ccc;
|
62 |
+
}
|
63 |
+
th.column-total {
|
64 |
+
width:90px;
|
65 |
+
}
|
66 |
+
th.column-shipping {
|
67 |
+
width:120px;
|
68 |
+
}
|
69 |
+
th.column-price {
|
70 |
+
width:100px;
|
71 |
+
}
|
72 |
+
</style>
|
73 |
+
</head>
|
74 |
+
<body onload="window.print()">
|
75 |
+
<div id="wrapper">
|
76 |
+
<div id="header">
|
77 |
+
<h1>
|
78 |
+
<?php bloginfo( 'name' ); ?><br />
|
79 |
+
<span><?php printf( esc_html__( 'Packing Slip for Order #%s', 'wpsc' ), $this->log_id ); ?></span>
|
80 |
+
</h1>
|
81 |
+
</div>
|
82 |
+
<div id="customer">
|
83 |
+
<div class="shipping">
|
84 |
+
<h2><?php echo esc_html_x( 'Ship To:', 'packing slip', 'wpsc' ); ?></h2>
|
85 |
+
<strong><?php echo wpsc_display_purchlog_shipping_name(); ?></strong><br />
|
86 |
+
<?php echo wpsc_display_purchlog_shipping_address(); ?><br />
|
87 |
+
<?php echo wpsc_display_purchlog_shipping_city(); ?><br />
|
88 |
+
<?php echo wpsc_display_purchlog_shipping_state_and_postcode(); ?><br />
|
89 |
+
<?php echo wpsc_display_purchlog_shipping_country(); ?><br />
|
90 |
+
</div>
|
91 |
+
<div class="billing">
|
92 |
+
<h2><?php echo esc_html_x( 'Bill To:', 'packing slip', 'wpsc' ); ?></h2>
|
93 |
+
<strong><?php echo wpsc_display_purchlog_buyers_name(); ?></strong><br />
|
94 |
+
<?php echo wpsc_display_purchlog_buyers_address(); ?><br />
|
95 |
+
<?php echo wpsc_display_purchlog_buyers_city(); ?><br />
|
96 |
+
<?php echo wpsc_display_purchlog_buyers_state_and_postcode(); ?><br />
|
97 |
+
<?php echo wpsc_display_purchlog_buyers_country(); ?><br />
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
<table id="order">
|
101 |
+
<thead>
|
102 |
+
<tr>
|
103 |
+
<th><?php echo esc_html_x( 'Order Date', 'packing slip', 'wpsc' ); ?></th>
|
104 |
+
<th><?php echo esc_html_x( 'Order ID', 'packing slip', 'wpsc' ); ?></th>
|
105 |
+
<th><?php echo esc_html_x( 'Shipping Method', 'packing slip', 'wpsc' ); ?></th>
|
106 |
+
<th><?php echo esc_html_x( 'Payment Method', 'packing slip', 'wpsc' ); ?></th>
|
107 |
+
</tr>
|
108 |
+
</thead>
|
109 |
+
<tbody>
|
110 |
+
<tr>
|
111 |
+
<td><?php echo wpsc_purchaselog_details_date(); ?></td>
|
112 |
+
<td><?php echo wpsc_purchaselog_details_purchnumber(); ?></td>
|
113 |
+
<td><?php echo wpsc_display_purchlog_shipping_method(); ?></td>
|
114 |
+
<td><?php echo wpsc_display_purchlog_paymentmethod(); ?></td>
|
115 |
+
</tr>
|
116 |
+
</tbody>
|
117 |
+
</table>
|
118 |
+
<table id="cart-items" class="widefat" cellspacing="0">
|
119 |
+
<thead>
|
120 |
+
<tr>
|
121 |
+
<?php print_column_headers( 'wpsc_purchase_log_item_details' ); ?>
|
122 |
+
</tr>
|
123 |
+
</thead>
|
124 |
+
|
125 |
+
<tbody>
|
126 |
+
<?php $this->purchase_log_cart_items(); ?>
|
127 |
+
|
128 |
+
<tr class="wpsc_purchaselog_start_totals">
|
129 |
+
<td colspan="<?php echo $cols; ?>">
|
130 |
+
<?php if ( wpsc_purchlog_has_discount_data() ): ?>
|
131 |
+
<?php esc_html_e( 'Coupon Code', 'wpsc' ); ?>: <?php echo wpsc_display_purchlog_discount_data(); ?>
|
132 |
+
<?php endif; ?>
|
133 |
+
</td>
|
134 |
+
<th><?php esc_html_e( 'Discount', 'wpsc' ); ?> </th>
|
135 |
+
<td class="amount"><?php echo wpsc_display_purchlog_discount(); ?></td>
|
136 |
+
</tr>
|
137 |
+
|
138 |
+
<?php if( ! wpec_display_product_tax() ): ?>
|
139 |
+
<tr>
|
140 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
141 |
+
<th><?php esc_html_e( 'Taxes', 'wpsc' ); ?> </th>
|
142 |
+
<td class="amount"><?php echo wpsc_display_purchlog_taxes(); ?></td>
|
143 |
+
</tr>
|
144 |
+
<?php endif; ?>
|
145 |
+
|
146 |
+
<tr>
|
147 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
148 |
+
<th><?php esc_html_e( 'Shipping', 'wpsc' ); ?> </th>
|
149 |
+
<td class="amount"><?php echo wpsc_display_purchlog_shipping(); ?></td>
|
150 |
+
</tr>
|
151 |
+
<tr>
|
152 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
153 |
+
<th><?php esc_html_e( 'Total', 'wpsc' ); ?> </th>
|
154 |
+
<td class="amount"><?php echo wpsc_display_purchlog_totalprice(); ?></td>
|
155 |
+
</tr>
|
156 |
+
</tbody>
|
157 |
+
</table>
|
158 |
+
</div>
|
159 |
+
</body>
|
160 |
+
</html>
|
wpsc-admin/includes/purchase-logs-page/upgrade.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class='wrap'>
|
2 |
+
|
3 |
+
<h2><?php echo esc_html( __('Sales Upgrade Fix', 'wpsc') ); ?> </h2>
|
4 |
+
|
5 |
+
<?php if ( $numChanged != 0 && $numQueries != 0 ): ?>
|
6 |
+
<div class="updated">
|
7 |
+
<p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wpsc' ), remove_query_arg( 'c' ) ); ?></p>
|
8 |
+
</div>
|
9 |
+
<?php else: ?>
|
10 |
+
<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.', 'wpsc'); ?> </p>
|
11 |
+
|
12 |
+
<div class="metabox-holder" style="width:700px">
|
13 |
+
<form action='' method='post'>
|
14 |
+
|
15 |
+
<?php
|
16 |
+
|
17 |
+
$duplicate = array();
|
18 |
+
foreach($formfields as $fields){
|
19 |
+
if(!in_array($fields->name,$duplicate) && $fields->name != 'State'){
|
20 |
+
echo '<div class="postbox" style="width:70%">';
|
21 |
+
echo '<h3 class="handle">Billing '.$fields->name.'</h3>';
|
22 |
+
echo '<div class="inside" style="padding:20px;">';
|
23 |
+
echo '<label style="width:120px;float:left;" for="'.$fields->id.'">'.$fields->value.'</label>';
|
24 |
+
echo $this->purchase_logs_fix_options( $fields->id );
|
25 |
+
echo '</div>';
|
26 |
+
echo '</div>';
|
27 |
+
$duplicate[] = $fields->name;
|
28 |
+
}else{
|
29 |
+
echo '<div class="postbox" style="width:70%">';
|
30 |
+
echo '<h3 class="handle">Shipping '.$fields->name.'</h3>';
|
31 |
+
echo '<div class="inside" style="padding:20px;">';
|
32 |
+
echo '<label style="width:120px;float:left;" for="'.$fields->id.'">'.$fields->value.'</label>';
|
33 |
+
echo $this->purchase_logs_fix_options( $fields->id );
|
34 |
+
echo '</div>';
|
35 |
+
echo '</div>';
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
40 |
+
?>
|
41 |
+
<input type='submit' value='<?php _e('Apply', 'wpsc'); ?>' class='button-secondary action' />
|
42 |
+
</form>
|
43 |
+
</div>
|
44 |
+
<?php endif; ?>
|
45 |
+
</div>
|
wpsc-admin/includes/purchlogs_upgrade.php
DELETED
@@ -1,103 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
global $wpdb;
|
3 |
-
$numChanged = 0;
|
4 |
-
$numQueries = 0;
|
5 |
-
$purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
|
6 |
-
$id = $wpdb->get_var($purchlog);
|
7 |
-
$usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`" ;
|
8 |
-
$formfields = $wpdb->get_results($usersql);
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
if(count($formfields) < 1){
|
13 |
-
$usersql = "SELECT DISTINCT `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` != 'heading'";
|
14 |
-
$formfields = $wpdb->get_results($usersql);
|
15 |
-
|
16 |
-
}
|
17 |
-
if(isset($_POST)){
|
18 |
-
foreach($_POST as $key=>$value){
|
19 |
-
if($value != '-1'){
|
20 |
-
$sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='".$value."' WHERE id=".$key;
|
21 |
-
$complete = $wpdb->query($sql);
|
22 |
-
}
|
23 |
-
$numChaged++;
|
24 |
-
$numQueries ++;
|
25 |
-
}
|
26 |
-
|
27 |
-
$sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='delivertoafriend' WHERE `name` = '2. Shipping details'";
|
28 |
-
$wpdb->query($sql);
|
29 |
-
|
30 |
-
add_option('wpsc_purchaselogs_fixed',true);
|
31 |
-
}
|
32 |
-
function wpsc_select_options_purchlogs_fix($id){
|
33 |
-
?>
|
34 |
-
<select name='<?php echo $id; ?>'>
|
35 |
-
<option value='-1'><?php _e( 'Select an Option', 'wpsc' ); ?>'</option>
|
36 |
-
<option value='billingfirstname'><?php _e( 'Billing First Name', 'wpsc' ); ?></option>
|
37 |
-
<option value='billinglastname'><?php _e( 'Billing Last Name', 'wpsc' ); ?></option>
|
38 |
-
<option value='billingaddress'><?php _e( 'Billing Address', 'wpsc' ); ?></option>
|
39 |
-
<option value='billingcity'><?php _e( 'Billing City', 'wpsc' ); ?></option>
|
40 |
-
<option value='billingstate'><?php _e( 'Billing State', 'wpsc' ); ?></option>
|
41 |
-
<option value='billingcountry'><?php _e( 'Billing Country', 'wpsc' ); ?></option>
|
42 |
-
<option value='billingemail'><?php _e( 'Billing Email', 'wpsc' ); ?></option>
|
43 |
-
<option value='billingphone'><?php _e( 'Billing Phone', 'wpsc' ); ?></option>
|
44 |
-
<option value='billingpostcode'><?php _e( 'Billing Post Code', 'wpsc' ); ?></option>
|
45 |
-
<option value='shippingfirstname'><?php _e( 'Shipping First Name', 'wpsc' ); ?></option>
|
46 |
-
<option value='shippinglastname'><?php _e( 'Shipping Last Name', 'wpsc' ); ?></option>
|
47 |
-
<option value='shippingaddress'><?php _e( 'Shipping Address', 'wpsc' ); ?></option>
|
48 |
-
<option value='shippingcity'><?php _e( 'Shipping City', 'wpsc' ); ?></option>
|
49 |
-
<option value='shippingstate'><?php _e( 'Shipping State', 'wpsc' ); ?></option>
|
50 |
-
<option value='shippingcountry'><?php _e( 'Shipping Country', 'wpsc' ); ?></option>
|
51 |
-
<option value='shippingpostcode'><?php _e( 'Shipping Post Code', 'wpsc' ); ?></option>
|
52 |
-
|
53 |
-
</select>
|
54 |
-
<?php
|
55 |
-
}
|
56 |
-
?>
|
57 |
-
|
58 |
-
<div class='wrap'>
|
59 |
-
|
60 |
-
<?php if ( $numChanged != 0 && $numQueries != 0 ) {
|
61 |
-
echo '<div id="message" class="updated fade"><p>';
|
62 |
-
_e( 'Check Out Form Fields updated.', 'wpsc' );
|
63 |
-
echo '</p></div>';
|
64 |
-
}
|
65 |
-
|
66 |
-
?>
|
67 |
-
|
68 |
-
<h2><?php echo esc_html( __('Sales Upgrade Fix', 'wpsc') ); ?> </h2>
|
69 |
-
<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.', 'wpsc'); ?> </p>
|
70 |
-
|
71 |
-
<div class="metabox-holder" style="width:700px">
|
72 |
-
<form action='' method='post'>
|
73 |
-
|
74 |
-
<?php
|
75 |
-
|
76 |
-
$duplicate = array();
|
77 |
-
foreach($formfields as $fields){
|
78 |
-
if(!in_array($fields->name,$duplicate) && $fields->name != 'State'){
|
79 |
-
echo '<div class="postbox" style="width:70%">';
|
80 |
-
echo '<h3 class="handle">Billing '.$fields->name.'</h3>';
|
81 |
-
echo '<div class="inside" style="padding:20px;">';
|
82 |
-
echo '<label style="width:120px;float:left;" for="'.$fields->id.'">'.$fields->value.'</label>';
|
83 |
-
echo wpsc_select_options_purchlogs_fix($fields->id);
|
84 |
-
echo '</div>';
|
85 |
-
echo '</div>';
|
86 |
-
$duplicate[] = $fields->name;
|
87 |
-
}else{
|
88 |
-
echo '<div class="postbox" style="width:70%">';
|
89 |
-
echo '<h3 class="handle">Shipping '.$fields->name.'</h3>';
|
90 |
-
echo '<div class="inside" style="padding:20px;">';
|
91 |
-
echo '<label style="width:120px;float:left;" for="'.$fields->id.'">'.$fields->value.'</label>';
|
92 |
-
echo wpsc_select_options_purchlogs_fix($fields->id);
|
93 |
-
echo '</div>';
|
94 |
-
echo '</div>';
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
}
|
99 |
-
?>
|
100 |
-
<input type='submit' value='<?php _e('Apply', 'wpsc'); ?>' class='button-secondary action' />
|
101 |
-
</form>
|
102 |
-
</div>
|
103 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/save-data.functions.php
CHANGED
@@ -6,6 +6,22 @@
|
|
6 |
* @since 3.8
|
7 |
* @todo UI needs a lot of loving - lots of padding issues, if we have these boxes, they should be sortable, closable, hidable, etc.
|
8 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
/**
|
11 |
* WP eCommerce edit and add product category page functions
|
@@ -216,7 +232,7 @@ function wpsc_admin_category_forms_add() {
|
|
216 |
|
217 |
<!-- START OF TARGET MARKET SELECTION -->
|
218 |
<div id="poststuff" class="postbox">
|
219 |
-
<h3 class="hndle"><?php _e('Target Market Restrictions'); ?></h3>
|
220 |
<div class="inside"><?php
|
221 |
$category_id = '';
|
222 |
if (isset($_GET["tag_ID"])) $category_id = $_GET["tag_ID"];
|
@@ -545,14 +561,14 @@ function wpsc_save_category_set($category_id, $tt_id) {
|
|
545 |
} else {
|
546 |
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ) );
|
547 |
}
|
548 |
-
$image =
|
549 |
} else {
|
550 |
$new_image_path = ( WPSC_CATEGORY_DIR.basename($_FILES['image']['name'] ) );
|
551 |
move_uploaded_file( $_FILES['image']['tmp_name'], $new_image_path );
|
552 |
$stat = stat( dirname( $new_image_path ) );
|
553 |
$perms = $stat['mode'] & 0000666;
|
554 |
@ chmod( $new_image_path, $perms );
|
555 |
-
$image =
|
556 |
}
|
557 |
} else {
|
558 |
$image = '';
|
@@ -588,13 +604,13 @@ function wpsc_save_category_set($category_id, $tt_id) {
|
|
588 |
wpsc_update_categorymeta($category_id, 'order', '0');
|
589 |
|
590 |
if ( isset( $_POST['display_type'] ) )
|
591 |
-
wpsc_update_categorymeta($category_id, 'display_type'
|
592 |
|
593 |
if ( isset( $_POST['image_height'] ) )
|
594 |
-
wpsc_update_categorymeta($category_id, 'image_height',
|
595 |
|
596 |
if ( isset( $_POST['image_width'] ) )
|
597 |
-
wpsc_update_categorymeta($category_id, 'image_width',
|
598 |
|
599 |
|
600 |
if ( ! empty( $_POST['use_additional_form_set'] ) ) {
|
6 |
* @since 3.8
|
7 |
* @todo UI needs a lot of loving - lots of padding issues, if we have these boxes, they should be sortable, closable, hidable, etc.
|
8 |
*/
|
9 |
+
function wpsc_ajax_set_variation_order(){
|
10 |
+
global $wpdb;
|
11 |
+
$sort_order = $_POST['sort_order'];
|
12 |
+
$parent_id = $_POST['parent_id'];
|
13 |
+
|
14 |
+
$result = true;
|
15 |
+
foreach( $sort_order as $key=>$value ){
|
16 |
+
if ( empty( $value ) )
|
17 |
+
continue;
|
18 |
+
|
19 |
+
$value = preg_replace( '/[^0-9]/', '', $value );
|
20 |
+
|
21 |
+
if( !wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_variation' ) )
|
22 |
+
$result = false;
|
23 |
+
}
|
24 |
+
}
|
25 |
|
26 |
/**
|
27 |
* WP eCommerce edit and add product category page functions
|
232 |
|
233 |
<!-- START OF TARGET MARKET SELECTION -->
|
234 |
<div id="poststuff" class="postbox">
|
235 |
+
<h3 class="hndle"><?php _e( 'Target Market Restrictions', 'wpsc' ); ?></h3>
|
236 |
<div class="inside"><?php
|
237 |
$category_id = '';
|
238 |
if (isset($_GET["tag_ID"])) $category_id = $_GET["tag_ID"];
|
561 |
} else {
|
562 |
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ) );
|
563 |
}
|
564 |
+
$image = esc_sql( $_FILES['image']['name'] );
|
565 |
} else {
|
566 |
$new_image_path = ( WPSC_CATEGORY_DIR.basename($_FILES['image']['name'] ) );
|
567 |
move_uploaded_file( $_FILES['image']['tmp_name'], $new_image_path );
|
568 |
$stat = stat( dirname( $new_image_path ) );
|
569 |
$perms = $stat['mode'] & 0000666;
|
570 |
@ chmod( $new_image_path, $perms );
|
571 |
+
$image = esc_sql( $_FILES['image']['name'] );
|
572 |
}
|
573 |
} else {
|
574 |
$image = '';
|
604 |
wpsc_update_categorymeta($category_id, 'order', '0');
|
605 |
|
606 |
if ( isset( $_POST['display_type'] ) )
|
607 |
+
wpsc_update_categorymeta($category_id, 'display_type',esc_sql(stripslashes($_POST['display_type'])));
|
608 |
|
609 |
if ( isset( $_POST['image_height'] ) )
|
610 |
+
wpsc_update_categorymeta($category_id, 'image_height', esc_sql(stripslashes($_POST['image_height'])));
|
611 |
|
612 |
if ( isset( $_POST['image_width'] ) )
|
613 |
+
wpsc_update_categorymeta($category_id, 'image_width', esc_sql(stripslashes($_POST['image_width'])));
|
614 |
|
615 |
|
616 |
if ( ! empty( $_POST['use_additional_form_set'] ) ) {
|
wpsc-admin/includes/settings-pages/checkout.php
DELETED
@@ -1,231 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
function wpsc_options_checkout(){
|
3 |
-
global $wpdb;
|
4 |
-
$form_types = get_option('wpsc_checkout_form_fields');
|
5 |
-
$unique_names = get_option('wpsc_checkout_unique_names');
|
6 |
-
|
7 |
-
do_action('wpsc_checkout_form_fields_page');
|
8 |
-
$columns = array(
|
9 |
-
'drag' => __('Drag', 'wpsc'),
|
10 |
-
'name' => __('Name', 'wpsc'),
|
11 |
-
'type' => __('Type', 'wpsc'),
|
12 |
-
'unique_names' => __('Unique Names', 'wpsc'),
|
13 |
-
'mandatory' => __('Mandatory', 'wpsc'),
|
14 |
-
'trash' => __('Trash', 'wpsc'),
|
15 |
-
);
|
16 |
-
register_column_headers('display-checkout-list', $columns);
|
17 |
-
|
18 |
-
|
19 |
-
?>
|
20 |
-
|
21 |
-
<form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
|
22 |
-
<div class="wrap">
|
23 |
-
<?php
|
24 |
-
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
25 |
-
wpsc_settings_page_update_notification(); ?>
|
26 |
-
|
27 |
-
<div class='metabox-holder' style='width:95%;'>
|
28 |
-
<div class='postbox'>
|
29 |
-
<input type='hidden' name='checkout_submits' value='true' />
|
30 |
-
<h3 class='hndle'><?php _e( 'Misc Checkout Options' , 'wpsc' ); ?></h3>
|
31 |
-
<div class='inside'>
|
32 |
-
<table>
|
33 |
-
<tr>
|
34 |
-
<td><?php _e('Users must register before checking out', 'wpsc'); ?>:</td>
|
35 |
-
<td>
|
36 |
-
<?php
|
37 |
-
$require_register = esc_attr( get_option('require_register') );
|
38 |
-
$require_register1 = "";
|
39 |
-
$require_register2 = "";
|
40 |
-
switch($require_register) {
|
41 |
-
case 0:
|
42 |
-
$require_register2 = "checked ='checked'";
|
43 |
-
break;
|
44 |
-
|
45 |
-
case 1:
|
46 |
-
$require_register1 = "checked ='checked'";
|
47 |
-
break;
|
48 |
-
}
|
49 |
-
?>
|
50 |
-
<input type='radio' value='1' name='wpsc_options[require_register]' id='require_register1' <?php echo $require_register1; ?> /> <label for='require_register1'><?php _e('Yes', 'wpsc');?></label>
|
51 |
-
<input type='radio' value='0' name='wpsc_options[require_register]' id='require_register2' <?php echo $require_register2; ?> /> <label for='require_register2'><?php _e('No', 'wpsc');?></label>
|
52 |
-
</td>
|
53 |
-
<td>
|
54 |
-
<a title='<?php _e('If yes then you must also turn on the wordpress option "Any one can register"', 'wpsc');?>' class='flag_email' href='#' ><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/help.png' alt='' /> </a>
|
55 |
-
</td>
|
56 |
-
</tr>
|
57 |
-
|
58 |
-
<tr>
|
59 |
-
<?php
|
60 |
-
$shippingBilling = get_option('shippingsameasbilling');
|
61 |
-
$shippingBilling1 = $shippingBilling2 = '';
|
62 |
-
switch($shippingBilling) {
|
63 |
-
case 1:
|
64 |
-
$shippingBilling1 = "checked ='checked'";
|
65 |
-
break;
|
66 |
-
|
67 |
-
case 0:
|
68 |
-
$shippingBilling2 = "checked ='checked'";
|
69 |
-
break;
|
70 |
-
}
|
71 |
-
?>
|
72 |
-
<td scope="row"><?php _e('Enable Shipping Same as Billing Option: ', 'wpsc'); ?>:</td>
|
73 |
-
<td>
|
74 |
-
<input type='radio' value='1' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling1' <?php if (!empty($shippingBilling1)) echo $shippingBilling1; ?> />
|
75 |
-
<label for='shippingsameasbilling1'><?php _e('Yes', 'wpsc');?></label>
|
76 |
-
<input type='radio' value='0' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling2' <?php if (!empty($shippingBilling2)) echo $shippingBilling2; ?> />
|
77 |
-
<label for='shippingsameasbilling2'><?php _e('No', 'wpsc');?></label>
|
78 |
-
</td>
|
79 |
-
|
80 |
-
</tr>
|
81 |
-
<tr>
|
82 |
-
<td><?php _e('Force users to use SSL', 'wpsc'); ?>:</td>
|
83 |
-
<td>
|
84 |
-
<?php
|
85 |
-
$wpsc_force_ssl = esc_attr( get_option('wpsc_force_ssl') );
|
86 |
-
$wpsc_force_ssl1 = "";
|
87 |
-
$wpsc_force_ssl2 = "";
|
88 |
-
switch($wpsc_force_ssl) {
|
89 |
-
case 0:
|
90 |
-
$wpsc_force_ssl2 = "checked ='checked'";
|
91 |
-
break;
|
92 |
-
|
93 |
-
case 1:
|
94 |
-
$wpsc_force_ssl1 = "checked ='checked'";
|
95 |
-
break;
|
96 |
-
}
|
97 |
-
?>
|
98 |
-
<input type='radio' value='1' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl1' <?php echo $wpsc_force_ssl1; ?> /> <label for='wpsc_force_ssl1'><?php _e('Yes', 'wpsc');?></label>
|
99 |
-
<input type='radio' value='0' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl2' <?php echo $wpsc_force_ssl2; ?> /> <label for='wpsc_force_ssl2'><?php _e('No', 'wpsc');?></label>
|
100 |
-
</td>
|
101 |
-
<td>
|
102 |
-
<a title='<?php _e('This can cause warnings for your users if you do not have a properly configured SSL certificate', 'wpsc');?>' class='flag_email' href='#' ><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/help.png' alt='' /> </a>
|
103 |
-
</td>
|
104 |
-
</tr>
|
105 |
-
<?php do_action('wpsc_checkout_settings_page'); ?>
|
106 |
-
</table>
|
107 |
-
</div>
|
108 |
-
</div>
|
109 |
-
</div>
|
110 |
-
<h3><?php _e('Form Fields', 'wpsc'); ?></h3>
|
111 |
-
<p><?php _e('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...', 'wpsc');?></p>
|
112 |
-
|
113 |
-
<p>
|
114 |
-
<label for='wpsc_form_set'><?php _e('Select a Form Set' , 'wpsc'); ?>:</label>
|
115 |
-
<select id='wpsc_form_set' name='wpsc_form_set'>
|
116 |
-
<?php
|
117 |
-
$checkout_sets = get_option('wpsc_checkout_form_sets');
|
118 |
-
foreach((array)$checkout_sets as $key => $value) {
|
119 |
-
$selected_state = "";
|
120 |
-
if(isset($_GET['checkout-set']) && $_GET['checkout-set'] == $key) {
|
121 |
-
$selected_state = "selected='selected'";
|
122 |
-
}
|
123 |
-
echo "<option {$selected_state} value='{$key}'>".esc_attr( stripslashes( $value ) )."</option>";
|
124 |
-
}
|
125 |
-
?>
|
126 |
-
</select>
|
127 |
-
<input type='submit' value='Filter' name='wpsc_checkout_set_filter' class='button-secondary' />
|
128 |
-
<a href='#' class='add_new_form_set'><?php _e("+ Add New Form Set", 'wpsc'); ?></a>
|
129 |
-
</p>
|
130 |
-
|
131 |
-
<p class='add_new_form_set_forms'>
|
132 |
-
<label><?php _e("Add new Form Set",'wpsc'); ?>: <input type="text" value="" name="new_form_set" /></label>
|
133 |
-
<input type="submit" value="<?php _e('Add', 'wpsc'); ?>" class="button-secondary" id="formset-add-sumbit"/>
|
134 |
-
</p>
|
135 |
-
|
136 |
-
<?php
|
137 |
-
if(!isset($_GET['checkout-set']) || ($_GET['checkout-set'] == 0)) {
|
138 |
-
$form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('0', '') ORDER BY `checkout_order`;";
|
139 |
-
} else {
|
140 |
-
$filter = $wpdb->escape($_GET['checkout-set']);
|
141 |
-
$form_sql = "SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1' AND `checkout_set` IN ('".$filter."') ORDER BY `checkout_order`;";
|
142 |
-
}
|
143 |
-
$email_form_field = $wpdb->get_row("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1",ARRAY_A);
|
144 |
-
|
145 |
-
|
146 |
-
$form_data = $wpdb->get_results($form_sql,ARRAY_A);
|
147 |
-
if (!isset($_GET['checkout-set'])) $_GET['checkout-set'] = '';
|
148 |
-
|
149 |
-
$selected_checkout_set = esc_attr($_GET['checkout-set']);
|
150 |
-
echo "<input type='hidden' name='selected_form_set' value='".$selected_checkout_set."' />";
|
151 |
-
?>
|
152 |
-
<table id="wpsc_checkout_list" class="widefat page fixed" cellspacing="0">
|
153 |
-
<thead>
|
154 |
-
<tr>
|
155 |
-
<?php print_column_headers('display-checkout-list'); ?>
|
156 |
-
</tr>
|
157 |
-
</thead>
|
158 |
-
|
159 |
-
<tfoot>
|
160 |
-
<tr>
|
161 |
-
<?php print_column_headers('display-checkout-list', false); ?>
|
162 |
-
</tr>
|
163 |
-
</tfoot>
|
164 |
-
|
165 |
-
<tbody id='wpsc_checkout_list_body'>
|
166 |
-
<?php
|
167 |
-
foreach((array)$form_data as $form_field) {
|
168 |
-
echo "<tr id='checkout_".$form_field['id']."' class='checkout_form_field'>\n\r";
|
169 |
-
echo '<td class="drag"><a href="" onclick="return false;" title="' . __('Click and Drag to Order Checkout Fields', 'wpsc') . '"><img src="' . WPSC_CORE_IMAGES_URL . '/roll-over-drag.jpg" alt="roll-over-drag" /></a></td>';
|
170 |
-
echo "<td class='namecol'><input type='text' name='form_name[".$form_field['id']."]' value='".esc_attr(htmlentities(stripslashes($form_field['name']), ENT_QUOTES, "UTF-8"))."' /></td>";
|
171 |
-
|
172 |
-
echo " <td class='typecol'>";
|
173 |
-
echo "<select class='wpsc_checkout_selectboxes' name='form_type[".$form_field['id']."]'>";
|
174 |
-
foreach($form_types as $form_type_name => $form_type) {
|
175 |
-
$selected = '';
|
176 |
-
if($form_type === $form_field['type']) {
|
177 |
-
$selected = "selected='selected'";
|
178 |
-
}
|
179 |
-
echo "<option value='".$form_type."' ".$selected.">" . $form_type_name . "</option>";
|
180 |
-
}
|
181 |
-
|
182 |
-
echo "</select>";
|
183 |
-
if(in_array($form_field['type'], array('select','radio','checkbox'))){
|
184 |
-
echo "<a class='wpsc_edit_checkout_options' rel='form_options[".$form_field['id']."]' href=''>" . __('more options', 'wpsc') . "</a>";
|
185 |
-
}
|
186 |
-
echo "</td>";
|
187 |
-
$checked = "";
|
188 |
-
echo "<td><select name='unique_names[".$form_field['id']."]'>";
|
189 |
-
echo "<option value='-1'>" . __('Select a Unique Name', 'wpsc') . "</option>";
|
190 |
-
foreach($unique_names as $unique_name){
|
191 |
-
$selected = "";
|
192 |
-
if($unique_name == $form_field['unique_name']) {
|
193 |
-
$selected = "selected='selected'";
|
194 |
-
}
|
195 |
-
echo "<option ".$selected." value='".$unique_name."'>".$unique_name."</option>";
|
196 |
-
}
|
197 |
-
echo "</select></td>";
|
198 |
-
if($form_field['mandatory']) {
|
199 |
-
$checked = "checked='checked'";
|
200 |
-
}
|
201 |
-
echo " <td class='mandatorycol'><input $checked type='checkbox' name='form_mandatory[".$form_field['id']."]' value='1' /></td>";
|
202 |
-
|
203 |
-
|
204 |
-
echo " <td><a class='image_link' href='#' onclick='return remove_form_field(\"checkout_".$form_field['id']."\",".$form_field['id'].");'><img src='" . WPSC_CORE_IMAGES_URL . "/trash.gif' alt='".__('Delete', 'wpsc')."' title='".__('Delete', 'wpsc')."' /></a>";
|
205 |
-
|
206 |
-
if($email_form_field['id'] == $form_field['id']) {
|
207 |
-
echo "<a title='".__('This will be the Email address that the Purchase Reciept is sent to.', 'wpsc')."' class='flag_email' href='#' ><img src='" . WPSC_CORE_IMAGES_URL . "/help.png' alt='' /> </a>";
|
208 |
-
}
|
209 |
-
echo "</td>";
|
210 |
-
|
211 |
-
echo "
|
212 |
-
</tr>";
|
213 |
-
|
214 |
-
}
|
215 |
-
?>
|
216 |
-
|
217 |
-
</tbody>
|
218 |
-
</table>
|
219 |
-
<?php ?>
|
220 |
-
<p>
|
221 |
-
<input type='hidden' name='wpsc_admin_action' value='checkout_settings' />
|
222 |
-
|
223 |
-
<?php wp_nonce_field('update-options', 'wpsc-update-options'); ?>
|
224 |
-
<input class='button-primary' type='submit' name='submit' value='<?php _e('Save Changes', 'wpsc');?>' />
|
225 |
-
<a href='#' onclick='return add_form_field();'><?php _e('Add New Form Field', 'wpsc');?></a></p>
|
226 |
-
<div id="checkout_message">Note: Any new form fields will appear in your sales logs and on your checkout page but this data will not be sent to the payment gateway.</div>
|
227 |
-
</div>
|
228 |
-
</form>
|
229 |
-
<?php
|
230 |
-
}
|
231 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-pages/gateway.php
DELETED
@@ -1,151 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function wpsc_options_gateway() {
|
4 |
-
global $wpdb, $nzshpcrt_gateways;
|
5 |
-
|
6 |
-
$curgateway = get_option( 'payment_gateway' );
|
7 |
-
|
8 |
-
$payment_gateway_names = get_option( 'payment_gateway_names' );
|
9 |
-
|
10 |
-
if ( empty( $nzshpcrt_gateways ) )
|
11 |
-
$nzshpcrt_gateways = nzshpcrt_get_gateways();
|
12 |
-
|
13 |
-
if ( is_array( $nzshpcrt_gateways ) ) {
|
14 |
-
$selected_gateways = get_option( 'custom_gateway_options' );
|
15 |
-
foreach ( $nzshpcrt_gateways as $gateway ) {
|
16 |
-
if ( $gateway['internalname'] == $curgateway ) {
|
17 |
-
$selected = "selected='selected'";
|
18 |
-
$form = $gateway['form']();
|
19 |
-
$selected_gateway_data = $gateway;
|
20 |
-
} else {
|
21 |
-
$selected = '';
|
22 |
-
}
|
23 |
-
|
24 |
-
if ( isset( $gateway['admin_name'] ) )
|
25 |
-
$gateway['name'] = $gateway['admin_name'];
|
26 |
-
|
27 |
-
$disabled = '';
|
28 |
-
|
29 |
-
if ( !in_array( $gateway['internalname'], (array)$selected_gateways ) )
|
30 |
-
$disabled = "disabled='disabled'";
|
31 |
-
|
32 |
-
if ( !isset( $gateway['internalname'] ) )
|
33 |
-
$gateway['internalname'] = '';
|
34 |
-
|
35 |
-
$gatewaylist = '';
|
36 |
-
$gatewaylist .= "<option $disabled value='" . esc_attr( $gateway['internalname'] ) . "' " . $selected . " >" . esc_attr( $gateway['name'] ) . "</option>";
|
37 |
-
}
|
38 |
-
}
|
39 |
-
$nogw = '';
|
40 |
-
$gatewaylist = "<option value='" . $nogw . "'>" . __( 'Please Select A Payment Gateway', 'wpsc' ) . "</option>" . $gatewaylist;
|
41 |
-
?>
|
42 |
-
|
43 |
-
<script language='javascript' type='text/javascript'>
|
44 |
-
function selectgateway() {
|
45 |
-
document.forms.gateway_opt.submit();
|
46 |
-
}
|
47 |
-
</script>
|
48 |
-
|
49 |
-
<div class="wrap">
|
50 |
-
<div class='metabox-holder'>
|
51 |
-
<form name='gatewayopt' method='post' id='gateway_opt' action='' class='wpsc_form_track'>
|
52 |
-
<input type='hidden' name='gateway_submits' value='true' />
|
53 |
-
<input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
|
54 |
-
<?php
|
55 |
-
if ( get_option( 'custom_gateway' ) == 1 ) {
|
56 |
-
$custom_gateway_hide = "style='display:block;'";
|
57 |
-
$custom_gateway1 = 'checked="checked"';
|
58 |
-
} else {
|
59 |
-
$custom_gateway_hide = "style='display:none;'";
|
60 |
-
$custom_gateway2 = 'checked="checked"';
|
61 |
-
}
|
62 |
-
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
63 |
-
wpsc_settings_page_update_notification(); ?>
|
64 |
-
<table id='gateway_options' >
|
65 |
-
<tr>
|
66 |
-
<td class='select_gateway'>
|
67 |
-
<div class='postbox'>
|
68 |
-
<h3 class='hndle'><?php _e( 'General Settings', 'wpsc' ); ?></h3>
|
69 |
-
<div class='inside'>
|
70 |
-
<p><?php _e( 'Activate the payment gateways that you want to make available to your customers by selecting them below.', 'wpsc' ); ?></p>
|
71 |
-
<br />
|
72 |
-
<?php
|
73 |
-
$selected_gateways = get_option( 'custom_gateway_options' );
|
74 |
-
foreach ( $nzshpcrt_gateways as $gateway ) {
|
75 |
-
if ( isset( $gateway['admin_name'] ) )
|
76 |
-
$gateway['name'] = $gateway['admin_name'];
|
77 |
-
|
78 |
-
if ( in_array( $gateway['internalname'], (array)$selected_gateways ) ) {
|
79 |
-
?>
|
80 |
-
|
81 |
-
<div class="wpsc_shipping_options">
|
82 |
-
<div class='wpsc-shipping-actions wpsc-payment-actions'>
|
83 |
-
| <span class="edit">
|
84 |
-
<a class='edit-payment-module' rel="<?php echo $gateway['internalname']; ?>" onclick="event.preventDefault();" title="Edit this Payment Module" href='<?php echo htmlspecialchars( add_query_arg( 'payment_module', $gateway['internalname'] ) ); ?>' style="cursor:pointer;">Edit</a>
|
85 |
-
</span> |
|
86 |
-
</div>
|
87 |
-
<p><input name='wpsc_options[custom_gateway_options][]' checked='checked' type='checkbox' value='<?php esc_attr_e( $gateway['internalname'] ); ?>' id='<?php esc_attr_e( $gateway['internalname'] ); ?>_id' />
|
88 |
-
<label for='<?php esc_attr_e( $gateway['internalname'] ); ?>_id'><?php esc_attr_e( $gateway['name'] ); ?></label></p>
|
89 |
-
</div>
|
90 |
-
<?php } else { ?>
|
91 |
-
<div class="wpsc_shipping_options">
|
92 |
-
<div class='wpsc-shipping-actions wpsc-payment-actions'>
|
93 |
-
| <span class="edit">
|
94 |
-
<a class='edit-payment-module' rel="<?php echo $gateway['internalname']; ?>" onclick="event.preventDefault();" title="Edit this Payment Module" href='<?php echo htmlspecialchars( add_query_arg( 'payment_module', $gateway['internalname'] ) ); ?>' style="cursor:pointer;"><?php _e( 'Edit' , 'wpsc' ); ?></a>
|
95 |
-
</span> |
|
96 |
-
</div>
|
97 |
-
<p><input name='wpsc_options[custom_gateway_options][]' type='checkbox' value='<?php echo $gateway['internalname']; ?>' id='<?php echo $gateway['internalname']; ?>_id' />
|
98 |
-
<label for='<?php echo $gateway['internalname']; ?>_id'><?php echo $gateway['name']; ?></label></p></div>
|
99 |
-
<?php
|
100 |
-
}
|
101 |
-
}
|
102 |
-
?>
|
103 |
-
<div class='submit gateway_settings'>
|
104 |
-
<input type='hidden' value='true' name='update_gateways' />
|
105 |
-
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ) ?>' name='updateoption' />
|
106 |
-
</div>
|
107 |
-
</div>
|
108 |
-
</div>
|
109 |
-
|
110 |
-
<h4><?php _e( 'We Recommend', 'wpsc' ); ?></h4>
|
111 |
-
<a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php echo WPSC_CORE_IMAGES_URL; ?>/paypal-referal.gif" border="0" alt="Sign up for PayPal and start accepting credit card payments instantly." /></a> <br /><br />
|
112 |
-
<a style="border-bottom:none;" href="http://checkout.google.com/sell/?promo=seinstinct" target="_blank"><img src="https://checkout.google.com/buyer/images/google_checkout.gif" border="0" alt="Sign up for Google Checkout" /></a>
|
113 |
-
|
114 |
-
</td>
|
115 |
-
|
116 |
-
<td class='gateway_settings' rowspan='2'>
|
117 |
-
<div class='postbox'>
|
118 |
-
<?php
|
119 |
-
|
120 |
-
if ( !isset( $_SESSION['previous_payment_name'] ) )
|
121 |
-
$_SESSION['previous_payment_name'] = "";
|
122 |
-
if ( !isset( $selected_gateway_data ) )
|
123 |
-
$selected_gateway_data = "";
|
124 |
-
$payment_data = wpsc_get_payment_form( $_SESSION['previous_payment_name'], $selected_gateway_data );
|
125 |
-
?>
|
126 |
-
<h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
|
127 |
-
<div class='inside'>
|
128 |
-
<table class='form-table'>
|
129 |
-
<?php echo $payment_data['form_fields']; ?>
|
130 |
-
</table>
|
131 |
-
<?php
|
132 |
-
if ( $payment_data['has_submit_button'] == 0 )
|
133 |
-
$update_button_css = 'style= "display: none;"';
|
134 |
-
else
|
135 |
-
$update_button_css = '';
|
136 |
-
?>
|
137 |
-
<div class='submit' <?php echo $update_button_css; ?>>
|
138 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
139 |
-
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ) ?>' name='updateoption' />
|
140 |
-
</div>
|
141 |
-
</div>
|
142 |
-
</td>
|
143 |
-
</tr>
|
144 |
-
</table>
|
145 |
-
</form>
|
146 |
-
</div>
|
147 |
-
</div>
|
148 |
-
|
149 |
-
<?php
|
150 |
-
}
|
151 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-pages/import.php
DELETED
@@ -1,170 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* This file handles the standard importing of products through a csv file upload. Access this page via WP-admin Settings>Import
|
5 |
-
* @package WP e-Commerce
|
6 |
-
*/
|
7 |
-
function wpsc_options_import() {
|
8 |
-
global $wpdb;
|
9 |
-
?>
|
10 |
-
<form name='cart_options' enctype='multipart/form-data' id='cart_options' method='post' action='<?php echo 'admin.php?page=wpsc-settings&tab=import'; ?>' class='wpsc_form_track'>
|
11 |
-
<div class="wrap">
|
12 |
-
<?php _e( '<p>You can import your products from a comma delimited text file.</p><p>An example of a csv import file would look like this: </p><p>Description, Additional Description, Product Name, Price, SKU, weight, weight unit, stock quantity, is limited quantity</p>', 'wpsc' ); ?>
|
13 |
-
|
14 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
15 |
-
<input type='hidden' name='MAX_FILE_SIZE' value='5000000' />
|
16 |
-
<input type='file' name='csv_file' />
|
17 |
-
<input type='submit' value='Import' class='button-primary'>
|
18 |
-
<?php
|
19 |
-
if ( isset( $_FILES['csv_file']['name'] ) && ($_FILES['csv_file']['name'] != '') ) {
|
20 |
-
ini_set( "auto_detect_line_endings", 1 );
|
21 |
-
$file = $_FILES['csv_file'];
|
22 |
-
if ( move_uploaded_file( $file['tmp_name'], WPSC_FILE_DIR . $file['name'] ) ) {
|
23 |
-
$content = file_get_contents( WPSC_FILE_DIR . $file['name'] );
|
24 |
-
$handle = @fopen( WPSC_FILE_DIR . $file['name'], 'r' );
|
25 |
-
while ( ($csv_data = @fgetcsv( $handle, filesize( $handle ), "," )) !== false ) {
|
26 |
-
$fields = count( $csv_data );
|
27 |
-
for ( $i = 0; $i < $fields; $i++ ) {
|
28 |
-
if ( !is_array( $data1[$i] ) ) {
|
29 |
-
$data1[$i] = array( );
|
30 |
-
}
|
31 |
-
array_push( $data1[$i], $csv_data[$i] );
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
$_SESSION['cvs_data'] = $data1;
|
36 |
-
$categories = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $category_id );
|
37 |
-
?>
|
38 |
-
|
39 |
-
<p><?php _e( 'For each column, select the field it corresponds to in \'Belongs to\'. You can upload as many products as you like.', 'wpsc' ); ?></p>
|
40 |
-
<div class='metabox-holder' style='width:90%'>
|
41 |
-
<input type='hidden' name='csv_action' value='import'>
|
42 |
-
|
43 |
-
<div style='width:100%;' class='postbox'>
|
44 |
-
<h3 class='hndle'><?php _e('Product Status' , 'wpsc' ); ?></h3>
|
45 |
-
<div class='inside'>
|
46 |
-
<table>
|
47 |
-
<tr><td style='width:80%;'>
|
48 |
-
<?php _e( 'Select if you would like to import your products in as Drafts or Publish them right away.' , 'wpsc' ); ?>
|
49 |
-
<br />
|
50 |
-
</td><td>
|
51 |
-
<select name='post_status'>
|
52 |
-
<option value='publish'><?php _e('Publish', 'wpsc'); ?></option>
|
53 |
-
<option value='draft'><?php _e('Draft', 'wpsc'); ?></option>
|
54 |
-
</select>
|
55 |
-
</td></tr>
|
56 |
-
</table>
|
57 |
-
</div>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
<?php
|
61 |
-
foreach ( (array)$data1 as $key => $datum ) {
|
62 |
-
?>
|
63 |
-
<div style='width:100%;' class='postbox'>
|
64 |
-
<h3 class='hndle'><?php printf(__('Column (%s)', 'wpsc'), ($key + 1)); ?></h3>
|
65 |
-
<div class='inside'>
|
66 |
-
<table>
|
67 |
-
<tr><td style='width:80%;'>
|
68 |
-
<input type='hidden' name='column[]' value='<?php echo $key + 1; ?>'>
|
69 |
-
<?php
|
70 |
-
foreach ( $datum as $column ) {
|
71 |
-
echo $column;
|
72 |
-
break;
|
73 |
-
} ?>
|
74 |
-
<br />
|
75 |
-
</td><td>
|
76 |
-
<select name='value_name[]'>
|
77 |
-
<!-- /* These are the current fields that can be imported with products, to add additional fields add more <option> to this dorpdown list */ -->
|
78 |
-
<option value='name'><?php _e('Product Name', 'wpsc'); ?></option>
|
79 |
-
<option value='description'><?php _e('Description', 'wpsc'); ?></option>
|
80 |
-
<option value='additional_description'><?php _e('Additional Description', 'wpsc'); ?></option>
|
81 |
-
<option value='price'><?php _e('Price', 'wpsc'); ?></option>
|
82 |
-
<option value='sku'><?php _e('SKU', 'wpsc'); ?></option>
|
83 |
-
<option value='weight'><?php _e('Weight', 'wpsc'); ?></option>
|
84 |
-
<option value='weight_unit'><?php _e('Weight Unit', 'wpsc'); ?></option>
|
85 |
-
<option value='quantity'><?php _e('Stock Quantity', 'wpsc'); ?></option>
|
86 |
-
<option value='quantity_limited'><?php _e('Stock Quantity Limit', 'wpsc'); ?></option>
|
87 |
-
</select>
|
88 |
-
</td></tr>
|
89 |
-
</table>
|
90 |
-
</div>
|
91 |
-
</div>
|
92 |
-
<?php } ?>
|
93 |
-
<label for='category'><?php _e('Please select a category you would like to place all products from this CSV into' , 'wpsc' ); ?>:</label>
|
94 |
-
<select id='category' name='category'>
|
95 |
-
<?php
|
96 |
-
foreach ( $categories as $category ) {
|
97 |
-
echo '<option value="' . $category->term_id . '">' . $category->name . '</option>';
|
98 |
-
}
|
99 |
-
?>
|
100 |
-
</select>
|
101 |
-
<input type='submit' value='Import' class='button-primary'>
|
102 |
-
</div>
|
103 |
-
<?php
|
104 |
-
} else {
|
105 |
-
echo "<br /><br />" . __('There was an error while uploading your csv file.', 'wpsc');
|
106 |
-
}
|
107 |
-
}
|
108 |
-
if ( isset( $_POST['csv_action'] ) && ('import' == $_POST['csv_action']) ) {
|
109 |
-
global $wpdb;
|
110 |
-
$cvs_data = $_SESSION['cvs_data'];
|
111 |
-
$column_data = $_POST['column'];
|
112 |
-
$value_data = $_POST['value_name'];
|
113 |
-
|
114 |
-
$status = esc_attr($_POST['post_status']);
|
115 |
-
|
116 |
-
$name = array( );
|
117 |
-
foreach ( $value_data as $key => $value ) {
|
118 |
-
|
119 |
-
$cvs_data2[$value] = $cvs_data[$key];
|
120 |
-
}
|
121 |
-
$num = count( $cvs_data2['name'] );
|
122 |
-
|
123 |
-
for ( $i = 0; $i < $num; $i++ ) {
|
124 |
-
$product_columns = array(
|
125 |
-
'post_title' => esc_attr( $cvs_data2['name'][$i] ),
|
126 |
-
'content' => esc_attr( $cvs_data2['description'][$i] ),
|
127 |
-
'additional_description' => esc_attr( $cvs_data2['additional_description'][$i] ),
|
128 |
-
'price' => esc_attr( str_replace( '$', '', $cvs_data2['price'][$i] ) ),
|
129 |
-
'weight' => esc_attr( $cvs_data2['weight'][$i] ),
|
130 |
-
'weight_unit' => esc_attr( $cvs_data2['weight_unit'][$i] ),
|
131 |
-
'pnp' => null,
|
132 |
-
'international_pnp' => null,
|
133 |
-
'file' => null,
|
134 |
-
'image' => '0',
|
135 |
-
'quantity_limited' => esc_attr( $cvs_data2['quantity_limited'][$i] ),
|
136 |
-
'quantity' => esc_attr( $cvs_data2['quantity'][$i] ),
|
137 |
-
'special' => null,
|
138 |
-
'special_price' => null,
|
139 |
-
'display_frontpage' => null,
|
140 |
-
'notax' => null,
|
141 |
-
'active' => null,
|
142 |
-
'donation' => null,
|
143 |
-
'no_shipping' => null,
|
144 |
-
'thumbnail_image' => null,
|
145 |
-
'thumbnail_state' => null,
|
146 |
-
'meta' => array(
|
147 |
-
'_wpsc_price' => esc_attr( str_replace( '$', '', $cvs_data2['price'][$i] ) ),
|
148 |
-
'_wpsc_sku' => esc_attr( $cvs_data2['sku'][$i] ),
|
149 |
-
'_wpsc_stock' => esc_attr( $cvs_data2['quantity'][$i] ),
|
150 |
-
'_wpsc_limited_stock' => esc_attr( $cvs_data2['quantity_limited'][$i] ),
|
151 |
-
'_wpsc_product_metadata' => array(
|
152 |
-
'weight' => esc_attr( $cvs_data2['weight'][$i] ),
|
153 |
-
'weight_unit' => esc_attr( $cvs_data2['weight_unit'][$i] ),
|
154 |
-
)
|
155 |
-
)
|
156 |
-
);
|
157 |
-
$product_columns = wpsc_sanitise_product_forms( $product_columns );
|
158 |
-
// status needs to be set here because wpsc_sanitise_product_forms overwrites it :/
|
159 |
-
$product_columns['post_status'] = $status;
|
160 |
-
$product_id = wpsc_insert_product( $product_columns );
|
161 |
-
wp_set_object_terms( $product_id , array( (int)$_POST['category'] ) , 'wpsc_product_category' );
|
162 |
-
}
|
163 |
-
echo "<br /><br />". sprintf(__("Success, your <a href='%s'>products</a> have been upload.", "wpsc"), admin_url('edit.php?post_type=wpsc-product'));
|
164 |
-
}
|
165 |
-
?>
|
166 |
-
</div>
|
167 |
-
</form>
|
168 |
-
<?php
|
169 |
-
}
|
170 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-pages/marketing.php
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* options marketing is the main function for displaying the WP-Admin : Settings > Marketing page
|
4 |
-
* @access public
|
5 |
-
*
|
6 |
-
* @since 3.8
|
7 |
-
* @param null
|
8 |
-
* @return null
|
9 |
-
*/
|
10 |
-
function wpsc_options_marketing() {
|
11 |
-
|
12 |
-
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
13 |
-
wpsc_settings_page_update_notification(); ?>
|
14 |
-
|
15 |
-
<div class='metabox-holder'>
|
16 |
-
<?php
|
17 |
-
add_meta_box( 'wpsc_marketing_settings', __( 'Marketing Section', 'wpsc' ), 'wpsc_marketing_meta_box', 'wpsc' );
|
18 |
-
add_meta_box( 'wpsc_rss_address', __( 'RSS Address', 'wpsc' ), 'wpsc_rss_address_meta_box', 'wpsc' );
|
19 |
-
add_meta_box( 'wpsc_google_merch_center', __( 'Google Merchant Centre / Google Product Search', 'wpsc' ), 'wpsc_google_merch_center_meta_box', 'wpsc' );
|
20 |
-
|
21 |
-
do_meta_boxes( 'wpsc', 'advanced', null );
|
22 |
-
?>
|
23 |
-
|
24 |
-
</div>
|
25 |
-
|
26 |
-
<?php
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
function wpsc_marketing_meta_box() {
|
31 |
-
|
32 |
-
$wpsc_also_bought = get_option( 'wpsc_also_bought' );
|
33 |
-
$wpsc_also_bought1 = '';
|
34 |
-
|
35 |
-
if ( '1' == $wpsc_also_bought )
|
36 |
-
$wpsc_also_bought1 = "checked ='checked'";
|
37 |
-
|
38 |
-
$wpsc_share_this = get_option( 'wpsc_share_this' );
|
39 |
-
$wpsc_share_this1 = '';
|
40 |
-
|
41 |
-
if ( '1' == $wpsc_share_this )
|
42 |
-
$wpsc_share_this1 = "checked ='checked'";
|
43 |
-
|
44 |
-
$facebook_like = get_option( 'wpsc_facebook_like' );
|
45 |
-
$facebook_like1 = '';
|
46 |
-
if ( 'on' == $facebook_like )
|
47 |
-
$facebook_like1 = "checked ='checked'";
|
48 |
-
|
49 |
-
$display_find_us = get_option( 'display_find_us' );
|
50 |
-
$display_find_us1 = '';
|
51 |
-
|
52 |
-
if ( '1' == $display_find_us )
|
53 |
-
$display_find_us1 = "checked ='checked'"; ?>
|
54 |
-
|
55 |
-
|
56 |
-
<form method='post' action='' id='cart_options' name='cart_options' class='wpsc_form_track'>
|
57 |
-
<input type='hidden' name='change-settings' value='true' />
|
58 |
-
<p>
|
59 |
-
<span class='input_label'><?php _e( 'Display Cross Sales', 'wpsc' ); ?></span>
|
60 |
-
<input <?php echo $wpsc_also_bought1; ?> type='checkbox' name='wpsc_also_bought' />
|
61 |
-
<span class='description'> <?php _e( 'Adds the \'Users who bought this also bought\' item to the single products page.', 'wpsc' ); ?></span>
|
62 |
-
</p><br />
|
63 |
-
<p>
|
64 |
-
<span class='input_label'><?php _e( 'Show Share This (Social Bookmarks)', 'wpsc' ); ?></span>
|
65 |
-
<input <?php echo $wpsc_share_this1; ?> type='checkbox' name='wpsc_share_this' />
|
66 |
-
<span class='description'> <?php _e( 'Adds the \'Share this link\' item to the single products page.', 'wpsc' ); ?></span>
|
67 |
-
</p><br />
|
68 |
-
<p>
|
69 |
-
<span class='input_label'> <?php _e( 'Display How Customer Found Us Survey', 'wpsc' ) ?></span>
|
70 |
-
<input <?php echo $display_find_us1; ?> type='checkbox' name='display_find_us' />
|
71 |
-
<span class='description'> <?php _e( 'Adds the \'How did you find out about us\' drop-down option at checkout.', 'wpsc' ) ?></span>
|
72 |
-
</p><br />
|
73 |
-
<p>
|
74 |
-
<span class='input_label'> <?php _e( 'Display Facebook Like', 'wpsc' ) ?></span>
|
75 |
-
<input type='hidden' value='0' name='wpsc_options[wpsc_facebook_like]' />
|
76 |
-
<input <?php echo $facebook_like1; ?> type='checkbox' name='wpsc_options[wpsc_facebook_like]' />
|
77 |
-
<span class='description'> <?php _e( 'Adds the Facebook Like button on your single products page.', 'wpsc' ) ?></span>
|
78 |
-
</p><br />
|
79 |
-
<div class="submit">
|
80 |
-
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
81 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
82 |
-
<input type='submit' class='button-primary' value='<?php _e( 'Update »', 'wpsc' ); ?>' name='form_submit' />
|
83 |
-
</div>
|
84 |
-
</form>
|
85 |
-
|
86 |
-
<?php
|
87 |
-
}
|
88 |
-
|
89 |
-
function wpsc_rss_address_meta_box() { ?>
|
90 |
-
|
91 |
-
<p><?php _e( 'People can use this RSS feed to keep up to date with your product list.', 'wpsc' ); ?></p>
|
92 |
-
<p><?php _e( 'RSS Feed Address', 'wpsc' ) ?> : <?php echo get_bloginfo( 'url' ) . "/index.php?rss=true&action=product_list"; ?></p>
|
93 |
-
|
94 |
-
<?php
|
95 |
-
}
|
96 |
-
|
97 |
-
function wpsc_google_merch_center_meta_box() { ?>
|
98 |
-
|
99 |
-
<p><?php _e( 'To import your products into <a href="http://www.google.com/merchants/" target="_blank">Google Merchant Centre</a> so that they appear within Google Product Search results, sign up for a Google Merchant Centre account and add a scheduled data feed with the following URL:', 'wpsc' ); ?></p>
|
100 |
-
|
101 |
-
<?php $google_feed_url = get_bloginfo( 'url' ) . "/index.php?rss=true&action=product_list&xmlformat=google"; ?>
|
102 |
-
|
103 |
-
<a href="<?php esc_attr_e( htmlentities( $google_feed_url, ENT_QUOTES, 'UTF-8' ) ); ?>"><?php esc_attr_e( htmlentities( $google_feed_url, ENT_QUOTES, 'UTF-8' ) ); ?></a>
|
104 |
-
|
105 |
-
<?php
|
106 |
-
}
|
107 |
-
|
108 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-pages/shipping.php
DELETED
@@ -1,274 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function wpsc_options_shipping() {
|
4 |
-
global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
|
5 |
-
// sort into external and internal arrays.
|
6 |
-
foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
|
7 |
-
if(empty($module))continue;
|
8 |
-
if ( isset( $module->is_external ) && ($module->is_external == true) ) {
|
9 |
-
$external_shipping_modules[$key] = $module;
|
10 |
-
} else {
|
11 |
-
$internal_shipping_modules[$key] = $module;
|
12 |
-
}
|
13 |
-
}
|
14 |
-
$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 );
|
15 |
-
if ( $currency_data['symbol'] != '' ) {
|
16 |
-
$currency_sign = $currency_data['symbol_html'];
|
17 |
-
} else {
|
18 |
-
$currency_sign = $currency_data['code'];
|
19 |
-
}
|
20 |
-
//get shipping options that are selected
|
21 |
-
$selected_shippings = get_option( 'custom_shipping_options' );
|
22 |
-
?>
|
23 |
-
<form name='cart_options' id='cart_options' method='post' action='' class='wpsc_form_track'>
|
24 |
-
|
25 |
-
<script type='text/javascript'>
|
26 |
-
function selectgateway() {
|
27 |
-
document.forms.shippingopt.submit();
|
28 |
-
}
|
29 |
-
</script>
|
30 |
-
<div class="wrap">
|
31 |
-
<div class="metabox-holder">
|
32 |
-
<form name='shippingopt' method='post' id='shipping_options' action='' class='wpsc_form_track'>
|
33 |
-
<input type='hidden' name='shipping_submits' value='true' />
|
34 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
35 |
-
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
36 |
-
|
37 |
-
<?php
|
38 |
-
|
39 |
-
if ( !isset( $_SESSION['previous_shipping_name'] ) )
|
40 |
-
$_SESSION['previous_shipping_name'] = "";
|
41 |
-
|
42 |
-
$shipping_data = wpsc_get_shipping_form( $_SESSION['previous_shipping_name'] );
|
43 |
-
|
44 |
-
if ( get_option( 'custom_gateway' ) == 1 ) {
|
45 |
-
$custom_gateway_hide = "style='display:block;'";
|
46 |
-
$custom_gateway1 = 'checked="checked"';
|
47 |
-
} else {
|
48 |
-
$custom_gateway_hide = "style='display:none;'";
|
49 |
-
$custom_gateway2 = 'checked="checked"';
|
50 |
-
}
|
51 |
-
if ( $shipping_data['has_submit_button'] == 0 )
|
52 |
-
$update_button_css = 'style= "display: none;"';
|
53 |
-
else
|
54 |
-
$update_button_css = '';
|
55 |
-
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
56 |
-
wpsc_settings_page_update_notification(); ?>
|
57 |
-
<div class='postbox'>
|
58 |
-
<h3 class='hndle'><?php _e( 'General Settings', 'wpsc' ); ?></h3>
|
59 |
-
<div class='inside'>
|
60 |
-
|
61 |
-
<table class='wpsc_options form-table'>
|
62 |
-
<tr>
|
63 |
-
<th scope="row">
|
64 |
-
<?php _e( 'Use Shipping', 'wpsc' ); ?>:
|
65 |
-
</th>
|
66 |
-
<td>
|
67 |
-
<?php
|
68 |
-
$do_not_use_shipping = get_option( 'do_not_use_shipping' );
|
69 |
-
$do_not_use_shipping1 = "";
|
70 |
-
$do_not_use_shipping2 = "";
|
71 |
-
if( $do_not_use_shipping )
|
72 |
-
$do_not_use_shipping1 = "checked ='checked'";
|
73 |
-
else
|
74 |
-
$do_not_use_shipping2 = "checked ='checked'";
|
75 |
-
?>
|
76 |
-
<input type='radio' value='0' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping2' <?php echo $do_not_use_shipping2; ?> /> <label for='do_not_use_shipping2'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
77 |
-
<input type='radio' value='1' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping1' <?php echo $do_not_use_shipping1; ?> /> <label for='do_not_use_shipping1'><?php _e( 'No', 'wpsc' ); ?></label><br />
|
78 |
-
<?php _e( 'If you are only selling digital downloads, you should select no to disable the shipping on your site.', 'wpsc' ); ?>
|
79 |
-
</td>
|
80 |
-
</tr>
|
81 |
-
|
82 |
-
<tr>
|
83 |
-
<th><?php _e( 'Base City:', 'wpsc' ); ?></th>
|
84 |
-
<td>
|
85 |
-
<input type='text' name='wpsc_options[base_city]' value='<?php esc_attr_e( get_option( 'base_city' ) ); ?>' />
|
86 |
-
<br /><?php _e( 'Please provide for more accurate rates', 'wpsc' ); ?>
|
87 |
-
</td>
|
88 |
-
</tr>
|
89 |
-
<tr>
|
90 |
-
<th><?php _e( 'Base Zipcode/Postcode:', 'wpsc' ); ?></th>
|
91 |
-
<td>
|
92 |
-
<input type='text' name='wpsc_options[base_zipcode]' value='<?php esc_attr_e( get_option( 'base_zipcode' ) ); ?>' />
|
93 |
-
<br /><?php _e( '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.', 'wpsc' ); ?>
|
94 |
-
</td>
|
95 |
-
</tr>
|
96 |
-
<?php
|
97 |
-
$shipwire1 = "";
|
98 |
-
$shipwire2 = "";
|
99 |
-
switch ( get_option( 'shipwire' ) ) {
|
100 |
-
case 1:
|
101 |
-
$shipwire1 = "checked ='checked'";
|
102 |
-
$shipwire_settings = 'style=\'display: block;\'';
|
103 |
-
break;
|
104 |
-
|
105 |
-
case 0:
|
106 |
-
default:
|
107 |
-
$shipwire2 = "checked ='checked'";
|
108 |
-
$shipwire_settings = '';
|
109 |
-
break;
|
110 |
-
}
|
111 |
-
?>
|
112 |
-
|
113 |
-
<tr>
|
114 |
-
<th scope="row">
|
115 |
-
<?php _e( 'ShipWire Settings', 'wpsc' ); ?><span style='color: red;'></span> :
|
116 |
-
</th>
|
117 |
-
<td>
|
118 |
-
<input type='radio' onclick='jQuery("#wpsc_shipwire_setting").show()' value='1' name='wpsc_options[shipwire]' id='shipwire1' <?php echo $shipwire1; ?> /> <label for='shipwire1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
119 |
-
<input type='radio' onclick='jQuery("#wpsc_shipwire_setting").hide()' value='0' name='wpsc_options[shipwire]' id='shipwire2' <?php echo $shipwire2; ?> /> <label for='shipwire2'><?php _e( 'No', 'wpsc' ); ?></label>
|
120 |
-
<?php
|
121 |
-
$shipwireemail = esc_attr_e( get_option( "shipwireemail" ) );
|
122 |
-
$shipwirepassword = esc_attr_e( get_option( "shipwirepassword" ) );
|
123 |
-
?>
|
124 |
-
<div id='wpsc_shipwire_setting' <?php echo $shipwire_settings; ?>>
|
125 |
-
<table>
|
126 |
-
<tr><td><?php _e( 'ShipWire Email', 'wpsc' ); ?> :</td><td> <input type="text" name='wpsc_options[shipwireemail]' value="<?php echo $shipwireemail; ?>" /></td></tr>
|
127 |
-
<tr><td><?php _e( 'ShipWire Password', 'wpsc' ); ?> :</td><td><input type="text" name='wpsc_options[shipwirepassword]' value="<?php echo $shipwirepassword; ?>" /></td></tr>
|
128 |
-
<tr><td><a onclick='shipwire_sync()' style="cursor:pointer;">Sync product</a></td></tr>
|
129 |
-
</table>
|
130 |
-
</div>
|
131 |
-
</td>
|
132 |
-
</tr>
|
133 |
-
<tr>
|
134 |
-
<th scope="row">
|
135 |
-
<?php _e( 'Enable Free Shipping Discount', 'wpsc' ); ?>
|
136 |
-
</th>
|
137 |
-
<td>
|
138 |
-
<?php
|
139 |
-
if ( get_option( 'shipping_discount' ) == 1 ) {
|
140 |
-
$selected2 = '';
|
141 |
-
$selected1 = 'checked="checked"';
|
142 |
-
$shipping_discount_settings = 'style=\'display: block;\'';
|
143 |
-
} else {
|
144 |
-
$selected2 = 'checked="checked"';
|
145 |
-
$selected1 = '';
|
146 |
-
$shipping_discount_settings = '';
|
147 |
-
}
|
148 |
-
?>
|
149 |
-
<input type='radio' onclick='jQuery("#shipping_discount_value").show()' value='1' name='wpsc_options[shipping_discount]' id='shipping_discount1' <?php echo $selected1; ?> /> <label for='shipping_discount1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
150 |
-
<input type='radio' onclick='jQuery("#shipping_discount_value").hide()' value='0' name='wpsc_options[shipping_discount]' id='shipping_discount2' <?php echo $selected2; ?> /> <label for='shipping_discount2'><?php _e( 'No', 'wpsc' ); ?></label>
|
151 |
-
|
152 |
-
</td>
|
153 |
-
</tr>
|
154 |
-
<tr>
|
155 |
-
<td> </td>
|
156 |
-
<td colspan="2">
|
157 |
-
<?php
|
158 |
-
$value = esc_attr ( get_option( 'shipping_discount_value' ) );
|
159 |
-
?>
|
160 |
-
<div <?php echo $shipping_discount_settings; ?> id='shipping_discount_value'>
|
161 |
-
|
162 |
-
<?php printf(__('Sales over or equal to: %1$s<input type="text" size="6" name="wpsc_options[shipping_discount_value]" value="%2$s" id="shipping_discount_value" /> will receive free shipping.', 'wpsc'), $currency_sign, $value ); ?>
|
163 |
-
</div>
|
164 |
-
|
165 |
-
|
166 |
-
</td>
|
167 |
-
|
168 |
-
</tr>
|
169 |
-
<tr>
|
170 |
-
<td>
|
171 |
-
<div class='submit' <?php echo $update_button_css; ?>>
|
172 |
-
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ); ?>' name='updateoption' />
|
173 |
-
</div>
|
174 |
-
</td>
|
175 |
-
</tr>
|
176 |
-
<?php do_action('wpsc_shipping_settings_page'); ?>
|
177 |
-
|
178 |
-
</table>
|
179 |
-
</div>
|
180 |
-
</div>
|
181 |
-
<table id='gateway_options' >
|
182 |
-
<tr>
|
183 |
-
<td class='select_gateway'>
|
184 |
-
<a name="gateway_options"></a>
|
185 |
-
<div class='postbox'>
|
186 |
-
<h3 class='hndle'><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
|
187 |
-
<div class='inside'>
|
188 |
-
|
189 |
-
<p>
|
190 |
-
<?php _e( 'To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site.<br /> If you want to use fixed-price shipping options like "Pickup - $0, Overnight - $10, Same day - $20, etc." you can download a WordPress plugin from plugins directory for <a href="http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/">Simple shipping</a>. It will appear in the list as "Fixed rate".', 'wpsc' ); ?>
|
191 |
-
</p>
|
192 |
-
<br />
|
193 |
-
<p>
|
194 |
-
<strong><?php _e( 'Internal Shipping Calculators', 'wpsc' ); ?></strong>
|
195 |
-
</p>
|
196 |
-
<?php
|
197 |
-
foreach ( $internal_shipping_modules as $shipping ) {
|
198 |
-
|
199 |
-
$shipping->checked = '';
|
200 |
-
if ( is_object( $shipping ) && in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
|
201 |
-
$shipping->checked = ' checked = "checked" ';
|
202 |
-
?>
|
203 |
-
|
204 |
-
<div class='wpsc_shipping_options'>
|
205 |
-
<div class='wpsc-shipping-actions'>
|
206 |
-
| <span class="edit">
|
207 |
-
<a class='edit-shipping-module' rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg('tab', 'shipping' , add_query_arg('page', 'wpsc-settings' , add_query_arg( 'shipping_module', $shipping->internal_name ) ) ) ); ?>#gateway_options' style="cursor:pointer;">Edit</a>
|
208 |
-
</span> |
|
209 |
-
</div>
|
210 |
-
|
211 |
-
<p><input name='custom_shipping_options[]' <?php echo $shipping->checked; ?> 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>
|
212 |
-
</div>
|
213 |
-
<?php } ?>
|
214 |
-
<br />
|
215 |
-
<p>
|
216 |
-
<strong><?php _e( 'External Shipping Calculators', 'wpsc' ); ?></strong>
|
217 |
-
<?php if ( !function_exists( 'curl_init' ) ) {
|
218 |
-
?>
|
219 |
-
<br /><span style='color: red; font-size:8pt; line-height:10pt;'><?php _e( '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. ', 'wpsc' ); ?></span>
|
220 |
-
<?php } ?>
|
221 |
-
</p>
|
222 |
-
<?php
|
223 |
-
// print the internal shipping methods
|
224 |
-
foreach ( $external_shipping_modules as $shipping ) {
|
225 |
-
$disabled = '';
|
226 |
-
if ( isset($shipping->requires_curl) && ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
|
227 |
-
$disabled = "disabled='disabled'";
|
228 |
-
}
|
229 |
-
$shipping->checked = '';
|
230 |
-
if ( in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
|
231 |
-
$shipping->checked = " checked='checked' ";
|
232 |
-
?>
|
233 |
-
<div class='wpsc_shipping_options'>
|
234 |
-
<div class="wpsc-shipping-actions">
|
235 |
-
| <span class="edit">
|
236 |
-
<a class='edit-shippping-module' rel="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo htmlspecialchars( add_query_arg('tab', 'shipping' , add_query_arg('page', 'wpsc-settings' , add_query_arg( 'shipping_module', $shipping->internal_name ) ) ) ); ?>#gateway_options' style="cursor:pointer;"><?php _e( 'Edit' , 'wpsc' ); ?></a>
|
237 |
-
</span> |
|
238 |
-
</div>
|
239 |
-
<p><input <?php echo $disabled; ?> name='custom_shipping_options[]' <?php echo $shipping->checked; ?> type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php esc_attr_e( $shipping->name ); ?></label></p>
|
240 |
-
</div>
|
241 |
-
<?php } ?>
|
242 |
-
|
243 |
-
<div class='submit gateway_settings'>
|
244 |
-
<input type='hidden' value='true' name='update_gateways'/>
|
245 |
-
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ); ?>' name='updateoption'/>
|
246 |
-
</div>
|
247 |
-
|
248 |
-
</div>
|
249 |
-
</div>
|
250 |
-
</td>
|
251 |
-
|
252 |
-
<td class='gateway_settings' rowspan='2'>
|
253 |
-
<div class='postbox'>
|
254 |
-
<h3 class='hndle'><?php esc_html( $shipping_data['name'] ); ?></h3>
|
255 |
-
<div class='inside'>
|
256 |
-
<table class='form-table'>
|
257 |
-
<?php echo $shipping_data['form_fields']; ?>
|
258 |
-
</table>
|
259 |
-
|
260 |
-
<div class='submit' <?php echo $update_button_css; ?>>
|
261 |
-
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ); ?>' name='updateoption' />
|
262 |
-
</div>
|
263 |
-
</div>
|
264 |
-
</div>
|
265 |
-
</td>
|
266 |
-
</tr>
|
267 |
-
</table>
|
268 |
-
</form>
|
269 |
-
</div>
|
270 |
-
</div>
|
271 |
-
</form>
|
272 |
-
<?php
|
273 |
-
}
|
274 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-pages/taxes.php
DELETED
@@ -1,188 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function wpec_options_taxes() {
|
4 |
-
$wpec_taxes_controller = new wpec_taxes_controller;
|
5 |
-
$wpec_taxes_options = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_options();
|
6 |
-
|
7 |
-
//include standard shopping cart notifications
|
8 |
-
wpsc_settings_page_update_notification();
|
9 |
-
?>
|
10 |
-
<form name='wpec_taxes_options' id='wpec_taxes_options' method='post' action='' class='wpsc_form_track'>
|
11 |
-
<div class="wrap">
|
12 |
-
<h3><?php _e( 'Tax Settings', 'wpsc' ); ?></h3>
|
13 |
-
<p>
|
14 |
-
<label for='wpec_taxes_enabled'>
|
15 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_enabled'] ) {
|
16 |
-
echo 'checked="checked"';
|
17 |
-
} ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
|
18 |
-
<?php _e( 'Turn tax on', 'wpsc' ); ?>
|
19 |
-
</label>
|
20 |
-
</p>
|
21 |
-
<p>
|
22 |
-
<label for='wpec_taxes_inprice1'>
|
23 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'exclusive' ) {
|
24 |
-
echo 'checked="checked"';
|
25 |
-
} ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
|
26 |
-
<?php _e( 'Product prices are tax exclusive - add tax to the price during checkout', 'wpsc' ); ?>
|
27 |
-
</label>
|
28 |
-
</p>
|
29 |
-
<p>
|
30 |
-
<label for='wpec_taxes_inprice2'>
|
31 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'inclusive' ) {
|
32 |
-
echo 'checked="checked"';
|
33 |
-
} ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
|
34 |
-
<?php _e( "Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item", 'wpsc' ); ?>
|
35 |
-
</label>
|
36 |
-
</p>
|
37 |
-
<h4><?php _e( 'Product Specific Tax', 'wpsc' ); ?></h4>
|
38 |
-
<p>
|
39 |
-
<label for='wpec_taxes_product_1'>
|
40 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'add' ) {
|
41 |
-
echo 'checked="checked"';
|
42 |
-
} ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
|
43 |
-
<?php _e( 'Add per product tax to tax percentage if product has a specific tax rate', 'wpsc' ); ?>
|
44 |
-
</label>
|
45 |
-
</p>
|
46 |
-
<p>
|
47 |
-
<label for='wpec_taxes_product_2'>
|
48 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'replace' ) {
|
49 |
-
echo 'checked="checked"';
|
50 |
-
} ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
|
51 |
-
<?php _e( 'Replace tax percentage with product specific tax rate', 'wpsc' ); ?>
|
52 |
-
</label>
|
53 |
-
</p>
|
54 |
-
|
55 |
-
<h4><?php _e( 'Tax Logic', 'wpsc' ); ?></h4>
|
56 |
-
<p>
|
57 |
-
<label for='wpec_taxes_logic_1'>
|
58 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
|
59 |
-
echo 'checked="checked"';
|
60 |
-
} ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
|
61 |
-
<?php _e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
|
62 |
-
</label>
|
63 |
-
<div id='billing_shipping_preference_container' style='margin-left: 20px;'>
|
64 |
-
<p>
|
65 |
-
<label for='wpec_billing_preference'>
|
66 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'billing_address' ) {
|
67 |
-
echo 'checked="checked"';
|
68 |
-
} ?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
69 |
-
<?php _e( 'Apply tax to Billing Address', 'wpsc' ); ?>
|
70 |
-
</label>
|
71 |
-
</p>
|
72 |
-
<p>
|
73 |
-
<label for='wpec_shipping_preference'>
|
74 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'shipping_address' ) {
|
75 |
-
echo 'checked="checked"';
|
76 |
-
} ?> type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
77 |
-
<?php _e( 'Apply tax to Shipping Address', 'wpsc' ); ?>
|
78 |
-
</label>
|
79 |
-
</p>
|
80 |
-
</div>
|
81 |
-
</p>
|
82 |
-
<p>
|
83 |
-
<label for='wpec_taxes_logic_2'>
|
84 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
|
85 |
-
echo 'checked="checked"';
|
86 |
-
} ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
|
87 |
-
<?php _e( 'Apply tax when Billing Country is the same as Tax Rate', 'wpsc' ); ?>
|
88 |
-
</label>
|
89 |
-
</p>
|
90 |
-
<p>
|
91 |
-
<label for='wpec_taxes_logic_3'>
|
92 |
-
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
|
93 |
-
echo 'checked="checked"';
|
94 |
-
} ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
|
95 |
-
<?php _e( 'Apply tax when Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
|
96 |
-
</label>
|
97 |
-
</p>
|
98 |
-
<div id='metabox-holder' class="metabox-holder">
|
99 |
-
<div id='wpec-taxes-rates-container' class='postbox'>
|
100 |
-
<h3 class='hndle' style='cursor: default'><?php _e( 'Tax Rates', 'wpsc' ); ?></h3>
|
101 |
-
<div id='wpec-taxes-rates' class='inside'>
|
102 |
-
<!--Start Taxes Output-->
|
103 |
-
<?php
|
104 |
-
/**
|
105 |
-
* Add New Tax Rate - should add another paragraph with the
|
106 |
-
another key specified for the input array
|
107 |
-
* Delete - Should remove the given paragraph from the page
|
108 |
-
and either ajax delete it from the DB or mark it for
|
109 |
-
deletion and process it after the changes are made.
|
110 |
-
* Selecting a Country - should automatically populate the
|
111 |
-
regions select box. Selecting a different country should
|
112 |
-
remove the region select box. If the user selects a
|
113 |
-
different country with regions it shouldn't matter because
|
114 |
-
the code should automatically add the region select in.
|
115 |
-
* - Allow users to define tax for entire country even if regions exist.
|
116 |
-
* Shipping Tax - needs to be per region or per tax rate.
|
117 |
-
Remove the setting from the main Tax Settings area.
|
118 |
-
* Constraints -
|
119 |
-
1. Should not allow a user to add more than one
|
120 |
-
tax rate for the same area.
|
121 |
-
2. If a country tax rate is specified and then a region tax
|
122 |
-
rate, the region tax rate takes precedence.
|
123 |
-
* */
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Removed Shipping Restriction on Included tax - 01-20-2011
|
127 |
-
//if tax is included warn about shipping
|
128 |
-
if ( $wpec_taxes_controller->wpec_taxes_isincluded() ) {
|
129 |
-
echo '<p>' . __( 'Note: Tax is not applied to shipping when product prices are tax inclusive.' ) . '</p>';
|
130 |
-
}// if
|
131 |
-
**/
|
132 |
-
|
133 |
-
//get current tax rates
|
134 |
-
$tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
|
135 |
-
$tax_rate_count = 0;
|
136 |
-
if ( !empty( $tax_rates ) ) {
|
137 |
-
foreach ( $tax_rates as $tax_rate ) {
|
138 |
-
echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_rate_count, $tax_rate );
|
139 |
-
$tax_rate_count++;
|
140 |
-
}// foreach
|
141 |
-
}// if
|
142 |
-
?>
|
143 |
-
<!--End Taxes Output-->
|
144 |
-
<p>
|
145 |
-
<a id="add_taxes_rate" href="#"><?php _e( 'Add New Tax Rate', 'wpsc' ); ?></a>
|
146 |
-
</p>
|
147 |
-
</div>
|
148 |
-
</div>
|
149 |
-
<div id='wpec-taxes-bands-container' class='postbox'>
|
150 |
-
<h3 class='hndle' style='cursor: default'><?php _e( 'Tax Bands', 'wpsc' ); ?></h3>
|
151 |
-
<div id='wpec-taxes-bands' class='inside'>
|
152 |
-
|
153 |
-
<?php
|
154 |
-
echo '<p>' . __( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. <br /> Please visit the product page to apply your Tax Band.', 'wpsc' ) . '</p>';
|
155 |
-
|
156 |
-
//echo message regarding inclusive tax
|
157 |
-
if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
|
158 |
-
echo '<p>' . __( 'Note: Tax Bands do not take affect when product prices are tax exclusive.', 'wpsc' ) . '</p>';
|
159 |
-
}// if
|
160 |
-
|
161 |
-
$tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
|
162 |
-
$tax_band_count = 0;
|
163 |
-
if ( !empty( $tax_bands ) ) {
|
164 |
-
foreach ( $tax_bands as $tax_band ) {
|
165 |
-
echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_band_count, $tax_band, 'bands' );
|
166 |
-
$tax_band_count++;
|
167 |
-
}// foreach
|
168 |
-
}// if
|
169 |
-
?>
|
170 |
-
<p>
|
171 |
-
<a id="add_taxes_band" href="#"><?php _e( 'Add New Tax Band', 'wpsc' ); ?></a>
|
172 |
-
</p>
|
173 |
-
</div>
|
174 |
-
</div><!--wpec-taxes-bands-container-->
|
175 |
-
</div><!--metabox-holder-->
|
176 |
-
<?php do_action('wpsc_taxes_settings_page'); ?>
|
177 |
-
<div class="submit">
|
178 |
-
<input type='hidden' name='wpec_admin_action' value='submit_taxes_options' />
|
179 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
180 |
-
<input type="submit" class='button-primary' value="Save Changes" name="submit_taxes" />
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
</form>
|
184 |
-
<?php
|
185 |
-
}
|
186 |
-
|
187 |
-
// wpec_options_taxes
|
188 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/{settings-pages → settings-tabs}/admin.php
RENAMED
@@ -1,34 +1,31 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
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 _e('Max downloads per file', 'wpsc');?>: </th>
|
14 |
<td>
|
15 |
<input type='text' size='10' value='<?php esc_attr_e( get_option('max_downloads') ); ?>' name='wpsc_options[max_downloads]' />
|
16 |
</td>
|
17 |
-
</tr>
|
18 |
<?php
|
19 |
$wpsc_ip_lock_downloads1 = "";
|
20 |
$wpsc_ip_lock_downloads2 = "";
|
21 |
-
switch( esc_attr( get_option('wpsc_ip_lock_downloads') ) ) {
|
22 |
case 1:
|
23 |
$wpsc_ip_lock_downloads1 = "checked ='checked'";
|
24 |
break;
|
25 |
-
|
26 |
case 0:
|
27 |
default:
|
28 |
$wpsc_ip_lock_downloads2 = "checked ='checked'";
|
29 |
break;
|
30 |
}
|
31 |
-
|
32 |
?>
|
33 |
<tr>
|
34 |
<th scope="row">
|
@@ -40,7 +37,7 @@ global $wpdb;
|
|
40 |
</td>
|
41 |
</tr>
|
42 |
|
43 |
-
|
44 |
<?php
|
45 |
$wpsc_check_mime_types1 = "";
|
46 |
$wpsc_check_mime_types2 = "";
|
@@ -48,13 +45,13 @@ global $wpdb;
|
|
48 |
case 1:
|
49 |
$wpsc_check_mime_types2 = "checked ='checked'";
|
50 |
break;
|
51 |
-
|
52 |
case 0:
|
53 |
default:
|
54 |
$wpsc_check_mime_types1 = "checked ='checked'";
|
55 |
break;
|
56 |
}
|
57 |
-
|
58 |
?>
|
59 |
<tr>
|
60 |
<th scope="row">
|
@@ -68,9 +65,9 @@ global $wpdb;
|
|
68 |
<?php _e('Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we recommend installing the Fileinfo extention for PHP rather than disabling this.', 'wpsc'); ?>
|
69 |
</span>
|
70 |
</td>
|
71 |
-
</tr>
|
72 |
-
|
73 |
-
|
74 |
<tr>
|
75 |
<th scope="row">
|
76 |
<?php _e('Purchase Log Email', 'wpsc');?>:
|
@@ -96,7 +93,7 @@ global $wpdb;
|
|
96 |
<input class='text' name='wpsc_options[return_name]' type='text' size='40' value='<?php esc_attr_e( get_option('return_name') ); ?>' />
|
97 |
</td>
|
98 |
</tr>
|
99 |
-
|
100 |
<tr>
|
101 |
<th scope="row">
|
102 |
<?php _e('Terms and Conditions', 'wpsc');?>:
|
@@ -105,8 +102,8 @@ global $wpdb;
|
|
105 |
<textarea name='wpsc_options[terms_and_conditions]' cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e(stripslashes(get_option('terms_and_conditions') ) ); ?></textarea>
|
106 |
</td>
|
107 |
</tr>
|
108 |
-
|
109 |
-
</table>
|
110 |
<h3 class="form_group"><?php _e('Custom Messages', 'wpsc');?>:</h3>
|
111 |
<table class='wpsc_options form-table'>
|
112 |
<tr>
|
@@ -137,7 +134,7 @@ global $wpdb;
|
|
137 |
<td><textarea name="wpsc_options[wpsc_email_admin]" cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e( stripslashes(get_option('wpsc_email_admin') ) );?></textarea></td>
|
138 |
</tr>
|
139 |
</table>
|
140 |
-
|
141 |
<h3 class="form_group"><?php _e("Track and Trace settings", 'wpsc');?>:</h3>
|
142 |
<table class='wpsc_options form-table'>
|
143 |
<tr>
|
@@ -156,21 +153,6 @@ global $wpdb;
|
|
156 |
<td><textarea name="wpsc_options[wpsc_trackingid_message]" cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e( stripslashes(get_option('wpsc_trackingid_message') ) );?></textarea></td>
|
157 |
</tr>
|
158 |
</table>
|
159 |
-
|
160 |
<?php
|
161 |
-
|
162 |
-
|
163 |
-
<?php do_action('wpsc_admin_settings_page'); ?>
|
164 |
-
<div class="submit">
|
165 |
-
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
166 |
-
|
167 |
-
<?php wp_nonce_field('update-options', 'wpsc-update-options'); ?>
|
168 |
-
<input type="submit" value="<?php _e('Update »', 'wpsc');?>" name="updateoption"/>
|
169 |
-
</div>
|
170 |
-
</div>
|
171 |
-
</form>
|
172 |
-
|
173 |
-
<?php
|
174 |
-
}
|
175 |
-
|
176 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
public function display() {
|
6 |
+
?>
|
7 |
+
<h3><?php _e('Admin Settings', 'wpsc'); ?></h3>
|
8 |
+
<table class='wpsc_options form-table'>
|
|
|
|
|
|
|
9 |
<tr>
|
10 |
<th scope="row"><?php _e('Max downloads per file', 'wpsc');?>: </th>
|
11 |
<td>
|
12 |
<input type='text' size='10' value='<?php esc_attr_e( get_option('max_downloads') ); ?>' name='wpsc_options[max_downloads]' />
|
13 |
</td>
|
14 |
+
</tr>
|
15 |
<?php
|
16 |
$wpsc_ip_lock_downloads1 = "";
|
17 |
$wpsc_ip_lock_downloads2 = "";
|
18 |
+
switch( esc_attr( get_option('wpsc_ip_lock_downloads') ) ) {
|
19 |
case 1:
|
20 |
$wpsc_ip_lock_downloads1 = "checked ='checked'";
|
21 |
break;
|
22 |
+
|
23 |
case 0:
|
24 |
default:
|
25 |
$wpsc_ip_lock_downloads2 = "checked ='checked'";
|
26 |
break;
|
27 |
}
|
28 |
+
|
29 |
?>
|
30 |
<tr>
|
31 |
<th scope="row">
|
37 |
</td>
|
38 |
</tr>
|
39 |
|
40 |
+
|
41 |
<?php
|
42 |
$wpsc_check_mime_types1 = "";
|
43 |
$wpsc_check_mime_types2 = "";
|
45 |
case 1:
|
46 |
$wpsc_check_mime_types2 = "checked ='checked'";
|
47 |
break;
|
48 |
+
|
49 |
case 0:
|
50 |
default:
|
51 |
$wpsc_check_mime_types1 = "checked ='checked'";
|
52 |
break;
|
53 |
}
|
54 |
+
|
55 |
?>
|
56 |
<tr>
|
57 |
<th scope="row">
|
65 |
<?php _e('Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we recommend installing the Fileinfo extention for PHP rather than disabling this.', 'wpsc'); ?>
|
66 |
</span>
|
67 |
</td>
|
68 |
+
</tr>
|
69 |
+
|
70 |
+
|
71 |
<tr>
|
72 |
<th scope="row">
|
73 |
<?php _e('Purchase Log Email', 'wpsc');?>:
|
93 |
<input class='text' name='wpsc_options[return_name]' type='text' size='40' value='<?php esc_attr_e( get_option('return_name') ); ?>' />
|
94 |
</td>
|
95 |
</tr>
|
96 |
+
|
97 |
<tr>
|
98 |
<th scope="row">
|
99 |
<?php _e('Terms and Conditions', 'wpsc');?>:
|
102 |
<textarea name='wpsc_options[terms_and_conditions]' cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e(stripslashes(get_option('terms_and_conditions') ) ); ?></textarea>
|
103 |
</td>
|
104 |
</tr>
|
105 |
+
|
106 |
+
</table>
|
107 |
<h3 class="form_group"><?php _e('Custom Messages', 'wpsc');?>:</h3>
|
108 |
<table class='wpsc_options form-table'>
|
109 |
<tr>
|
134 |
<td><textarea name="wpsc_options[wpsc_email_admin]" cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e( stripslashes(get_option('wpsc_email_admin') ) );?></textarea></td>
|
135 |
</tr>
|
136 |
</table>
|
137 |
+
|
138 |
<h3 class="form_group"><?php _e("Track and Trace settings", 'wpsc');?>:</h3>
|
139 |
<table class='wpsc_options form-table'>
|
140 |
<tr>
|
153 |
<td><textarea name="wpsc_options[wpsc_trackingid_message]" cols='' rows='' style='width: 300px; height: 200px;'><?php esc_attr_e( stripslashes(get_option('wpsc_trackingid_message') ) );?></textarea></td>
|
154 |
</tr>
|
155 |
</table>
|
|
|
156 |
<?php
|
157 |
+
}
|
158 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-tabs/checkout.php
ADDED
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Checkout extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
private $require_register;
|
6 |
+
private $shipping_same_as_billing;
|
7 |
+
private $force_ssl;
|
8 |
+
private $checkout_sets;
|
9 |
+
private $current_checkout_set;
|
10 |
+
private $field_types;
|
11 |
+
private $user_field_types;
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
global $wpdb;
|
15 |
+
|
16 |
+
$this->require_register = get_option( 'require_register', 0 );
|
17 |
+
$this->shipping_same_as_billing = get_option( 'shippingsameasbilling', 0 );
|
18 |
+
$this->force_ssl = get_option( 'wpsc_force_ssl', 0 );
|
19 |
+
$this->checkout_sets = get_option( 'wpsc_checkout_form_sets' );
|
20 |
+
$this->current_checkout_set = empty( $_GET['checkout-set'] ) ? 0 : $_GET['checkout-set'];
|
21 |
+
$this->field_types = get_option( 'wpsc_checkout_form_fields' );
|
22 |
+
$this->user_field_types = array('text','textarea','heading','select','radio','checkbox');
|
23 |
+
|
24 |
+
$form_sql = $wpdb->prepare( "
|
25 |
+
SELECT *
|
26 |
+
FROM " . WPSC_TABLE_CHECKOUT_FORMS . "
|
27 |
+
WHERE checkout_set = %s
|
28 |
+
ORDER BY checkout_order
|
29 |
+
", $this->current_checkout_set );
|
30 |
+
$this->form_fields = $wpdb->get_results( $form_sql );
|
31 |
+
|
32 |
+
$columns = array(
|
33 |
+
'drag' => __('Drag', 'wpsc'),
|
34 |
+
'name' => __('Title', 'wpsc'),
|
35 |
+
'type' => __('Type', 'wpsc'),
|
36 |
+
'unique_name' => ' ',
|
37 |
+
'display' => __('Display', 'wpsc'),
|
38 |
+
'mandatory' => __('Mandatory', 'wpsc'),
|
39 |
+
'actions' => ' ',
|
40 |
+
);
|
41 |
+
register_column_headers('display-checkout-list', $columns);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function callback_submit_options() {
|
45 |
+
global $wpdb;
|
46 |
+
|
47 |
+
if ( ! isset( $_POST['form_name'] ) )
|
48 |
+
return;
|
49 |
+
|
50 |
+
$existing_orders = array();
|
51 |
+
$new_field_orders = array();
|
52 |
+
if ( ! empty( $_POST['sort_order'] ) ) {
|
53 |
+
foreach ( $_POST['sort_order'] as $order => $field_id ) {
|
54 |
+
$id = absint( preg_replace('/[^0-9]+/', '', $field_id) );
|
55 |
+
|
56 |
+
if ( strpos( $field_id, 'new-field' ) === 0 )
|
57 |
+
$new_field_orders[$id] = $order;
|
58 |
+
else
|
59 |
+
$existing_orders[$id] = $order;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$sql = "SELECT id FROM " . WPSC_TABLE_CHECKOUT_FORMS;
|
64 |
+
$ids = $wpdb->get_col( $sql );
|
65 |
+
|
66 |
+
foreach ( $_POST['form_name'] as $field_id => $name ) {
|
67 |
+
$data = array(
|
68 |
+
'name' => $name,
|
69 |
+
'active' => empty( $_POST['form_display'][$field_id] ) ? 0 : 1,
|
70 |
+
'mandatory' => empty( $_POST['form_mandatory'][$field_id] ) ? 0 : 1,
|
71 |
+
);
|
72 |
+
|
73 |
+
$data_format = array(
|
74 |
+
'%s', // name
|
75 |
+
'%s', // active
|
76 |
+
'%s', // mandatory
|
77 |
+
);
|
78 |
+
|
79 |
+
$where = array( 'id' => $field_id );
|
80 |
+
|
81 |
+
if ( isset( $_POST['form_type'][$field_id] ) ) {
|
82 |
+
$data['type'] = $_POST['form_type'][$field_id];
|
83 |
+
$data_format[] = '%s';
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( isset( $existing_orders[$field_id] ) ) {
|
87 |
+
$data['checkout_order'] = $existing_orders[$field_id];
|
88 |
+
$data_format[] = '%d';
|
89 |
+
}
|
90 |
+
|
91 |
+
if ( isset( $_POST['form_options'][$field_id]['label'] ) ) {
|
92 |
+
$options = array();
|
93 |
+
foreach( $_POST['form_options'][$field_id]['label'] as $key => $label ) {
|
94 |
+
$value = $_POST['form_options'][$field_id]['value'][$key];
|
95 |
+
if ( $label === '' && $value === '')
|
96 |
+
continue;
|
97 |
+
$options[$label] = $value;
|
98 |
+
}
|
99 |
+
$data['options'] = serialize( $options );
|
100 |
+
$data_format[] = '%s';
|
101 |
+
}
|
102 |
+
|
103 |
+
$index = array_search( $field_id, $ids );
|
104 |
+
if ( $index !== false ) {
|
105 |
+
unset( $ids[$index] );
|
106 |
+
}
|
107 |
+
|
108 |
+
$wpdb->update( WPSC_TABLE_CHECKOUT_FORMS, $data, $where, $data_format, '%d' );
|
109 |
+
}
|
110 |
+
|
111 |
+
// delete all other fields that are not present in the submitted form
|
112 |
+
if ( ! empty( $ids ) ) {
|
113 |
+
$sql = "DELETE FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE id IN (" . implode( ', ', $ids ) . ")";
|
114 |
+
$wpdb->query( $sql );
|
115 |
+
}
|
116 |
+
|
117 |
+
foreach ( $_POST['new_field_name'] as $key => $name ) {
|
118 |
+
if ( $key === 0 && empty( $name ) )
|
119 |
+
continue;
|
120 |
+
|
121 |
+
$data = array(
|
122 |
+
'name' => $name,
|
123 |
+
'type' => $_POST['new_field_type'][$key],
|
124 |
+
'active' => empty( $_POST['new_field_display'][$key] ) ? 0 : 1,
|
125 |
+
'mandatory' => empty( $_POST['new_field_mandatory'][$key] ) ? 0 : 1,
|
126 |
+
);
|
127 |
+
|
128 |
+
$data_format = array(
|
129 |
+
'%s', // name
|
130 |
+
'%s', // type
|
131 |
+
'%s', // active
|
132 |
+
'%s', // mandatory
|
133 |
+
);
|
134 |
+
|
135 |
+
if ( isset( $new_field_orders[$key] ) ) {
|
136 |
+
$data['checkout_order'] = $new_field_orders[$key];
|
137 |
+
$data_format[] = '%d';
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( isset( $_POST['new_field_options'][$key]['label'] ) ) {
|
141 |
+
$options = array();
|
142 |
+
foreach( $_POST['new_field_options'][$key]['label'] as $index => $label ) {
|
143 |
+
$value = $_POST['new_field_options'][$key]['value'][$index];
|
144 |
+
if ( $label === '' && $value === '')
|
145 |
+
continue;
|
146 |
+
$options[$label] = $value;
|
147 |
+
}
|
148 |
+
|
149 |
+
$data['options'] = serialize( $options );
|
150 |
+
$data_format[] = '%s';
|
151 |
+
}
|
152 |
+
|
153 |
+
$wpdb->insert( WPSC_TABLE_CHECKOUT_FORMS, $data, $data_format );
|
154 |
+
}
|
155 |
+
|
156 |
+
wp_redirect( $_SERVER['REQUEST_URI'] );
|
157 |
+
exit;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Determine whether this field is default or not.
|
162 |
+
*
|
163 |
+
* We do not let default fields to be deleted from 3.8.8. However, if the user upgrades from
|
164 |
+
* 3.7.x, the "default" column of the checkout form table does not correctly specify
|
165 |
+
* whether the fields are default or not.
|
166 |
+
*
|
167 |
+
* Also, if in any case the user has deleted a default field in versions older than 3.8.8,
|
168 |
+
* the field's "active" column will be set to 0. We should let users delete those fields as well.
|
169 |
+
*
|
170 |
+
* As a result, to determine whether a field is default or not, we have to rely on the field's
|
171 |
+
* unique name and "active" status.
|
172 |
+
*
|
173 |
+
* @param {Object} $field Field object
|
174 |
+
* @return {Boolean} True if the field is default.
|
175 |
+
*/
|
176 |
+
private function is_field_default( $field ) {
|
177 |
+
global $wpdb;
|
178 |
+
|
179 |
+
if ( $field->default == 1 )
|
180 |
+
return true;
|
181 |
+
|
182 |
+
if ( empty( $field->unique_name) || $this->current_checkout_set !== 0 || empty( $field->active ) )
|
183 |
+
return false;
|
184 |
+
|
185 |
+
$default_fields = array(
|
186 |
+
'billingfirstname',
|
187 |
+
'billinglastname',
|
188 |
+
'billingaddress',
|
189 |
+
'billingcity',
|
190 |
+
'billingstate',
|
191 |
+
'billingcountry',
|
192 |
+
'billingpostcode',
|
193 |
+
'billingemail',
|
194 |
+
'billingphone',
|
195 |
+
'shippingfirstname',
|
196 |
+
'shippinglastname',
|
197 |
+
'shippingaddress',
|
198 |
+
'shippingcity',
|
199 |
+
'shippingstate',
|
200 |
+
'shippingcountry',
|
201 |
+
'shippingpostcode',
|
202 |
+
'shippingemail',
|
203 |
+
);
|
204 |
+
|
205 |
+
if ( in_array( $field->unique_name, $default_fields ) )
|
206 |
+
return true;
|
207 |
+
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
public function display() {
|
212 |
+
global $wpdb;
|
213 |
+
|
214 |
+
//not to sure if we still need these any more - $form_types, $unique_names
|
215 |
+
$form_types = get_option('wpsc_checkout_form_fields');
|
216 |
+
$unique_names = get_option('wpsc_checkout_unique_names');
|
217 |
+
|
218 |
+
do_action('wpsc_checkout_form_fields_page');
|
219 |
+
?>
|
220 |
+
|
221 |
+
<div class='metabox-holder' style='width:95%;'>
|
222 |
+
<div class='postbox'>
|
223 |
+
<input type='hidden' name='checkout_submits' value='true' />
|
224 |
+
<h3 class='hndle'><?php _e( 'Misc Checkout Options' , 'wpsc' ); ?></h3>
|
225 |
+
<div class='inside'>
|
226 |
+
<table>
|
227 |
+
<tr>
|
228 |
+
<td><?php _e('Users must register before checking out', 'wpsc'); ?>:</td>
|
229 |
+
<td>
|
230 |
+
<input type='radio' value='1' name='wpsc_options[require_register]' id='require_register1' <?php checked( $this->require_register, 1 ); ?> />
|
231 |
+
<label for='require_register1'><?php _e('Yes', 'wpsc');?></label>
|
232 |
+
<input type='radio' value='0' name='wpsc_options[require_register]' id='require_register2' <?php checked( $this->require_register, 0 ); ?> />
|
233 |
+
<label for='require_register2'><?php _e('No', 'wpsc');?></label>
|
234 |
+
</td>
|
235 |
+
<td>
|
236 |
+
<a title='<?php _e('If yes then you must also turn on the wordpress option "Any one can register"', 'wpsc');?>' class='flag_email' href='#' ><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/help.png' alt='' /> </a>
|
237 |
+
</td>
|
238 |
+
</tr>
|
239 |
+
|
240 |
+
<tr>
|
241 |
+
<td scope="row"><?php _e('Enable Shipping Same as Billing Option', 'wpsc'); ?>:</td>
|
242 |
+
<td>
|
243 |
+
<input type='radio' value='1' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling1' <?php checked( $this->shipping_same_as_billing, 1 ); ?> />
|
244 |
+
<label for='shippingsameasbilling1'><?php _e('Yes', 'wpsc');?></label>
|
245 |
+
<input type='radio' value='0' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling2' <?php checked( $this->shipping_same_as_billing, 0 ); ?> />
|
246 |
+
<label for='shippingsameasbilling2'><?php _e('No', 'wpsc');?></label>
|
247 |
+
</td>
|
248 |
+
</tr>
|
249 |
+
<tr>
|
250 |
+
<td><?php _e('Force users to use SSL', 'wpsc'); ?>:</td>
|
251 |
+
<td>
|
252 |
+
<input type='radio' value='1' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl1' <?php checked( $this->force_ssl, 1 ); ?> />
|
253 |
+
<label for='wpsc_force_ssl1'><?php _e('Yes', 'wpsc');?></label>
|
254 |
+
<input type='radio' value='0' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl2' <?php checked( $this->force_ssl, 0 ); ?> />
|
255 |
+
<label for='wpsc_force_ssl2'><?php _e('No', 'wpsc');?></label>
|
256 |
+
</td>
|
257 |
+
<td>
|
258 |
+
<a title='<?php _e('This can cause warnings for your users if you do not have a properly configured SSL certificate', 'wpsc');?>' class='flag_email' href='#' ><img src='<?php echo WPSC_CORE_IMAGES_URL; ?>/help.png' alt='' /> </a>
|
259 |
+
</td>
|
260 |
+
</tr>
|
261 |
+
</table>
|
262 |
+
</div>
|
263 |
+
</div>
|
264 |
+
</div>
|
265 |
+
|
266 |
+
<h3><?php _e('Form Fields', 'wpsc'); ?></h3>
|
267 |
+
<p><?php _e('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...', 'wpsc');?></p>
|
268 |
+
|
269 |
+
<p>
|
270 |
+
<label for='wpsc_form_set'><?php _e('Select a Form Set' , 'wpsc'); ?>:</label>
|
271 |
+
<select id='wpsc_form_set' name='wpsc_form_set'>
|
272 |
+
<?php foreach ( $this->checkout_sets as $key => $value ): ?>
|
273 |
+
<option <?php selected( $this->current_checkout_set, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></option>
|
274 |
+
<?php endforeach; ?>
|
275 |
+
</select>
|
276 |
+
<input type='submit' value='<?php esc_attr_e( 'Filter', 'wpsc' ); ?>' name='wpsc_checkout_set_filter' class='button-secondary' />
|
277 |
+
<a href='#' class='add_new_form_set'><?php esc_html_e("+ Add New Form Set", 'wpsc'); ?></a>
|
278 |
+
</p>
|
279 |
+
|
280 |
+
<p class='add_new_form_set_forms'>
|
281 |
+
<label><?php esc_html_e( "Add new Form Set", 'wpsc' ); ?>:
|
282 |
+
<input type="text" value="" name="new_form_set" /></label>
|
283 |
+
<input type="submit" value="<?php _e('Add', 'wpsc'); ?>" class="button-secondary" id="formset-add-sumbit"/>
|
284 |
+
</p>
|
285 |
+
|
286 |
+
<input type="hidden" name="selected_form_set" value="<?php echo esc_attr( $this->current_checkout_set ); ?>" />
|
287 |
+
|
288 |
+
<table id="wpsc_checkout_list" class="widefat page fixed" cellspacing="0">
|
289 |
+
<thead>
|
290 |
+
<tr>
|
291 |
+
<?php print_column_headers( 'display-checkout-list' ); ?>
|
292 |
+
</tr>
|
293 |
+
</thead>
|
294 |
+
|
295 |
+
<tfoot>
|
296 |
+
<tr>
|
297 |
+
<?php print_column_headers( 'display-checkout-list', false ); ?>
|
298 |
+
</tr>
|
299 |
+
</tfoot>
|
300 |
+
|
301 |
+
<tbody id='wpsc_checkout_list_body'>
|
302 |
+
<?php foreach ( $this->form_fields as $form_field ): ?>
|
303 |
+
<tr data-field-id="<?php echo esc_attr( $form_field->id ); ?>" id="checkout_<?php echo esc_attr( $form_field->id ); ?>" class="checkout_form_field">
|
304 |
+
<td class="drag">
|
305 |
+
<div class="cell-wrapper">
|
306 |
+
<a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
|
307 |
+
<img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
|
308 |
+
</a>
|
309 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
310 |
+
</div>
|
311 |
+
</td>
|
312 |
+
<td class="namecol">
|
313 |
+
<div class="cell-wrapper">
|
314 |
+
<input type="text" name="form_name[<?php echo esc_attr( $form_field->id ); ?>]" value="<?php echo esc_attr( $form_field->name ); ?>" />
|
315 |
+
<a
|
316 |
+
class="edit-options" href="#"
|
317 |
+
<?php
|
318 |
+
if ( in_array( $form_field->type, array( 'select', 'radio', 'checkbox' ) ) )
|
319 |
+
echo 'style="display:inline;"';
|
320 |
+
?>
|
321 |
+
><?php esc_html_e( 'Edit Options', 'wpsc' ); ?></a>
|
322 |
+
</div>
|
323 |
+
</td>
|
324 |
+
<td class="typecol">
|
325 |
+
<div class="cell-wrapper">
|
326 |
+
<?php if ( $this->is_field_default( $form_field ) ): ?>
|
327 |
+
<strong><?php echo esc_html( $form_field->type ); ?></strong>
|
328 |
+
<?php else: ?>
|
329 |
+
<select name="form_type[<?php echo esc_attr( $form_field->id ); ?>]">
|
330 |
+
<?php foreach ($this->field_types as $label => $name): ?>
|
331 |
+
<option <?php selected( $form_field->type, $name ); ?> value="<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $label ); ?></option>
|
332 |
+
<?php endforeach ?>
|
333 |
+
</select>
|
334 |
+
<?php
|
335 |
+
$field_options = unserialize( $form_field->options );
|
336 |
+
if ( empty( $field_options ) )
|
337 |
+
$field_options = array();
|
338 |
+
|
339 |
+
$i = 0;
|
340 |
+
foreach ( $field_options as $label => $value ):
|
341 |
+
$i ++;
|
342 |
+
?>
|
343 |
+
<input type="hidden" name="form_options[<?php echo esc_attr( $form_field->id ); ?>][label][]" value="<?php echo esc_attr( $label ); ?>" />
|
344 |
+
<input type="hidden" name="form_options[<?php echo esc_attr( $form_field->id ); ?>][value][]" value="<?php echo esc_attr( $value ); ?>" />
|
345 |
+
<?php endforeach; ?>
|
346 |
+
<?php endif; ?>
|
347 |
+
</div>
|
348 |
+
</td>
|
349 |
+
|
350 |
+
<td class="uniquenamecol">
|
351 |
+
<div class="cell-wrapper">
|
352 |
+
<?php if ( $form_field->type != 'heading' && ! empty( $form_field->unique_name ) ): ?>
|
353 |
+
<small><?php echo esc_html( $form_field->unique_name ); ?></small>
|
354 |
+
<?php endif ?>
|
355 |
+
</div>
|
356 |
+
</td>
|
357 |
+
<td class="displaycol">
|
358 |
+
<div class="cell-wrapper">
|
359 |
+
<input <?php checked( $form_field->active, 1 ); ?> type="checkbox" name="form_display[<?php echo esc_attr( $form_field->id ); ?>]" value="1" />
|
360 |
+
</div>
|
361 |
+
</td>
|
362 |
+
<td class="mandatorycol">
|
363 |
+
<div class="cell-wrapper">
|
364 |
+
<?php if ( $form_field->type != 'heading' ): ?>
|
365 |
+
<input <?php checked( $form_field->mandatory, 1 ); ?> type="checkbox" name="form_mandatory[<?php echo esc_attr( $form_field->id ); ?>]" value="1" />
|
366 |
+
<?php endif ?>
|
367 |
+
</div>
|
368 |
+
</td>
|
369 |
+
<td class="actionscol">
|
370 |
+
<div class="cell-wrapper">
|
371 |
+
<?php if ( ! $this->is_field_default( $form_field ) ): ?>
|
372 |
+
<a tabindex="-1" title="<?php _e( 'Delete Field', 'wpsc' ); ?>" class="action delete" href="#">Delete</a>
|
373 |
+
<?php else: ?>
|
374 |
+
<span title="<?php _e( 'Cannot Delete Default Fields', 'wpsc' ); ?>" class="action delete">Delete</span>
|
375 |
+
<?php endif; ?>
|
376 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wpsc' ); ?>" class="action add" href="#">Add</a>
|
377 |
+
</div>
|
378 |
+
</td>
|
379 |
+
</tr>
|
380 |
+
<?php endforeach; ?>
|
381 |
+
<tr id="field-prototype" class="new-field">
|
382 |
+
<td class="drag">
|
383 |
+
<div class="cell-wrapper">
|
384 |
+
<a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wpsc' ); ?>">
|
385 |
+
<img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
|
386 |
+
</a>
|
387 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
388 |
+
</div>
|
389 |
+
</td>
|
390 |
+
<td class="namecol">
|
391 |
+
<div class="cell-wrapper">
|
392 |
+
<input type="text" name="new_field_name[0]" value="" />
|
393 |
+
<a class="edit-options" href="#"><?php esc_html_e( 'Edit Options', 'wpsc' ); ?></a>
|
394 |
+
</div>
|
395 |
+
</td>
|
396 |
+
<td class="typecol">
|
397 |
+
<div class="cell-wrapper">
|
398 |
+
<select name="new_field_type[0]">
|
399 |
+
<?php foreach ( $this->field_types as $name => $type ): ?>
|
400 |
+
<?php if( in_array($type, $this->user_field_types) ): ?>
|
401 |
+
<option value="<?php echo esc_attr( $type ); ?>"><?php echo esc_html( $name ); ?></option>
|
402 |
+
<?php endif ?>
|
403 |
+
<?php endforeach ?>
|
404 |
+
</select>
|
405 |
+
</div>
|
406 |
+
</td>
|
407 |
+
<td class="uniquenamecol">
|
408 |
+
</td>
|
409 |
+
<td class="displaycol">
|
410 |
+
<div class="cell-wrapper">
|
411 |
+
<input checked="checked" type="checkbox" name="new_field_display[0]" value="1" />
|
412 |
+
</div>
|
413 |
+
</td>
|
414 |
+
<td class="mandatorycol">
|
415 |
+
<div class="cell-wrapper">
|
416 |
+
<input type="checkbox" name="new_field_mandatory[0]" value="1" />
|
417 |
+
</div>
|
418 |
+
</td>
|
419 |
+
<td class="actionscol">
|
420 |
+
<div class="cell-wrapper">
|
421 |
+
<a tabindex="-1" title="<?php _e( 'Delete Field', 'wpsc' ); ?>" class="action delete" href="#">Delete</a>
|
422 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wpsc' ); ?>" class="action add" href="#">Add</a>
|
423 |
+
</div>
|
424 |
+
</td>
|
425 |
+
</tr>
|
426 |
+
<tr id="field-options-prototype" class="form-field-options">
|
427 |
+
<td></td>
|
428 |
+
<td>
|
429 |
+
<div class="cell-wrapper">
|
430 |
+
<h4></h4>
|
431 |
+
<table class="wpsc-field-options-table">
|
432 |
+
<thead>
|
433 |
+
<th class="column-labels"><?php echo esc_html( _x( 'Label', "checkout field's options", 'wpsc' ) ); ?></th>
|
434 |
+
<th class="column-values"><?php echo esc_html( _x( 'Value', "checkout field's options", 'wpsc' ) ) ?></th>
|
435 |
+
<th class="column-actions"> </th>
|
436 |
+
</thead>
|
437 |
+
<tbody>
|
438 |
+
<tr class="new-option">
|
439 |
+
<td class="column-labels">
|
440 |
+
<div class="field-option-cell-wrapper">
|
441 |
+
<input type="text" name="form_options[0][labels][]" value="" />
|
442 |
+
</div>
|
443 |
+
</td>
|
444 |
+
<td class="column-values">
|
445 |
+
<div class="field-option-cell-wrapper">
|
446 |
+
<input type="text" name="form_options[0][values][]" value="" />
|
447 |
+
</div>
|
448 |
+
</td>
|
449 |
+
<td class="column-actions">
|
450 |
+
<div class="field-option-cell-wrapper">
|
451 |
+
<a tabindex="-1" title="<?php _e( 'Delete Field', 'wpsc' ); ?>" class="action delete" href="#">Delete</a>
|
452 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wpsc' ); ?>" class="action add" href="#">Add</a>
|
453 |
+
</div>
|
454 |
+
</td>
|
455 |
+
</tr>
|
456 |
+
</tbody>
|
457 |
+
</table>
|
458 |
+
</div>
|
459 |
+
</td>
|
460 |
+
<td colspan="5"></td>
|
461 |
+
</tr>
|
462 |
+
</tbody>
|
463 |
+
</table>
|
464 |
+
<?php
|
465 |
+
}
|
466 |
+
}
|
wpsc-admin/includes/settings-tabs/gateway.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
private $active_gateways;
|
6 |
+
private $gateway_names;
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
if ( isset( $_REQUEST['payment_gateway_id'] ) )
|
10 |
+
update_user_option( get_current_user_id(), 'wpsc_settings_selected_payment_gateway', $_REQUEST['payment_gateway_id'] );
|
11 |
+
|
12 |
+
$this->active_gateways = get_option( 'custom_gateway_options' );
|
13 |
+
$this->gateway_names = get_option( 'payment_gateway_names' );
|
14 |
+
}
|
15 |
+
|
16 |
+
private function get_gateway_form( $selected_gateway ) {
|
17 |
+
global $nzshpcrt_gateways;
|
18 |
+
|
19 |
+
$payment_gateway_names = get_option('payment_gateway_names');
|
20 |
+
$return = false;
|
21 |
+
$selected_gateway_data = false;
|
22 |
+
foreach ( $nzshpcrt_gateways as $gateway ) {
|
23 |
+
if ( $gateway['internalname'] == $selected_gateway ) {
|
24 |
+
$selected_gateway_data = $gateway;
|
25 |
+
break;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( $selected_gateway_data ) {
|
30 |
+
if ( array_key_exists( $selected_gateway, $payment_gateway_names ) ) {
|
31 |
+
$display_name = $payment_gateway_names[$selected_gateway];
|
32 |
+
} elseif ( ! empty( $selected_gateway_data['display_name'] ) ) {
|
33 |
+
$display_name = $selected_gateway_data['display_name'];
|
34 |
+
} else {
|
35 |
+
switch($selected_gateway_data['payment_type']) {
|
36 |
+
case "paypal";
|
37 |
+
$display_name = "PayPal";
|
38 |
+
break;
|
39 |
+
|
40 |
+
case "manual_payment":
|
41 |
+
$display_name = "Manual Payment";
|
42 |
+
break;
|
43 |
+
|
44 |
+
case "google_checkout":
|
45 |
+
$display_name = "Google Checkout";
|
46 |
+
break;
|
47 |
+
|
48 |
+
case "credit_card":
|
49 |
+
default:
|
50 |
+
$display_name = "Credit Card";
|
51 |
+
break;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
ob_start();
|
56 |
+
?>
|
57 |
+
<tr>
|
58 |
+
<td><?php esc_html_e( 'Display Name', 'wpsc' ); ?></td>
|
59 |
+
<td>
|
60 |
+
<input type="text" name="user_defined_name[<?php echo esc_attr( $selected_gateway ); ?>]" value="<?php echo esc_html( $display_name ); ?>" /><br />
|
61 |
+
<small><?php esc_html_e( 'The text that people see when making a purchase.', 'wpsc' ); ?></small>
|
62 |
+
</td>
|
63 |
+
</tr>
|
64 |
+
<?php
|
65 |
+
$output = ob_get_clean();
|
66 |
+
$return = array(
|
67 |
+
'name' => $selected_gateway_data['name'],
|
68 |
+
'form_fields' => $output . $selected_gateway_data['form'](),
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
return $return;
|
73 |
+
}
|
74 |
+
|
75 |
+
private function get_gateway_settings_url( $gateway ) {
|
76 |
+
$location = isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'];
|
77 |
+
$location = add_query_arg( array(
|
78 |
+
'tab' => 'gateway',
|
79 |
+
'page' => 'wpsc-settings',
|
80 |
+
'payment_gateway_id' => $gateway,
|
81 |
+
), $location );
|
82 |
+
return $location;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function display_payment_gateway_settings_form() {
|
86 |
+
$selected_gateway = (string) get_user_option( 'wpsc_settings_selected_payment_gateway', get_current_user_id() );
|
87 |
+
if ( empty( $selected_gateway ) && ! empty( $this->active_gateways ) )
|
88 |
+
$selected_gateway = $this->active_gateways[0];
|
89 |
+
|
90 |
+
$payment_data = $this->get_gateway_form( $selected_gateway );
|
91 |
+
if ( ! $payment_data ) {
|
92 |
+
$payment_data = array(
|
93 |
+
'name' => __( 'Edit Gateway Settings', 'wpsc' ),
|
94 |
+
'form_fields' => __( 'Modify a payment gateway settings by clicking "Edit" link on the left.', 'wpsc' ),
|
95 |
+
);
|
96 |
+
}
|
97 |
+
?>
|
98 |
+
<td id='wpsc-payment-gateway-settings-panel' class='wpsc-module-settings' rowspan='2'>
|
99 |
+
<div class='postbox'>
|
100 |
+
<h3 class='hndle'><?php echo $payment_data['name']; ?></h3>
|
101 |
+
<div class='inside'>
|
102 |
+
<table class='form-table'>
|
103 |
+
<?php echo $payment_data['form_fields']; ?>
|
104 |
+
</table>
|
105 |
+
<div class='submit'>
|
106 |
+
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ) ?>' />
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
</td>
|
110 |
+
<?php
|
111 |
+
}
|
112 |
+
|
113 |
+
public function display() {
|
114 |
+
global $wpdb, $nzshpcrt_gateways;
|
115 |
+
$payment_gateway_names = get_option( 'payment_gateway_names' );
|
116 |
+
if ( empty( $nzshpcrt_gateways ) )
|
117 |
+
$nzshpcrt_gateways = nzshpcrt_get_gateways();
|
118 |
+
?>
|
119 |
+
|
120 |
+
<div class='metabox-holder'>
|
121 |
+
<input type='hidden' name='gateway_submits' value='true' />
|
122 |
+
<input type='hidden' name='wpsc_gateway_settings' value='gateway_settings' />
|
123 |
+
<?php
|
124 |
+
if ( get_option( 'custom_gateway' ) == 1 ) {
|
125 |
+
$custom_gateway_hide = "style='display:block;'";
|
126 |
+
$custom_gateway1 = 'checked="checked"';
|
127 |
+
} else {
|
128 |
+
$custom_gateway_hide = "style='display:none;'";
|
129 |
+
$custom_gateway2 = 'checked="checked"';
|
130 |
+
}
|
131 |
+
?>
|
132 |
+
<table id='wpsc-payment-gateway-settings' class='wpsc-edit-module-options'>
|
133 |
+
<tr>
|
134 |
+
<td>
|
135 |
+
<div class='postbox'>
|
136 |
+
<h3 class='hndle'><?php _e( 'Select Payment Gateways', 'wpsc' ); ?></h3>
|
137 |
+
<div class='inside'>
|
138 |
+
<p><?php _e( 'Activate the payment gateways that you want to make available to your customers by selecting them below.', 'wpsc' ); ?></p>
|
139 |
+
<br />
|
140 |
+
<?php
|
141 |
+
$selected_gateways = get_option( 'custom_gateway_options' );
|
142 |
+
foreach ( $nzshpcrt_gateways as $gateway ) {
|
143 |
+
if ( isset( $gateway['admin_name'] ) )
|
144 |
+
$gateway['name'] = $gateway['admin_name'];
|
145 |
+
?>
|
146 |
+
|
147 |
+
<div class="wpsc-select-gateway">
|
148 |
+
<div class='wpsc-gateway-actions'>
|
149 |
+
<span class="edit">
|
150 |
+
<a class='edit-payment-module' data-gateway-id="<?php echo esc_attr( $gateway['internalname'] ); ?>" title="<?php _e( "Edit this Payment Gateway's Settings", 'wpsc' ) ?>" href='<?php echo esc_attr( $this->get_gateway_settings_url( $gateway['internalname'] ) ); ?>'><?php esc_html_e( 'Edit', 'wpsc' ); ?></a>
|
151 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
152 |
+
</span>
|
153 |
+
</div>
|
154 |
+
<p>
|
155 |
+
<input name='wpsc_options[custom_gateway_options][]' <?php checked( in_array( $gateway['internalname'], (array) $selected_gateways ) ); ?> type='checkbox' value='<?php esc_attr_e( $gateway['internalname'] ); ?>' id='<?php esc_attr_e( $gateway['internalname'] ); ?>_id' />
|
156 |
+
<label for='<?php echo esc_attr( $gateway['internalname'] ); ?>_id'><?php echo esc_attr( $gateway['name'] ); ?></label>
|
157 |
+
</p>
|
158 |
+
</div>
|
159 |
+
<?php }
|
160 |
+
?>
|
161 |
+
<div class='submit gateway_settings'>
|
162 |
+
<input type='hidden' value='true' name='update_gateways' />
|
163 |
+
<input type='submit' value='<?php _e( 'Update »', 'wpsc' ) ?>' name='updateoption' />
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
|
168 |
+
<h4><?php _e( 'We Recommend', 'wpsc' ); ?></h4>
|
169 |
+
<a style="border-bottom:none;" href="https://www.paypal.com/nz/mrb/pal=LENKCHY6CU2VY" target="_blank"><img src="<?php echo WPSC_CORE_IMAGES_URL; ?>/paypal-referal.gif" border="0" alt="Sign up for PayPal and start accepting credit card payments instantly." /></a> <br /><br />
|
170 |
+
<a style="border-bottom:none;" href="http://checkout.google.com/sell/?promo=seinstinct" target="_blank"><img src="https://checkout.google.com/buyer/images/google_checkout.gif" border="0" alt="Sign up for Google Checkout" /></a>
|
171 |
+
|
172 |
+
</td>
|
173 |
+
|
174 |
+
<?php $this->display_payment_gateway_settings_form(); ?>
|
175 |
+
</tr>
|
176 |
+
</table>
|
177 |
+
</div>
|
178 |
+
|
179 |
+
<?php
|
180 |
+
}
|
181 |
+
}
|
wpsc-admin/includes/{settings-pages → settings-tabs}/general.php
RENAMED
@@ -1,44 +1,55 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
2 |
|
3 |
-
function
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
?>
|
|
|
13 |
<table class='wpsc_options form-table'>
|
14 |
<tr>
|
15 |
<th scope="row"><?php _e( 'Base Country/Region', 'wpsc' ); ?>: </th>
|
16 |
<td>
|
17 |
-
<select name='wpsc_options[base_country]'
|
18 |
-
|
19 |
<?php echo country_list( esc_attr( get_option( 'base_country' ) ) ); ?>
|
20 |
-
|
21 |
</select>
|
22 |
-
<span id='
|
23 |
-
|
24 |
-
|
25 |
-
if ( !empty( $region_list ) ) { ?>
|
26 |
-
|
27 |
-
<select name='wpsc_options[base_region]'>
|
28 |
-
<?php
|
29 |
-
foreach ( $region_list as $region ) {
|
30 |
-
if ( esc_attr( get_option( 'base_region' ) ) == $region['id'] ) {
|
31 |
-
$selected = "selected='selected'";
|
32 |
-
} else {
|
33 |
-
$selected = "";
|
34 |
-
}
|
35 |
-
?>
|
36 |
-
<option value='<?php echo $region['id']; ?>' <?php echo $selected; ?> ><?php echo esc_attr( $region['name'] ); ?></option> <?php
|
37 |
-
}
|
38 |
-
?>
|
39 |
-
</select>
|
40 |
-
|
41 |
-
<?php } ?>
|
42 |
</span>
|
43 |
<br /><?php _e( 'Select your primary business location.', 'wpsc' ); ?>
|
44 |
</td>
|
@@ -58,8 +69,10 @@ function wpsc_options_general() {
|
|
58 |
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.", 'wpsc' ) . "</em>";
|
59 |
} else {
|
60 |
?>
|
61 |
-
<span
|
62 |
-
<
|
|
|
|
|
63 |
<?php
|
64 |
foreach ( (array)$countrylist as $country ) {
|
65 |
$country['country'] = htmlspecialchars( $country['country'] );
|
@@ -72,12 +85,12 @@ function wpsc_options_general() {
|
|
72 |
<?php }
|
73 |
} ?>
|
74 |
</div><br />
|
75 |
-
<?php _e( 'Select the markets you are selling products to.' , 'wpsc');
|
76 |
}
|
77 |
?>
|
78 |
</td>
|
79 |
</tr>
|
80 |
-
<?php
|
81 |
$stock_keeping_time = get_option( 'wpsc_stock_keeping_time', 1 );
|
82 |
$stock_keeping_interval = get_option( 'wpsc_stock_keeping_interval', 'day' );
|
83 |
?>
|
@@ -104,7 +117,7 @@ function wpsc_options_general() {
|
|
104 |
<label><input type="radio" <?php checked( $hierarchical_category, 1 ); ?> name="wpsc_options[product_category_hierarchical_url]" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>
|
105 |
<label><input type="radio" <?php checked( $hierarchical_category, 0 ); ?>name="wpsc_options[product_category_hierarchical_url]" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label><br />
|
106 |
<?php _e( 'When Hierarchical Product Category URL is enabled, parent product categories are also included in the product URL.<br />For example: example.com/products-page/parent-cat/sub-cat/product-name', 'wpsc' ); ?>
|
107 |
-
</td>
|
108 |
</tr>
|
109 |
</table>
|
110 |
|
@@ -116,13 +129,10 @@ function wpsc_options_general() {
|
|
116 |
<select name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
|
117 |
<?php
|
118 |
$currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
|
|
|
119 |
foreach ( $currency_data as $currency ) {
|
120 |
-
|
121 |
-
|
122 |
-
} else {
|
123 |
-
$selected = "";
|
124 |
-
} ?>
|
125 |
-
<option value='<?php echo $currency['id']; ?>' <?php echo $selected; ?> ><?php echo htmlspecialchars( $currency['country'] ); ?> (<?php echo $currency['currency']; ?>)</option>
|
126 |
<?php
|
127 |
}
|
128 |
$currency_data = $wpdb->get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . esc_attr( get_option( 'currency_type' ) ) . "' LIMIT 1", ARRAY_A );
|
@@ -180,14 +190,6 @@ function wpsc_options_general() {
|
|
180 |
</td>
|
181 |
</tr>
|
182 |
</table>
|
183 |
-
<?php
|
184 |
-
|
185 |
-
|
186 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
187 |
-
<input type="submit" value="<?php _e( 'Update »', 'wpsc' ); ?>" name="updateoption" />
|
188 |
-
</div>
|
189 |
-
</div>
|
190 |
-
</form>
|
191 |
-
<?php
|
192 |
-
}
|
193 |
-
?>
|
1 |
<?php
|
2 |
+
class WPSC_Settings_Tab_General extends WPSC_Settings_Tab
|
3 |
+
{
|
4 |
+
private $regions = array();
|
5 |
|
6 |
+
public function __construct() {
|
7 |
+
$this->get_regions();
|
8 |
+
}
|
9 |
+
|
10 |
+
private function get_regions() {
|
11 |
+
global $wpdb;
|
12 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['country'] ) )
|
13 |
+
$base_country = $_POST['country'];
|
14 |
+
else
|
15 |
+
$base_country = get_option( 'base_country' );
|
16 |
+
$from = WPSC_TABLE_REGION_TAX . ' AS r';
|
17 |
+
$join = WPSC_TABLE_CURRENCY_LIST . ' AS c';
|
18 |
+
$sql = $wpdb->prepare( "
|
19 |
+
SELECT r.id, r.name
|
20 |
+
FROM {$from}
|
21 |
+
INNER JOIN {$join} ON r.country_id = c.id AND c.isocode = %s
|
22 |
+
", $base_country );
|
23 |
+
$this->regions = $wpdb->get_results( $sql );
|
24 |
+
}
|
25 |
+
|
26 |
+
public function display_region_drop_down() {
|
27 |
+
$base_region = get_option( 'base_region' );
|
28 |
+
if ( ! empty( $this->regions ) ):
|
29 |
+
?>
|
30 |
+
<select name='wpsc_options[base_region]'>
|
31 |
+
<?php foreach ( $this->regions as $region ): ?>
|
32 |
+
<option value='<?php echo esc_attr( $region->id ); ?>' <?php selected( $region->id, $base_region ); ?>><?php echo esc_html( $region->name ); ?></option>
|
33 |
+
<?php endforeach ?>
|
34 |
+
</select>
|
35 |
+
<?php
|
36 |
+
endif;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function display() {
|
40 |
+
global $wpdb;
|
41 |
?>
|
42 |
+
<h3><?php echo _e( 'General Settings', 'wpsc' ); ?></h3>
|
43 |
<table class='wpsc_options form-table'>
|
44 |
<tr>
|
45 |
<th scope="row"><?php _e( 'Base Country/Region', 'wpsc' ); ?>: </th>
|
46 |
<td>
|
47 |
+
<select id="wpsc-base-country-drop-down" name='wpsc_options[base_country]'>
|
|
|
48 |
<?php echo country_list( esc_attr( get_option( 'base_country' ) ) ); ?>
|
|
|
49 |
</select>
|
50 |
+
<span id='wpsc-base-region-drop-down'>
|
51 |
+
<?php $this->display_region_drop_down(); ?>
|
52 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
</span>
|
54 |
<br /><?php _e( 'Select your primary business location.', 'wpsc' ); ?>
|
55 |
</td>
|
69 |
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.", 'wpsc' ) . "</em>";
|
70 |
} else {
|
71 |
?>
|
72 |
+
<span>
|
73 |
+
<?php printf(__('Select: <a href="%1$s" class="wpsc-select-all" title="All">All</a> <a href="%2$s" class="wpsc-select-none" title="None">None</a>' , 'wpsc') , add_query_arg( array( 'selected_all' => 'all' ) ), add_query_arg( array( 'selected_all' => 'none' ) ) ); ?>
|
74 |
+
</span><br />
|
75 |
+
<div id='wpsc-target-markets' class='ui-widget-content multiple-select'>
|
76 |
<?php
|
77 |
foreach ( (array)$countrylist as $country ) {
|
78 |
$country['country'] = htmlspecialchars( $country['country'] );
|
85 |
<?php }
|
86 |
} ?>
|
87 |
</div><br />
|
88 |
+
<?php _e( 'Select the markets you are selling products to.' , 'wpsc');
|
89 |
}
|
90 |
?>
|
91 |
</td>
|
92 |
</tr>
|
93 |
+
<?php
|
94 |
$stock_keeping_time = get_option( 'wpsc_stock_keeping_time', 1 );
|
95 |
$stock_keeping_interval = get_option( 'wpsc_stock_keeping_interval', 'day' );
|
96 |
?>
|
117 |
<label><input type="radio" <?php checked( $hierarchical_category, 1 ); ?> name="wpsc_options[product_category_hierarchical_url]" value="1" /> <?php _e( 'Yes', 'wpsc' ); ?></label>
|
118 |
<label><input type="radio" <?php checked( $hierarchical_category, 0 ); ?>name="wpsc_options[product_category_hierarchical_url]" value="0" /> <?php _e( 'No', 'wpsc' ); ?></label><br />
|
119 |
<?php _e( 'When Hierarchical Product Category URL is enabled, parent product categories are also included in the product URL.<br />For example: example.com/products-page/parent-cat/sub-cat/product-name', 'wpsc' ); ?>
|
120 |
+
</td>
|
121 |
</tr>
|
122 |
</table>
|
123 |
|
129 |
<select name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
|
130 |
<?php
|
131 |
$currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
|
132 |
+
$currency_type = esc_attr( get_option( 'currency_type' ) );
|
133 |
foreach ( $currency_data as $currency ) {
|
134 |
+
?>
|
135 |
+
<option value='<?php echo $currency['id']; ?>' <?php selected( $currency['id'], $currency_type ); ?>><?php echo htmlspecialchars( $currency['country'] ); ?> (<?php echo $currency['currency']; ?>)</option>
|
|
|
|
|
|
|
|
|
136 |
<?php
|
137 |
}
|
138 |
$currency_data = $wpdb->get_row( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . esc_attr( get_option( 'currency_type' ) ) . "' LIMIT 1", ARRAY_A );
|
190 |
</td>
|
191 |
</tr>
|
192 |
</table>
|
193 |
+
<?php
|
194 |
+
}
|
195 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-tabs/import.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
public function display() {
|
6 |
+
?>
|
7 |
+
<?php _e( '<p>You can import your products from a comma delimited text file.</p><p>An example of a csv import file would look like this: </p><p>Description, Additional Description, Product Name, Price, SKU, weight, weight unit, stock quantity, is limited quantity</p>', 'wpsc' ); ?>
|
8 |
+
|
9 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
10 |
+
<input type='hidden' name='MAX_FILE_SIZE' value='5000000' />
|
11 |
+
<input type='file' name='csv_file' />
|
12 |
+
<input type='submit' value='Import' class='button-primary'>
|
13 |
+
<?php
|
14 |
+
if ( isset( $_FILES['csv_file']['name'] ) && ($_FILES['csv_file']['name'] != '') ) {
|
15 |
+
ini_set( "auto_detect_line_endings", 1 );
|
16 |
+
$file = $_FILES['csv_file'];
|
17 |
+
if ( move_uploaded_file( $file['tmp_name'], WPSC_FILE_DIR . $file['name'] ) ) {
|
18 |
+
$content = file_get_contents( WPSC_FILE_DIR . $file['name'] );
|
19 |
+
$handle = @fopen( WPSC_FILE_DIR . $file['name'], 'r' );
|
20 |
+
while ( ($csv_data = @fgetcsv( $handle, filesize( $handle ), "," )) !== false ) {
|
21 |
+
$fields = count( $csv_data );
|
22 |
+
for ( $i = 0; $i < $fields; $i++ ) {
|
23 |
+
if ( !is_array( $data1[$i] ) ) {
|
24 |
+
$data1[$i] = array( );
|
25 |
+
}
|
26 |
+
array_push( $data1[$i], $csv_data[$i] );
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
$_SESSION['cvs_data'] = $data1;
|
31 |
+
$categories = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $category_id );
|
32 |
+
?>
|
33 |
+
|
34 |
+
<p><?php _e( 'For each column, select the field it corresponds to in \'Belongs to\'. You can upload as many products as you like.', 'wpsc' ); ?></p>
|
35 |
+
<div class='metabox-holder' style='width:90%'>
|
36 |
+
<input type='hidden' name='csv_action' value='import'>
|
37 |
+
|
38 |
+
<div style='width:100%;' class='postbox'>
|
39 |
+
<h3 class='hndle'><?php _e('Product Status' , 'wpsc' ); ?></h3>
|
40 |
+
<div class='inside'>
|
41 |
+
<table>
|
42 |
+
<tr><td style='width:80%;'>
|
43 |
+
<?php _e( 'Select if you would like to import your products in as Drafts or Publish them right away.' , 'wpsc' ); ?>
|
44 |
+
<br />
|
45 |
+
</td><td>
|
46 |
+
<select name='post_status'>
|
47 |
+
<option value='publish'><?php _e('Publish', 'wpsc'); ?></option>
|
48 |
+
<option value='draft'><?php _e('Draft', 'wpsc'); ?></option>
|
49 |
+
</select>
|
50 |
+
</td></tr>
|
51 |
+
</table>
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<?php
|
56 |
+
foreach ( (array)$data1 as $key => $datum ) {
|
57 |
+
?>
|
58 |
+
<div style='width:100%;' class='postbox'>
|
59 |
+
<h3 class='hndle'><?php printf(__('Column (%s)', 'wpsc'), ($key + 1)); ?></h3>
|
60 |
+
<div class='inside'>
|
61 |
+
<table>
|
62 |
+
<tr><td style='width:80%;'>
|
63 |
+
<input type='hidden' name='column[]' value='<?php echo $key + 1; ?>'>
|
64 |
+
<?php
|
65 |
+
foreach ( $datum as $column ) {
|
66 |
+
echo $column;
|
67 |
+
break;
|
68 |
+
} ?>
|
69 |
+
<br />
|
70 |
+
</td><td>
|
71 |
+
<select name='value_name[]'>
|
72 |
+
<!-- /* These are the current fields that can be imported with products, to add additional fields add more <option> to this dorpdown list */ -->
|
73 |
+
<option value='name'><?php _e('Product Name', 'wpsc'); ?></option>
|
74 |
+
<option value='description'><?php _e('Description', 'wpsc'); ?></option>
|
75 |
+
<option value='additional_description'><?php _e('Additional Description', 'wpsc'); ?></option>
|
76 |
+
<option value='price'><?php _e('Price', 'wpsc'); ?></option>
|
77 |
+
<option value='sku'><?php _e('SKU', 'wpsc'); ?></option>
|
78 |
+
<option value='weight'><?php _e('Weight', 'wpsc'); ?></option>
|
79 |
+
<option value='weight_unit'><?php _e('Weight Unit', 'wpsc'); ?></option>
|
80 |
+
<option value='quantity'><?php _e('Stock Quantity', 'wpsc'); ?></option>
|
81 |
+
<option value='quantity_limited'><?php _e('Stock Quantity Limit', 'wpsc'); ?></option>
|
82 |
+
</select>
|
83 |
+
</td></tr>
|
84 |
+
</table>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
<?php } ?>
|
88 |
+
<label for='category'><?php _e('Please select a category you would like to place all products from this CSV into' , 'wpsc' ); ?>:</label>
|
89 |
+
<select id='category' name='category'>
|
90 |
+
<?php
|
91 |
+
foreach ( $categories as $category ) {
|
92 |
+
echo '<option value="' . $category->term_id . '">' . $category->name . '</option>';
|
93 |
+
}
|
94 |
+
?>
|
95 |
+
</select>
|
96 |
+
<input type='submit' value='Import' class='button-primary'>
|
97 |
+
</div>
|
98 |
+
<?php
|
99 |
+
} else {
|
100 |
+
echo "<br /><br />" . __('There was an error while uploading your csv file.', 'wpsc');
|
101 |
+
}
|
102 |
+
}
|
103 |
+
if ( isset( $_POST['csv_action'] ) && ('import' == $_POST['csv_action']) ) {
|
104 |
+
$cvs_data = $_SESSION['cvs_data'];
|
105 |
+
$column_data = $_POST['column'];
|
106 |
+
$value_data = $_POST['value_name'];
|
107 |
+
|
108 |
+
$status = esc_attr($_POST['post_status']);
|
109 |
+
|
110 |
+
$name = array( );
|
111 |
+
foreach ( $value_data as $key => $value ) {
|
112 |
+
|
113 |
+
$cvs_data2[$value] = $cvs_data[$key];
|
114 |
+
}
|
115 |
+
$num = count( $cvs_data2['name'] );
|
116 |
+
|
117 |
+
for ( $i = 0; $i < $num; $i++ ) {
|
118 |
+
$product_columns = array(
|
119 |
+
'post_title' => esc_attr( $cvs_data2['name'][$i] ),
|
120 |
+
'content' => esc_attr( $cvs_data2['description'][$i] ),
|
121 |
+
'additional_description' => esc_attr( $cvs_data2['additional_description'][$i] ),
|
122 |
+
'price' => esc_attr( str_replace( '$', '', $cvs_data2['price'][$i] ) ),
|
123 |
+
'weight' => esc_attr( $cvs_data2['weight'][$i] ),
|
124 |
+
'weight_unit' => esc_attr( $cvs_data2['weight_unit'][$i] ),
|
125 |
+
'pnp' => null,
|
126 |
+
'international_pnp' => null,
|
127 |
+
'file' => null,
|
128 |
+
'image' => '0',
|
129 |
+
'quantity_limited' => esc_attr( $cvs_data2['quantity_limited'][$i] ),
|
130 |
+
'quantity' => esc_attr( $cvs_data2['quantity'][$i] ),
|
131 |
+
'special' => null,
|
132 |
+
'special_price' => null,
|
133 |
+
'display_frontpage' => null,
|
134 |
+
'notax' => null,
|
135 |
+
'active' => null,
|
136 |
+
'donation' => null,
|
137 |
+
'no_shipping' => null,
|
138 |
+
'thumbnail_image' => null,
|
139 |
+
'thumbnail_state' => null,
|
140 |
+
'meta' => array(
|
141 |
+
'_wpsc_price' => esc_attr( str_replace( '$', '', $cvs_data2['price'][$i] ) ),
|
142 |
+
'_wpsc_sku' => esc_attr( $cvs_data2['sku'][$i] ),
|
143 |
+
'_wpsc_stock' => esc_attr( $cvs_data2['quantity'][$i] ),
|
144 |
+
'_wpsc_limited_stock' => esc_attr( $cvs_data2['quantity_limited'][$i] ),
|
145 |
+
'_wpsc_product_metadata' => array(
|
146 |
+
'weight' => esc_attr( $cvs_data2['weight'][$i] ),
|
147 |
+
'weight_unit' => esc_attr( $cvs_data2['weight_unit'][$i] ),
|
148 |
+
)
|
149 |
+
)
|
150 |
+
);
|
151 |
+
$product_columns = wpsc_sanitise_product_forms( $product_columns );
|
152 |
+
// status needs to be set here because wpsc_sanitise_product_forms overwrites it :/
|
153 |
+
$product_columns['post_status'] = $status;
|
154 |
+
$product_id = wpsc_insert_product( $product_columns );
|
155 |
+
wp_set_object_terms( $product_id , array( (int)$_POST['category'] ) , 'wpsc_product_category' );
|
156 |
+
}
|
157 |
+
echo "<br /><br />". sprintf(__("Success, your <a href='%s'>products</a> have been upload.", "wpsc"), admin_url('edit.php?post_type=wpsc-product'));
|
158 |
+
}
|
159 |
+
?>
|
160 |
+
<?php
|
161 |
+
}
|
162 |
+
}
|
wpsc-admin/includes/settings-tabs/marketing.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Marketing extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
public function display() {
|
6 |
+
?>
|
7 |
+
<div class='metabox-holder'>
|
8 |
+
<?php
|
9 |
+
add_meta_box( 'wpsc_marketing_settings', __( 'Marketing Section', 'wpsc' ), array( $this, 'marketing_meta_box' ), 'wpsc' );
|
10 |
+
add_meta_box( 'wpsc_rss_address', __( 'RSS Address', 'wpsc' ), array( $this, 'rss_address_meta_box' ), 'wpsc' );
|
11 |
+
add_meta_box( 'wpsc_google_merch_center', __( 'Google Merchant Centre / Google Product Search', 'wpsc' ), array( $this, 'google_merch_center_meta_box' ), 'wpsc' );
|
12 |
+
|
13 |
+
do_meta_boxes( 'wpsc', 'advanced', null );
|
14 |
+
?>
|
15 |
+
|
16 |
+
</div>
|
17 |
+
<?php
|
18 |
+
}
|
19 |
+
|
20 |
+
public function marketing_meta_box() {
|
21 |
+
|
22 |
+
$wpsc_also_bought = get_option( 'wpsc_also_bought' );
|
23 |
+
$wpsc_also_bought1 = '';
|
24 |
+
|
25 |
+
if ( '1' == $wpsc_also_bought )
|
26 |
+
$wpsc_also_bought1 = "checked ='checked'";
|
27 |
+
|
28 |
+
$wpsc_share_this = get_option( 'wpsc_share_this' );
|
29 |
+
$wpsc_share_this1 = '';
|
30 |
+
|
31 |
+
if ( '1' == $wpsc_share_this )
|
32 |
+
$wpsc_share_this1 = "checked ='checked'";
|
33 |
+
|
34 |
+
$facebook_like = get_option( 'wpsc_facebook_like' );
|
35 |
+
$facebook_like1 = '';
|
36 |
+
if ( 'on' == $facebook_like )
|
37 |
+
$facebook_like1 = "checked ='checked'";
|
38 |
+
|
39 |
+
$display_find_us = get_option( 'display_find_us' );
|
40 |
+
$display_find_us1 = '';
|
41 |
+
|
42 |
+
if ( '1' == $display_find_us )
|
43 |
+
$display_find_us1 = "checked ='checked'"; ?>
|
44 |
+
<input type='hidden' name='change-settings' value='true' />
|
45 |
+
<p>
|
46 |
+
<span class='input_label'><?php _e( 'Display Cross Sales', 'wpsc' ); ?></span>
|
47 |
+
<input <?php echo $wpsc_also_bought1; ?> type='checkbox' name='wpsc_also_bought' />
|
48 |
+
<span class='description'> <?php _e( 'Adds the \'Users who bought this also bought\' item to the single products page.', 'wpsc' ); ?></span>
|
49 |
+
</p><br />
|
50 |
+
<p>
|
51 |
+
<span class='input_label'><?php _e( 'Show Share This (Social Bookmarks)', 'wpsc' ); ?></span>
|
52 |
+
<input <?php echo $wpsc_share_this1; ?> type='checkbox' name='wpsc_share_this' />
|
53 |
+
<span class='description'> <?php _e( 'Adds the \'Share this link\' item to the single products page.', 'wpsc' ); ?></span>
|
54 |
+
</p><br />
|
55 |
+
<p>
|
56 |
+
<span class='input_label'> <?php _e( 'Display How Customer Found Us Survey', 'wpsc' ) ?></span>
|
57 |
+
<input <?php echo $display_find_us1; ?> type='checkbox' name='display_find_us' />
|
58 |
+
<span class='description'> <?php _e( 'Adds the \'How did you find out about us\' drop-down option at checkout.', 'wpsc' ) ?></span>
|
59 |
+
</p><br />
|
60 |
+
<p>
|
61 |
+
<span class='input_label'> <?php _e( 'Display Facebook Like', 'wpsc' ) ?></span>
|
62 |
+
<input type='hidden' value='0' name='wpsc_options[wpsc_facebook_like]' />
|
63 |
+
<input <?php echo $facebook_like1; ?> type='checkbox' name='wpsc_options[wpsc_facebook_like]' />
|
64 |
+
<span class='description'> <?php _e( 'Adds the Facebook Like button on your single products page.', 'wpsc' ) ?></span>
|
65 |
+
</p><br />
|
66 |
+
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
|
70 |
+
public function rss_address_meta_box() {
|
71 |
+
?>
|
72 |
+
<p><?php _e( 'People can use this RSS feed to keep up to date with your product list.', 'wpsc' ); ?></p>
|
73 |
+
<p><?php _e( 'RSS Feed Address', 'wpsc' ) ?> : <?php echo get_bloginfo( 'url' ) . "/index.php?rss=true&action=product_list"; ?></p>
|
74 |
+
<?php
|
75 |
+
}
|
76 |
+
|
77 |
+
function google_merch_center_meta_box() {
|
78 |
+
?>
|
79 |
+
<p><?php _e( 'To import your products into <a href="http://www.google.com/merchants/" target="_blank">Google Merchant Centre</a> so that they appear within Google Product Search results, sign up for a Google Merchant Centre account and add a scheduled data feed with the following URL:', 'wpsc' ); ?></p>
|
80 |
+
|
81 |
+
<?php $google_feed_url = get_bloginfo( 'url' ) . "/index.php?rss=true&action=product_list&xmlformat=google"; ?>
|
82 |
+
|
83 |
+
<a href="<?php esc_attr_e( htmlentities( $google_feed_url, ENT_QUOTES, 'UTF-8' ) ); ?>"><?php esc_attr_e( htmlentities( $google_feed_url, ENT_QUOTES, 'UTF-8' ) ); ?></a>
|
84 |
+
|
85 |
+
<?php
|
86 |
+
}
|
87 |
+
}
|
wpsc-admin/includes/{settings-pages → settings-tabs}/presentation.php
RENAMED
@@ -1,220 +1,186 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
*/
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Metabox for theme moving
|
11 |
-
* Location: Settings > Presentation page in WP-Admin
|
12 |
-
* @access public
|
13 |
-
*
|
14 |
-
* @since 3.8
|
15 |
-
* @param null
|
16 |
-
* @return null
|
17 |
-
*/
|
18 |
-
function wpsc_theme_presentation_page_metabox(){
|
19 |
-
|
20 |
-
$wpsc_templates = wpsc_list_product_templates();
|
21 |
-
$themes_location = wpsc_check_theme_location();
|
22 |
-
$themes_copied = false; //Check to see whether themes have been copied to selected Theme Folder
|
23 |
-
$themes_backedup = false; //Check to see whether themes have recently been backedup
|
24 |
-
$themes_in_uploads = false; //Check to see whether themes live in the uploads directory
|
25 |
-
|
26 |
-
if ( isset( $_SESSION['wpsc_themes_copied'] ) && ( true == $_SESSION['wpsc_themes_copied'] ) )
|
27 |
-
$themes_copied = true;
|
28 |
-
|
29 |
-
if ( isset( $_SESSION['wpsc_themes_backup'] ) && ( true == $_SESSION['wpsc_themes_backup'] ) )
|
30 |
-
$themes_backedup = true;
|
31 |
-
|
32 |
-
if ( wpsc_count_themes_in_uploads_directory() > 0 ) {
|
33 |
-
$themes_in_uploads = true;
|
34 |
-
|
35 |
-
foreach( (array)$themes_location as $location )
|
36 |
-
$new_location[] = str_ireplace( 'wpsc-','', $location );
|
37 |
-
|
38 |
-
$themes_location = $new_location;
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
do_action( 'wpsc_move_theme' );
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
<?php
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
-
if ( isset( $_SESSION['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
?>
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
<?php
|
82 |
-
$
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
<?php
|
102 |
-
foreach($wpsc_templates as $file){
|
103 |
-
$id = str_ireplace('.', '_', $file);
|
104 |
-
$selected = '';
|
105 |
-
if(false !== array_search($file, (array)$themes_location))
|
106 |
-
$selected = 'checked="checked"';
|
107 |
?>
|
108 |
-
<
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
<?php } ?>
|
119 |
-
<p><?php
|
120 |
-
wp_nonce_field('wpsc_copy_themes');
|
121 |
-
?>
|
122 |
-
<input type='submit' value='Move Template Files →' class="button" name='wpsc_move_themes' />
|
123 |
-
</p>
|
124 |
-
<p><?php _e('You can create a copy of your WordPress Theme by clicking the backup button bellow. Once copied you can find them here:' ,'wpsc'); ?></p>
|
125 |
-
<p class="howto"> /wp-content/uploads/wpsc/theme_backup/ </p>
|
126 |
-
<p>
|
127 |
-
<?php
|
128 |
-
printf( __( '<a href="%s" class="button">Backup Your WordPress Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
|
129 |
<br style="clear:both" />
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
<br style="clear:both" />
|
137 |
-
</div>
|
138 |
</div>
|
139 |
-
|
140 |
-
<?php
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* options categorylist provides a drop down of different options for displaying the products page
|
145 |
-
* @access public
|
146 |
-
*
|
147 |
-
* @since 3.7
|
148 |
-
* @param null
|
149 |
-
* @return $categorylist XHTML markup
|
150 |
-
*/
|
151 |
-
function options_categorylist() {
|
152 |
-
global $wpdb;
|
153 |
-
|
154 |
-
$current_default = esc_attr( get_option( 'wpsc_default_category' ) );
|
155 |
-
$group_data = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=0' );
|
156 |
-
$categorylist = "<select name='wpsc_options[wpsc_default_category]'>";
|
157 |
-
|
158 |
-
if ( $current_default == 'all' )
|
159 |
-
$selected = "selected='selected'";
|
160 |
-
else
|
161 |
-
$selected = '';
|
162 |
-
|
163 |
-
$categorylist .= "<option value='all' " . $selected . " >" . __( 'Show All Products', 'wpsc' ) . "</option>";
|
164 |
-
|
165 |
-
if ( $current_default == 'list' )
|
166 |
-
$selected = "selected='selected'";
|
167 |
-
else
|
168 |
-
$selected = '';
|
169 |
-
|
170 |
-
$categorylist .= "<option value='list' " . $selected . " >" . __( 'Show list of product categories', 'wpsc' ) . "</option>";
|
171 |
-
|
172 |
-
$categorylist .= "<optgroup label='Product Categories'>";
|
173 |
-
foreach ( $group_data as $group ) {
|
174 |
-
$selected = "";
|
175 |
-
if ( $current_default == $group->term_id )
|
176 |
-
$selected = "selected='selected'";
|
177 |
-
else
|
178 |
-
$selected = "";
|
179 |
-
|
180 |
-
$categorylist .= "<option value='" . $group->term_id . "' " . $selected . " >" . $group->name . "</option>";
|
181 |
-
$category_data = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $group->term_id );
|
182 |
-
if ( $category_data != null ) {
|
183 |
-
foreach ( $category_data as $category ) {
|
184 |
-
if ( $current_default == $category->term_id )
|
185 |
-
$selected = "selected='selected'";
|
186 |
-
else
|
187 |
-
$selected = "";
|
188 |
-
$categorylist .= "<option value='" . $category->term_id . "' " . $selected . " >" . $category->name . "</option>";
|
189 |
-
}
|
190 |
-
}
|
191 |
}
|
192 |
-
$categorylist .= "</optgroup>";
|
193 |
-
$categorylist .= "</select>";
|
194 |
-
return $categorylist;
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* options presentation is the main function for displaying the WP-Admin : Settings > Presentation page
|
199 |
-
* @access public
|
200 |
-
*
|
201 |
-
* @since 3.7
|
202 |
-
* @param null
|
203 |
-
* @return null
|
204 |
-
*/
|
205 |
-
function wpsc_options_presentation() {
|
206 |
-
global $wpdb;
|
207 |
-
|
208 |
-
?>
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
<?php wpsc_settings_page_update_notification(); ?>
|
214 |
-
|
215 |
-
<div class='product_and_button_settings'>
|
216 |
<h3 class="form_group"><?php _e( 'Button Settings', 'wpsc' ); ?></h3>
|
217 |
-
|
218 |
<table class='wpsc_options form-table'>
|
219 |
<tr>
|
220 |
<th scope="row"><?php _e( 'Button Type', 'wpsc' ); ?>:</th>
|
@@ -234,13 +200,13 @@ function wpsc_options_presentation() {
|
|
234 |
}
|
235 |
?>
|
236 |
<input type='radio' value='0' name='wpsc_options[addtocart_or_buynow]' id='addtocart_or_buynow1' <?php echo $addtocart_or_buynow1; ?> />
|
237 |
-
<label for='addtocart_or_buynow1'><?php _e( 'Add To Cart', 'wpsc' ); ?></label> <br />
|
238 |
<?php $selected_gateways = get_option( 'custom_gateway_options' );
|
239 |
$disable_buy_now = '';
|
240 |
$message = '';
|
241 |
-
if (!in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways )){
|
242 |
$disable_buy_now = 'disabled="disabled"';
|
243 |
-
$message = __('Buy Now Button only works for Paypal Standard, please activate Paypal Standard to enable this option.','wpsc');
|
244 |
} ?>
|
245 |
<input <?php echo $disable_buy_now; ?> type='radio' value='1' name='wpsc_options[addtocart_or_buynow]' id='addtocart_or_buynow2' <?php echo $addtocart_or_buynow2; ?> />
|
246 |
<label for='addtocart_or_buynow2'><?php _e( 'Buy Now', 'wpsc' ); ?></label><br />
|
@@ -303,7 +269,7 @@ function wpsc_options_presentation() {
|
|
303 |
if ( get_option( 'list_view_quantity' ) == 1 )
|
304 |
$list_view_quantity_value1 = 'checked="checked"';
|
305 |
else
|
306 |
-
$list_view_quantity_value2 = 'checked="checked"';
|
307 |
?>
|
308 |
<th scope="row">
|
309 |
<?php _e('Show Stock Availability','wpsc'); ?>
|
@@ -410,7 +376,7 @@ function wpsc_options_presentation() {
|
|
410 |
</table>
|
411 |
</div>
|
412 |
|
413 |
-
<?php
|
414 |
|
415 |
<div style='clear:both;'></div>
|
416 |
|
@@ -499,8 +465,8 @@ function wpsc_options_presentation() {
|
|
499 |
?>
|
500 |
</td>
|
501 |
</tr>
|
502 |
-
|
503 |
-
|
504 |
<tr id="wpsc-grid-settings">
|
505 |
<th scope="row"><?php _e( 'Grid view settings:', 'wpsc' ) ?></th>
|
506 |
<td>
|
@@ -508,36 +474,36 @@ function wpsc_options_presentation() {
|
|
508 |
<label for='grid_number_per_row'><?php _e( 'Products Per Row', 'wpsc' ); ?></label><br />
|
509 |
|
510 |
<input type='hidden' value='0' name='wpsc_options[show_images_only]' />
|
511 |
-
<input type='checkbox' value='1' name='wpsc_options[show_images_only]' id='
|
512 |
-
<label for='
|
513 |
|
514 |
<input type='hidden' value='0' name='wpsc_options[display_variations]' />
|
515 |
-
<input type='checkbox' value='1' name='wpsc_options[display_variations]' id='
|
516 |
-
<label for='
|
517 |
|
518 |
<input type='hidden' value='0' name='wpsc_options[display_description]' />
|
519 |
-
<input type='checkbox' value='1' name='wpsc_options[display_description]' id='
|
520 |
-
<label for='
|
521 |
|
522 |
<input type='hidden' value='0' name='wpsc_options[display_addtocart]' />
|
523 |
-
<input type='checkbox' value='1' name='wpsc_options[display_addtocart]' id='
|
524 |
-
<label for='
|
525 |
|
526 |
<input type='hidden' value='0' name='wpsc_options[display_moredetails]' />
|
527 |
-
<input type='checkbox' value='1' name='wpsc_options[display_moredetails]' id='
|
528 |
-
<label for='
|
529 |
</td>
|
530 |
</tr>
|
531 |
-
|
532 |
-
|
533 |
<?php
|
534 |
$selected1 = $selected2 = '';
|
535 |
if(get_option('wpsc_display_categories'))
|
536 |
$selected1 = 'checked="checked"';
|
537 |
else
|
538 |
-
$selected2 = 'checked="checked"';
|
539 |
?>
|
540 |
-
|
541 |
<tr>
|
542 |
<th scope="row"><?php _e('Show list of categories','wpsc'); ?></th>
|
543 |
<td>
|
@@ -546,11 +512,11 @@ function wpsc_options_presentation() {
|
|
546 |
<label for='display_categories1'><?php _e( 'No', 'wpsc' ); ?></label><br />
|
547 |
</td>
|
548 |
</tr>
|
549 |
-
|
550 |
<tr>
|
551 |
<th scope="row"><?php _e( 'Select what product category you want to display on the products page', 'wpsc' ); ?>:</th>
|
552 |
<td>
|
553 |
-
<?php echo
|
554 |
</td>
|
555 |
</tr>
|
556 |
<?php
|
@@ -639,7 +605,7 @@ function wpsc_options_presentation() {
|
|
639 |
<input type='radio' value='1' name='wpsc_options[catsprods_display_type]' id='catsprods_display_type2' <?php echo $catsprods_display_type2; ?> /> <label for='catsprods_display_type2'><?php _e( 'Sliding Product Groups (1 product per page)', 'wpsc' ); ?></label>
|
640 |
</td>
|
641 |
</tr>
|
642 |
-
|
643 |
<tr>
|
644 |
<th scope="row">
|
645 |
<?php echo __( 'Show Subcategory Products in Parent Category', 'wpsc' ); ?>:
|
@@ -701,7 +667,7 @@ function wpsc_options_presentation() {
|
|
701 |
} else {
|
702 |
$dis = "";
|
703 |
}
|
704 |
-
|
705 |
$embed_live_search_results = get_option( 'embed_live_search_results', '0' ) == '1' ? ' checked="checked"' : '';
|
706 |
?>
|
707 |
<input type='radio' onclick='jQuery("#wpsc_advanced_search").show()' value='1' name='wpsc_options[show_search]' id='show_search1' <?php echo $show_search1; ?> /> <label for='show_search1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
@@ -716,7 +682,7 @@ function wpsc_options_presentation() {
|
|
716 |
<?php _e( 'Use Live Search', 'wpsc' ); ?><br />
|
717 |
<input type='hidden' name='wpsc_options[embed_live_search_results]' value='0' />
|
718 |
<input type='checkbox' name='wpsc_options[embed_live_search_results]' id='embed_live_search_results'<?php echo $embed_live_search_results; ?> value='1' />
|
719 |
-
<?php _e( 'Dynamically replace search results into product list' ); ?>
|
720 |
</div>
|
721 |
</td>
|
722 |
</tr>
|
@@ -1008,7 +974,7 @@ function wpsc_options_presentation() {
|
|
1008 |
</th>
|
1009 |
<td>
|
1010 |
<?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_width]' value='<?php esc_attr_e( get_option( 'single_view_image_width' ) ); ?>' />
|
1011 |
-
<?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_height]' value='<?php esc_attr_e( get_option( 'single_view_image_height' ) ); ?>' />
|
1012 |
</td>
|
1013 |
</tr>
|
1014 |
<tr>
|
@@ -1098,7 +1064,7 @@ function wpsc_options_presentation() {
|
|
1098 |
<input type='radio' value='thickbox' name='wpsc_options[wpsc_lightbox]' id='wpsc_lightbox_thickbox2' <?php echo $wpsc_lightbox_thickbox2; ?> /> <label for='show_thumbnails_thickbox2'><?php _e( 'Thickbox', 'wpsc' ); ?></label><br />
|
1099 |
</td>
|
1100 |
</tr>
|
1101 |
-
|
1102 |
<?php
|
1103 |
if ( function_exists( 'gold_shpcrt_display_gallery' ) ) {
|
1104 |
?>
|
@@ -1131,12 +1097,12 @@ function wpsc_options_presentation() {
|
|
1131 |
<?php _e( "Gallery Thumbnail Image Size", 'wpsc' ); ?>:
|
1132 |
</th>
|
1133 |
<td>
|
1134 |
-
<?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[wpsc_gallery_image_width]' value='<?php esc_attr_e( get_option( 'wpsc_gallery_image_width' ) ); ?>' />
|
1135 |
<?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[wpsc_gallery_image_height]' value='<?php esc_attr_e( get_option( 'wpsc_gallery_image_height' ) ); ?>' /><br />
|
1136 |
|
1137 |
</td>
|
1138 |
</tr>
|
1139 |
-
|
1140 |
<?php
|
1141 |
}
|
1142 |
?>
|
@@ -1250,16 +1216,6 @@ function wpsc_options_presentation() {
|
|
1250 |
|
1251 |
</tr>
|
1252 |
</table>
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
1257 |
-
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
1258 |
-
<input type="submit" value="<?php _e( 'Update »', 'wpsc' ); ?>" name="updateoption" />
|
1259 |
-
</div>
|
1260 |
-
</div>
|
1261 |
-
</form>
|
1262 |
-
<?php
|
1263 |
-
}
|
1264 |
-
|
1265 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Presentation extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
public function __construct() {
|
6 |
+
$this->page_title = __( 'General Settings', 'wpsc' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
|
9 |
+
public function category_list() {
|
10 |
+
global $wpdb;
|
|
|
11 |
|
12 |
+
$current_default = esc_attr( get_option( 'wpsc_default_category' ) );
|
13 |
+
$group_data = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=0' );
|
14 |
+
$categorylist = "<select name='wpsc_options[wpsc_default_category]'>";
|
15 |
+
|
16 |
+
if ( $current_default == 'all' )
|
17 |
+
$selected = "selected='selected'";
|
18 |
+
else
|
19 |
+
$selected = '';
|
20 |
+
|
21 |
+
$categorylist .= "<option value='all' " . $selected . " >" . __( 'Show All Products', 'wpsc' ) . "</option>";
|
22 |
+
|
23 |
+
if ( $current_default == 'list' )
|
24 |
+
$selected = "selected='selected'";
|
25 |
+
else
|
26 |
+
$selected = '';
|
27 |
+
|
28 |
+
$categorylist .= "<option value='list' " . $selected . " >" . __( 'Show list of product categories', 'wpsc' ) . "</option>";
|
29 |
+
|
30 |
+
$categorylist .= "<optgroup label='Product Categories'>";
|
31 |
+
foreach ( $group_data as $group ) {
|
32 |
+
$selected = "";
|
33 |
+
if ( $current_default == $group->term_id )
|
34 |
+
$selected = "selected='selected'";
|
35 |
+
else
|
36 |
+
$selected = "";
|
37 |
+
|
38 |
+
$categorylist .= "<option value='" . $group->term_id . "' " . $selected . " >" . $group->name . "</option>";
|
39 |
+
$category_data = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $group->term_id );
|
40 |
+
if ( $category_data != null ) {
|
41 |
+
foreach ( $category_data as $category ) {
|
42 |
+
if ( $current_default == $category->term_id )
|
43 |
+
$selected = "selected='selected'";
|
44 |
+
else
|
45 |
+
$selected = "";
|
46 |
+
$categorylist .= "<option value='" . $category->term_id . "' " . $selected . " >" . $category->name . "</option>";
|
47 |
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
$categorylist .= "</optgroup>";
|
51 |
+
$categorylist .= "</select>";
|
52 |
+
return $categorylist;
|
53 |
+
}
|
54 |
+
|
55 |
+
private function theme_metabox(){
|
56 |
+
|
57 |
+
$wpsc_templates = wpsc_list_product_templates();
|
58 |
+
$themes_location = wpsc_check_theme_location();
|
59 |
+
$themes_copied = false; //Check to see whether themes have been copied to selected Theme Folder
|
60 |
+
$themes_backedup = false; //Check to see whether themes have recently been backedup
|
61 |
+
$themes_in_uploads = false; //Check to see whether themes live in the uploads directory
|
62 |
+
|
63 |
+
if ( isset( $_SESSION['wpsc_themes_copied'] ) && ( true == $_SESSION['wpsc_themes_copied'] ) )
|
64 |
+
$themes_copied = true;
|
65 |
+
|
66 |
+
if ( isset( $_SESSION['wpsc_themes_backup'] ) && ( true == $_SESSION['wpsc_themes_backup'] ) )
|
67 |
+
$themes_backedup = true;
|
68 |
+
|
69 |
+
if ( wpsc_count_themes_in_uploads_directory() > 0 ) {
|
70 |
+
$themes_in_uploads = true;
|
71 |
+
|
72 |
+
foreach( (array)$themes_location as $location )
|
73 |
+
$new_location[] = str_ireplace( 'wpsc-','', $location );
|
74 |
+
|
75 |
+
$themes_location = $new_location;
|
76 |
+
}
|
77 |
+
|
78 |
+
// Used to flush transients - @since 3.8-development
|
79 |
+
if ( true === $themes_copied )
|
80 |
+
do_action( 'wpsc_move_theme' );
|
81 |
+
|
82 |
+
?>
|
83 |
+
<div id="poststuff" class="metabox-holder">
|
84 |
+
<div id="themes_and_appearance" class='postbox'>
|
85 |
+
<h3 class="hndle"><span><?php _e( "Advanced Theme Settings", 'wpsc' ); ?></span></h3>
|
86 |
+
<div class="inside">
|
87 |
<?php
|
88 |
+
|
89 |
+
if( isset( $_SESSION['wpsc_theme_empty'] ) && ($_SESSION['wpsc_theme_empty'] == true) ) {
|
90 |
+
?>
|
91 |
+
|
92 |
+
<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
|
93 |
+
<p><?php _e('You did not specify any template files to be moved.','wpsc'); ?></p>
|
94 |
+
</div>
|
95 |
+
<?php
|
96 |
+
$_SESSION['wpsc_theme_empty'] = false;
|
97 |
+
$themes_copied = false;
|
98 |
}
|
99 |
+
if ( isset( $_SESSION['wpsc_themes_copied'] ) && ($_SESSION['wpsc_themes_copied'] == true) ) {
|
100 |
+
?>
|
101 |
+
<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
|
102 |
+
<?php if(in_array(false, $_SESSION['wpsc_themes_copied_results'], true)): ?>
|
103 |
+
<p style="color:red;"><?php _e( "Error: some files could not be copied. Please make sure that theme folder is writable.", 'wpsc' ); ?></p>
|
104 |
+
<?php else: ?>
|
105 |
+
<p><?php _e( "Thanks, the themes have been copied.", 'wpsc' ); ?></p>
|
106 |
+
<?php endif; ?>
|
107 |
+
</div>
|
108 |
+
<?php
|
109 |
+
unset($_SESSION['wpsc_themes_copied']);
|
110 |
+
unset($_SESSION['wpsc_themes_copied_results']);
|
111 |
+
}
|
112 |
+
if ( isset( $_SESSION['wpsc_themes_backup'] ) && ($_SESSION['wpsc_themes_backup'] == true) ) {
|
113 |
+
?>
|
114 |
+
<div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);">
|
115 |
+
<p><?php _e( "Thanks, you have made a succesful backup of your theme. It is located at the URL below. Please note each backup you create will replace your previous backups.", 'wpsc' ); ?></p>
|
116 |
+
<p>URL: <?php echo "/" . str_replace( ABSPATH, "", WPSC_THEME_BACKUP_DIR ); ?></p>
|
117 |
+
</div>
|
118 |
+
<?php
|
119 |
+
$_SESSION['wpsc_themes_backup'] = false;
|
120 |
+
}
|
121 |
?>
|
122 |
+
<p>
|
123 |
+
<?php if(false !== $themes_location)
|
124 |
+
//Some themes have been moved to the themes folder
|
125 |
+
_e('Some Theme files have been moved to your WordPress Theme Folder.','wpsc');
|
126 |
+
else
|
127 |
+
_e('No Theme files have been moved to your WordPress Theme Folder.','wpsc');
|
128 |
+
|
129 |
+
?>
|
130 |
+
|
131 |
+
</p>
|
132 |
+
<p>
|
133 |
+
<?php _e('WP e-Commerce provides you the ability to move your theme files to a safe place for theming control.
|
134 |
+
|
135 |
+
If you want to change the look of your site, select the files you want to edit from the list and click the move button. This will copy the template files to your active WordPress theme. ','wpsc'); ?>
|
136 |
+
</p>
|
137 |
+
<ul>
|
138 |
<?php
|
139 |
+
foreach($wpsc_templates as $file){
|
140 |
+
$id = str_ireplace('.', '_', $file);
|
141 |
+
$selected = '';
|
142 |
+
if(false !== array_search($file, (array)$themes_location))
|
143 |
+
$selected = 'checked="checked"';
|
144 |
+
?>
|
145 |
+
<li><input type='checkbox' id='<?php echo $id; ?>' <?php echo $selected; ?> value='<?php esc_attr_e( $file ); ?>' name='wpsc_templates_to_port[]' />
|
146 |
+
<label for='<?php echo $id; ?>'><?php esc_attr_e( $file ); ?></label></li>
|
147 |
+
<?php } ?>
|
148 |
+
</ul>
|
149 |
+
<p>
|
150 |
+
<?php if(false !== $themes_location){
|
151 |
+
_e('To change the look of certain aspects of your shop, you can edit the moved files that are found here:','wpsc');
|
152 |
+
?>
|
153 |
+
</p>
|
154 |
+
<p class="howto"> <?php echo get_stylesheet_directory(); ?></p>
|
155 |
+
<?php } ?>
|
156 |
+
<p><?php
|
157 |
+
wp_nonce_field('wpsc_copy_themes');
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
?>
|
159 |
+
<input type='submit' value='Move Template Files →' class="button" name='wpsc_move_themes' />
|
160 |
+
</p>
|
161 |
+
<p><?php _e('You can create a copy of your WordPress Theme by clicking the backup button bellow. Once copied you can find them here:' ,'wpsc'); ?></p>
|
162 |
+
<p class="howto"> /wp-content/uploads/wpsc/theme_backup/ </p>
|
163 |
+
<p>
|
164 |
+
<?php
|
165 |
+
printf( __( '<a href="%s" class="button">Backup Your WordPress Theme</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_admin_action=backup_themes', 'backup_themes' ) ); ?>
|
166 |
+
<br style="clear:both" />
|
167 |
+
</p>
|
168 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
<br style="clear:both" />
|
170 |
+
<p><?php _e('If you have moved your files in some other way i.e FTP, you may need to click the Flush Theme Cache. This will refresh the locations WordPress looks for your templates.' ,'wpsc'); ?></p>
|
171 |
+
<p><?php printf( __( '<a href="%s" class="button">Flush Theme Cache</a>', 'wpsc' ), wp_nonce_url( 'admin.php?wpsc_flush_theme_transients=true', 'wpsc_flush_theme_transients' ) ); ?></p>
|
172 |
+
<br style="clear:both" />
|
173 |
+
<br style="clear:both" />
|
174 |
+
</div>
|
175 |
+
</div>
|
|
|
|
|
176 |
</div>
|
177 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
public function display() {
|
181 |
+
?>
|
182 |
+
<div class='product_and_button_settings'>
|
|
|
|
|
|
|
183 |
<h3 class="form_group"><?php _e( 'Button Settings', 'wpsc' ); ?></h3>
|
|
|
184 |
<table class='wpsc_options form-table'>
|
185 |
<tr>
|
186 |
<th scope="row"><?php _e( 'Button Type', 'wpsc' ); ?>:</th>
|
200 |
}
|
201 |
?>
|
202 |
<input type='radio' value='0' name='wpsc_options[addtocart_or_buynow]' id='addtocart_or_buynow1' <?php echo $addtocart_or_buynow1; ?> />
|
203 |
+
<label for='addtocart_or_buynow1'><?php _e( 'Add To Cart', 'wpsc' ); ?></label> <br />
|
204 |
<?php $selected_gateways = get_option( 'custom_gateway_options' );
|
205 |
$disable_buy_now = '';
|
206 |
$message = '';
|
207 |
+
if (!in_array( 'wpsc_merchant_paypal_standard', (array)$selected_gateways )){
|
208 |
$disable_buy_now = 'disabled="disabled"';
|
209 |
+
$message = __('Buy Now Button only works for Paypal Standard, please activate Paypal Standard to enable this option.','wpsc');
|
210 |
} ?>
|
211 |
<input <?php echo $disable_buy_now; ?> type='radio' value='1' name='wpsc_options[addtocart_or_buynow]' id='addtocart_or_buynow2' <?php echo $addtocart_or_buynow2; ?> />
|
212 |
<label for='addtocart_or_buynow2'><?php _e( 'Buy Now', 'wpsc' ); ?></label><br />
|
269 |
if ( get_option( 'list_view_quantity' ) == 1 )
|
270 |
$list_view_quantity_value1 = 'checked="checked"';
|
271 |
else
|
272 |
+
$list_view_quantity_value2 = 'checked="checked"';
|
273 |
?>
|
274 |
<th scope="row">
|
275 |
<?php _e('Show Stock Availability','wpsc'); ?>
|
376 |
</table>
|
377 |
</div>
|
378 |
|
379 |
+
<?php $this->theme_metabox(); ?>
|
380 |
|
381 |
<div style='clear:both;'></div>
|
382 |
|
465 |
?>
|
466 |
</td>
|
467 |
</tr>
|
468 |
+
|
469 |
+
|
470 |
<tr id="wpsc-grid-settings">
|
471 |
<th scope="row"><?php _e( 'Grid view settings:', 'wpsc' ) ?></th>
|
472 |
<td>
|
474 |
<label for='grid_number_per_row'><?php _e( 'Products Per Row', 'wpsc' ); ?></label><br />
|
475 |
|
476 |
<input type='hidden' value='0' name='wpsc_options[show_images_only]' />
|
477 |
+
<input type='checkbox' value='1' name='wpsc_options[show_images_only]' id='wpsc-show-images-only' <?php echo $show_images_only_value; ?> />
|
478 |
+
<label for='wpsc-show-images-only'><?php _e( 'Show images only', 'wpsc' ); ?></label><br />
|
479 |
|
480 |
<input type='hidden' value='0' name='wpsc_options[display_variations]' />
|
481 |
+
<input type='checkbox' value='1' name='wpsc_options[display_variations]' id='wpsc-display-variations' <?php echo $display_variations; ?> />
|
482 |
+
<label for='wpsc-display-variations'><?php _e( 'Display Variations', 'wpsc' ); ?></label><br />
|
483 |
|
484 |
<input type='hidden' value='0' name='wpsc_options[display_description]' />
|
485 |
+
<input type='checkbox' value='1' name='wpsc_options[display_description]' id='wpsc-display-description' <?php echo $display_description; ?> />
|
486 |
+
<label for='wpsc-display-description'><?php _e( 'Display Description', 'wpsc' ); ?></label><br />
|
487 |
|
488 |
<input type='hidden' value='0' name='wpsc_options[display_addtocart]' />
|
489 |
+
<input type='checkbox' value='1' name='wpsc_options[display_addtocart]' id='wpsc-display-add-to-cart' <?php echo $display_addtocart; ?> />
|
490 |
+
<label for='wpsc-display-add-to-cart'><?php _e( 'Display "Add To Cart" Button', 'wpsc' ); ?></label><br />
|
491 |
|
492 |
<input type='hidden' value='0' name='wpsc_options[display_moredetails]' />
|
493 |
+
<input type='checkbox' value='1' name='wpsc_options[display_moredetails]' id='wpsc-display-more-details' <?php echo $display_moredetails; ?> />
|
494 |
+
<label for='wpsc-display-more-details'><?php _e( 'Display "More Details" Button', 'wpsc' ); ?></label>
|
495 |
</td>
|
496 |
</tr>
|
497 |
+
|
498 |
+
|
499 |
<?php
|
500 |
$selected1 = $selected2 = '';
|
501 |
if(get_option('wpsc_display_categories'))
|
502 |
$selected1 = 'checked="checked"';
|
503 |
else
|
504 |
+
$selected2 = 'checked="checked"';
|
505 |
?>
|
506 |
+
|
507 |
<tr>
|
508 |
<th scope="row"><?php _e('Show list of categories','wpsc'); ?></th>
|
509 |
<td>
|
512 |
<label for='display_categories1'><?php _e( 'No', 'wpsc' ); ?></label><br />
|
513 |
</td>
|
514 |
</tr>
|
515 |
+
|
516 |
<tr>
|
517 |
<th scope="row"><?php _e( 'Select what product category you want to display on the products page', 'wpsc' ); ?>:</th>
|
518 |
<td>
|
519 |
+
<?php echo $this->category_list(); ?>
|
520 |
</td>
|
521 |
</tr>
|
522 |
<?php
|
605 |
<input type='radio' value='1' name='wpsc_options[catsprods_display_type]' id='catsprods_display_type2' <?php echo $catsprods_display_type2; ?> /> <label for='catsprods_display_type2'><?php _e( 'Sliding Product Groups (1 product per page)', 'wpsc' ); ?></label>
|
606 |
</td>
|
607 |
</tr>
|
608 |
+
|
609 |
<tr>
|
610 |
<th scope="row">
|
611 |
<?php echo __( 'Show Subcategory Products in Parent Category', 'wpsc' ); ?>:
|
667 |
} else {
|
668 |
$dis = "";
|
669 |
}
|
670 |
+
|
671 |
$embed_live_search_results = get_option( 'embed_live_search_results', '0' ) == '1' ? ' checked="checked"' : '';
|
672 |
?>
|
673 |
<input type='radio' onclick='jQuery("#wpsc_advanced_search").show()' value='1' name='wpsc_options[show_search]' id='show_search1' <?php echo $show_search1; ?> /> <label for='show_search1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
682 |
<?php _e( 'Use Live Search', 'wpsc' ); ?><br />
|
683 |
<input type='hidden' name='wpsc_options[embed_live_search_results]' value='0' />
|
684 |
<input type='checkbox' name='wpsc_options[embed_live_search_results]' id='embed_live_search_results'<?php echo $embed_live_search_results; ?> value='1' />
|
685 |
+
<?php _e( 'Dynamically replace search results into product list', 'wpsc' ); ?>
|
686 |
</div>
|
687 |
</td>
|
688 |
</tr>
|
974 |
</th>
|
975 |
<td>
|
976 |
<?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_width]' value='<?php esc_attr_e( get_option( 'single_view_image_width' ) ); ?>' />
|
977 |
+
<?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[single_view_image_height]' value='<?php esc_attr_e( get_option( 'single_view_image_height' ) ); ?>' />
|
978 |
</td>
|
979 |
</tr>
|
980 |
<tr>
|
1064 |
<input type='radio' value='thickbox' name='wpsc_options[wpsc_lightbox]' id='wpsc_lightbox_thickbox2' <?php echo $wpsc_lightbox_thickbox2; ?> /> <label for='show_thumbnails_thickbox2'><?php _e( 'Thickbox', 'wpsc' ); ?></label><br />
|
1065 |
</td>
|
1066 |
</tr>
|
1067 |
+
|
1068 |
<?php
|
1069 |
if ( function_exists( 'gold_shpcrt_display_gallery' ) ) {
|
1070 |
?>
|
1097 |
<?php _e( "Gallery Thumbnail Image Size", 'wpsc' ); ?>:
|
1098 |
</th>
|
1099 |
<td>
|
1100 |
+
<?php _e( 'Width', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[wpsc_gallery_image_width]' value='<?php esc_attr_e( get_option( 'wpsc_gallery_image_width' ) ); ?>' />
|
1101 |
<?php _e( 'Height', 'wpsc' ); ?>:<input type='text' size='6' name='wpsc_options[wpsc_gallery_image_height]' value='<?php esc_attr_e( get_option( 'wpsc_gallery_image_height' ) ); ?>' /><br />
|
1102 |
|
1103 |
</td>
|
1104 |
</tr>
|
1105 |
+
|
1106 |
<?php
|
1107 |
}
|
1108 |
?>
|
1216 |
|
1217 |
</tr>
|
1218 |
</table>
|
1219 |
+
<?php
|
1220 |
+
}
|
1221 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-admin/includes/settings-tabs/shipping.php
ADDED
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab
|
3 |
+
{
|
4 |
+
public function __construct() {
|
5 |
+
parent::__construct();
|
6 |
+
|
7 |
+
if ( isset( $_REQUEST['shipping_module_id'] ) )
|
8 |
+
update_user_option( get_current_user_id(), 'wpsc_settings_selected_shipping_module', $_REQUEST['shipping_module_id'] );
|
9 |
+
}
|
10 |
+
|
11 |
+
public function display_shipping_module_settings_form() {
|
12 |
+
global $wpsc_shipping_modules;
|
13 |
+
$classes = array( 'wpsc-module-settings' );
|
14 |
+
$selected_module_id = (string) get_user_option( 'wpsc_settings_selected_shipping_module', get_current_user_id() );
|
15 |
+
$found_selected_module = array_key_exists( $selected_module_id, $wpsc_shipping_modules );
|
16 |
+
if ( $found_selected_module ) {
|
17 |
+
$selected_module = $wpsc_shipping_modules[$selected_module_id];
|
18 |
+
$title = $selected_module->name;
|
19 |
+
$content = $selected_module->getForm();
|
20 |
+
$classes[] = 'wpsc-shipping-module-settings-' . $selected_module_id;
|
21 |
+
} else {
|
22 |
+
$title = __( 'Edit Shipping Module Settings', 'wpsc' );
|
23 |
+
$content = __( 'To configure a shipping module select one on the left.', 'wpsc' );
|
24 |
+
}
|
25 |
+
$classes = implode( ' ', $classes );
|
26 |
+
?>
|
27 |
+
<td id="wpsc-shipping-module-settings" class="<?php echo esc_attr( $classes ); ?>" rowspan='2'>
|
28 |
+
<div class='postbox'>
|
29 |
+
<h3 class='hndle'><?php echo esc_html( $title ); ?></h3>
|
30 |
+
<div class='inside'>
|
31 |
+
<table class='form-table'>
|
32 |
+
<?php echo $content; ?>
|
33 |
+
</table>
|
34 |
+
<?php if ( $found_selected_module ): ?>
|
35 |
+
<p class="submit">
|
36 |
+
<input type="submit" value="<?php _e( 'Update »', 'wpsc' ); ?>" />
|
37 |
+
</p>
|
38 |
+
<?php endif; ?>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
</td>
|
42 |
+
<?php
|
43 |
+
}
|
44 |
+
|
45 |
+
private function get_shipping_module_url( $shipping ) {
|
46 |
+
$location = ( isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'] );
|
47 |
+
$location = add_query_arg( array(
|
48 |
+
'tab' => 'shipping',
|
49 |
+
'page' => 'wpsc-settings',
|
50 |
+
'shipping_module_id' => $shipping->internal_name,
|
51 |
+
), $location );
|
52 |
+
$location .= '#wpsc-shipping-module-options';
|
53 |
+
return $location;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function display() {
|
57 |
+
global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
|
58 |
+
// sort into external and internal arrays.
|
59 |
+
foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
|
60 |
+
if(empty($module))continue;
|
61 |
+
if ( isset( $module->is_external ) && ($module->is_external == true) ) {
|
62 |
+
$external_shipping_modules[$key] = $module;
|
63 |
+
} else {
|
64 |
+
$internal_shipping_modules[$key] = $module;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", get_option( 'currency_type' ) ), ARRAY_A );
|
68 |
+
if ( $currency_data['symbol'] != '' ) {
|
69 |
+
$currency_sign = $currency_data['symbol_html'];
|
70 |
+
} else {
|
71 |
+
$currency_sign = $currency_data['code'];
|
72 |
+
}
|
73 |
+
//get shipping options that are selected
|
74 |
+
$selected_shippings = get_option( 'custom_shipping_options' );
|
75 |
+
?>
|
76 |
+
<div class="metabox-holder">
|
77 |
+
<input type='hidden' name='shipping_submits' value='true' />
|
78 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
79 |
+
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
80 |
+
|
81 |
+
<?php
|
82 |
+
|
83 |
+
if ( get_option( 'custom_gateway' ) == 1 ) {
|
84 |
+
$custom_gateway_hide = "style='display:block;'";
|
85 |
+
$custom_gateway1 = 'checked="checked"';
|
86 |
+
} else {
|
87 |
+
$custom_gateway_hide = "style='display:none;'";
|
88 |
+
$custom_gateway2 = 'checked="checked"';
|
89 |
+
}
|
90 |
+
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
91 |
+
wpsc_settings_page_update_notification(); ?>
|
92 |
+
<div class='postbox'>
|
93 |
+
<h3 class='hndle'><?php _e( 'General Settings', 'wpsc' ); ?></h3>
|
94 |
+
<div class='inside'>
|
95 |
+
|
96 |
+
<table class='wpsc_options form-table'>
|
97 |
+
<tr>
|
98 |
+
<th scope="row">
|
99 |
+
<?php _e( 'Use Shipping', 'wpsc' ); ?>:
|
100 |
+
</th>
|
101 |
+
<td>
|
102 |
+
<?php
|
103 |
+
$do_not_use_shipping = get_option( 'do_not_use_shipping' );
|
104 |
+
$do_not_use_shipping1 = "";
|
105 |
+
$do_not_use_shipping2 = "";
|
106 |
+
if( $do_not_use_shipping )
|
107 |
+
$do_not_use_shipping1 = "checked ='checked'";
|
108 |
+
else
|
109 |
+
$do_not_use_shipping2 = "checked ='checked'";
|
110 |
+
?>
|
111 |
+
<input type='radio' value='0' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping2' <?php echo $do_not_use_shipping2; ?> /> <label for='do_not_use_shipping2'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
112 |
+
<input type='radio' value='1' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping1' <?php echo $do_not_use_shipping1; ?> /> <label for='do_not_use_shipping1'><?php _e( 'No', 'wpsc' ); ?></label><br />
|
113 |
+
<?php _e( 'If you are only selling digital downloads, you should select no to disable the shipping on your site.', 'wpsc' ); ?>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
<tr>
|
118 |
+
<th><?php _e( 'Base City:', 'wpsc' ); ?></th>
|
119 |
+
<td>
|
120 |
+
<input type='text' name='wpsc_options[base_city]' value='<?php esc_attr_e( get_option( 'base_city' ) ); ?>' />
|
121 |
+
<br /><?php _e( 'Please provide for more accurate rates', 'wpsc' ); ?>
|
122 |
+
</td>
|
123 |
+
</tr>
|
124 |
+
<tr>
|
125 |
+
<th><?php _e( 'Base Zipcode/Postcode:', 'wpsc' ); ?></th>
|
126 |
+
<td>
|
127 |
+
<input type='text' name='wpsc_options[base_zipcode]' value='<?php esc_attr_e( get_option( 'base_zipcode' ) ); ?>' />
|
128 |
+
<br /><?php _e( '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.', 'wpsc' ); ?>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<?php
|
132 |
+
$shipwire1 = "";
|
133 |
+
$shipwire2 = "";
|
134 |
+
switch ( get_option( 'shipwire' ) ) {
|
135 |
+
case 1:
|
136 |
+
$shipwire1 = "checked ='checked'";
|
137 |
+
$shipwire_settings = 'style=\'display: block;\'';
|
138 |
+
break;
|
139 |
+
|
140 |
+
case 0:
|
141 |
+
default:
|
142 |
+
$shipwire2 = "checked ='checked'";
|
143 |
+
$shipwire_settings = '';
|
144 |
+
break;
|
145 |
+
}
|
146 |
+
?>
|
147 |
+
|
148 |
+
<tr>
|
149 |
+
<th scope="row">
|
150 |
+
<?php _e( 'ShipWire Settings', 'wpsc' ); ?><span style='color: red;'></span> :
|
151 |
+
</th>
|
152 |
+
<td>
|
153 |
+
<input type='radio' onclick='jQuery("#wpsc_shipwire_setting").show()' value='1' name='wpsc_options[shipwire]' id='shipwire1' <?php echo $shipwire1; ?> /> <label for='shipwire1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
154 |
+
<input type='radio' onclick='jQuery("#wpsc_shipwire_setting").hide()' value='0' name='wpsc_options[shipwire]' id='shipwire2' <?php echo $shipwire2; ?> /> <label for='shipwire2'><?php _e( 'No', 'wpsc' ); ?></label>
|
155 |
+
<?php
|
156 |
+
$shipwireemail = esc_attr_e( get_option( "shipwireemail" ) );
|
157 |
+
$shipwirepassword = esc_attr_e( get_option( "shipwirepassword" ) );
|
158 |
+
?>
|
159 |
+
<div id='wpsc_shipwire_setting' <?php echo $shipwire_settings; ?>>
|
160 |
+
<table>
|
161 |
+
<tr><td><?php _e( 'ShipWire Email', 'wpsc' ); ?> :</td><td> <input type="text" name='wpsc_options[shipwireemail]' value="<?php echo $shipwireemail; ?>" /></td></tr>
|
162 |
+
<tr><td><?php _e( 'ShipWire Password', 'wpsc' ); ?> :</td><td><input type="text" name='wpsc_options[shipwirepassword]' value="<?php echo $shipwirepassword; ?>" /></td></tr>
|
163 |
+
<tr><td><a onclick='shipwire_sync()' style="cursor:pointer;">Sync product</a></td></tr>
|
164 |
+
</table>
|
165 |
+
</div>
|
166 |
+
</td>
|
167 |
+
</tr>
|
168 |
+
<tr>
|
169 |
+
<th scope="row">
|
170 |
+
<?php _e( 'Enable Free Shipping Discount', 'wpsc' ); ?>
|
171 |
+
</th>
|
172 |
+
<td>
|
173 |
+
<?php
|
174 |
+
if ( get_option( 'shipping_discount' ) == 1 ) {
|
175 |
+
$selected2 = '';
|
176 |
+
$selected1 = 'checked="checked"';
|
177 |
+
$shipping_discount_settings = 'style=\'display: block;\'';
|
178 |
+
} else {
|
179 |
+
$selected2 = 'checked="checked"';
|
180 |
+
$selected1 = '';
|
181 |
+
$shipping_discount_settings = '';
|
182 |
+
}
|
183 |
+
?>
|
184 |
+
<input type='radio' onclick='jQuery("#shipping_discount_value").show()' value='1' name='wpsc_options[shipping_discount]' id='shipping_discount1' <?php echo $selected1; ?> /> <label for='shipping_discount1'><?php _e( 'Yes', 'wpsc' ); ?></label>
|
185 |
+
<input type='radio' onclick='jQuery("#shipping_discount_value").hide()' value='0' name='wpsc_options[shipping_discount]' id='shipping_discount2' <?php echo $selected2; ?> /> <label for='shipping_discount2'><?php _e( 'No', 'wpsc' ); ?></label>
|
186 |
+
|
187 |
+
</td>
|
188 |
+
</tr>
|
189 |
+
<tr>
|
190 |
+
<td> </td>
|
191 |
+
<td colspan="2">
|
192 |
+
<?php
|
193 |
+
$value = esc_attr ( get_option( 'shipping_discount_value' ) );
|
194 |
+
?>
|
195 |
+
<div <?php echo $shipping_discount_settings; ?> id='shipping_discount_value'>
|
196 |
+
|
197 |
+
<?php printf(__('Sales over or equal to: %1$s<input type="text" size="6" name="wpsc_options[shipping_discount_value]" value="%2$s" id="shipping_discount_value" /> will receive free shipping.', 'wpsc'), $currency_sign, $value ); ?>
|
198 |
+
</div>
|
199 |
+
|
200 |
+
|
201 |
+
</td>
|
202 |
+
|
203 |
+
</tr>
|
204 |
+
</table>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
<table id='wpsc-shipping-module-options' class='wpsc-edit-module-options'>
|
208 |
+
<tr>
|
209 |
+
<td class='select_gateway'>
|
210 |
+
<a name="gateway_options"></a>
|
211 |
+
<div class='postbox'>
|
212 |
+
<h3 class='hndle'><?php _e( 'Shipping Modules', 'wpsc' ) ?></h3>
|
213 |
+
<div class='inside'>
|
214 |
+
|
215 |
+
<p>
|
216 |
+
<?php _e( 'To enable shipping in WP e-Commerce you must select which shipping methods you want to enable on your site.<br /> If you want to use fixed-price shipping options like "Pickup - $0, Overnight - $10, Same day - $20, etc." you can download a WordPress plugin from plugins directory for <a href="http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/">Simple shipping</a>. It will appear in the list as "Fixed rate".', 'wpsc' ); ?>
|
217 |
+
</p>
|
218 |
+
<br />
|
219 |
+
<p>
|
220 |
+
<strong><?php _e( 'Internal Shipping Calculators', 'wpsc' ); ?></strong>
|
221 |
+
</p>
|
222 |
+
<?php
|
223 |
+
foreach ( $internal_shipping_modules as $shipping ) {
|
224 |
+
|
225 |
+
$shipping->checked = '';
|
226 |
+
if ( is_object( $shipping ) && in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
|
227 |
+
$shipping->checked = ' checked = "checked" ';
|
228 |
+
?>
|
229 |
+
|
230 |
+
<div class='wpsc_shipping_options'>
|
231 |
+
<div class='wpsc-shipping-actions'>
|
232 |
+
<span class="edit">
|
233 |
+
<a class='edit-shipping-module' data-module-id="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo esc_attr( $this->get_shipping_module_url( $shipping ) ); ?>' style="cursor:pointer;"><?php _e( 'Edit', 'wpsc' ); ?></a>
|
234 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
235 |
+
</span>
|
236 |
+
</div>
|
237 |
+
|
238 |
+
<p><input name='custom_shipping_options[]' <?php echo $shipping->checked; ?> 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>
|
239 |
+
</div>
|
240 |
+
<?php } ?>
|
241 |
+
<br />
|
242 |
+
<p>
|
243 |
+
<strong><?php _e( 'External Shipping Calculators', 'wpsc' ); ?></strong>
|
244 |
+
<?php if ( !function_exists( 'curl_init' ) ) {
|
245 |
+
?>
|
246 |
+
<br /><span style='color: red; font-size:8pt; line-height:10pt;'><?php _e( '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. ', 'wpsc' ); ?></span>
|
247 |
+
<?php } ?>
|
248 |
+
</p>
|
249 |
+
<?php
|
250 |
+
// print the internal shipping methods
|
251 |
+
foreach ( $external_shipping_modules as $shipping ) {
|
252 |
+
$disabled = '';
|
253 |
+
if ( isset($shipping->requires_curl) && ($shipping->requires_curl == true) && !function_exists( 'curl_init' ) ) {
|
254 |
+
$disabled = "disabled='disabled'";
|
255 |
+
}
|
256 |
+
$shipping->checked = '';
|
257 |
+
if ( in_array( $shipping->getInternalName(), (array)$selected_shippings ) )
|
258 |
+
$shipping->checked = " checked='checked' ";
|
259 |
+
?>
|
260 |
+
<div class='wpsc_shipping_options'>
|
261 |
+
<div class="wpsc-shipping-actions">
|
262 |
+
<span class="edit">
|
263 |
+
<a class='edit-shipping-module' data-module-id="<?php echo $shipping->internal_name; ?>" title="Edit this Shipping Module" href='<?php echo esc_attr( $this->get_shipping_module_url( $shipping ) ); ?>' style="cursor:pointer;"><?php _e( 'Edit' , 'wpsc' ); ?></a>
|
264 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
265 |
+
</span>
|
266 |
+
</div>
|
267 |
+
<p><input <?php echo $disabled; ?> name='custom_shipping_options[]' <?php echo $shipping->checked; ?> type='checkbox' value='<?php echo $shipping->internal_name; ?>' id='<?php echo $shipping->internal_name; ?>_id' /><label for='<?php echo $shipping->internal_name; ?>_id'><?php esc_attr_e( $shipping->name ); ?></label></p>
|
268 |
+
</div>
|
269 |
+
<?php } ?>
|
270 |
+
<p class="submit">
|
271 |
+
<input type='hidden' value='true' name='update_gateways' />
|
272 |
+
<input type="submit" value="<?php _e( 'Update »', 'wpsc' ); ?>" />
|
273 |
+
</p>
|
274 |
+
</div>
|
275 |
+
</div>
|
276 |
+
</td>
|
277 |
+
|
278 |
+
<?php $this->display_shipping_module_settings_form(); ?>
|
279 |
+
</tr>
|
280 |
+
</table>
|
281 |
+
</div>
|
282 |
+
<?php
|
283 |
+
}
|
284 |
+
}
|
wpsc-admin/includes/settings-tabs/taxes.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Taxes extends WPSC_Settings_Tab
|
4 |
+
{
|
5 |
+
public function __construct() {
|
6 |
+
}
|
7 |
+
|
8 |
+
public function callback_submit_options() {
|
9 |
+
$taxes_enabled = ( isset( $_POST['wpsc_options']['wpec_taxes_enabled'] ) ) ? 1 : 0;
|
10 |
+
update_option( 'wpec_taxes_enabled', $taxes_enabled );
|
11 |
+
|
12 |
+
//currently there are two types - bands and rates
|
13 |
+
$taxes_rates_types = array( 'rates', 'bands' );
|
14 |
+
|
15 |
+
foreach ( $taxes_rates_types as $taxes_type ) {
|
16 |
+
$saved_rates = array( ); //keep track of saved rates
|
17 |
+
$exists = array( ); //keep track of what rates or names have been saved
|
18 |
+
//check the rates
|
19 |
+
if ( isset( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] ) ) {
|
20 |
+
foreach ( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] as $tax_rate ) {
|
21 |
+
if( !isset( $tax_rate['region_code'] ) )
|
22 |
+
$tax_rate['region_code'] = '';
|
23 |
+
|
24 |
+
//if there is no country then skip
|
25 |
+
if ( empty( $tax_rate['country_code'] ) ) {
|
26 |
+
continue;
|
27 |
+
}
|
28 |
+
|
29 |
+
//bands - if the name already exists then skip - if not save it
|
30 |
+
if ( $taxes_type == 'bands' ) {
|
31 |
+
if ( empty( $tax_rate['name'] ) || in_array( $tax_rate['name'], $exists ) || $tax_rate['name'] == 'Disabled' ) {
|
32 |
+
continue;
|
33 |
+
} else {
|
34 |
+
$exists[] = $tax_rate['name'];
|
35 |
+
$saved_rates[] = $tax_rate;
|
36 |
+
}// if
|
37 |
+
}// if
|
38 |
+
//rates - check the shipping checkbox
|
39 |
+
if ( $taxes_type == 'rates' ) {
|
40 |
+
//if there is no rate then skip
|
41 |
+
if ( empty( $tax_rate['rate'] ) ) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
|
45 |
+
$tax_rate['shipping'] = (isset( $tax_rate['shipping'] )) ? 1 : 0;
|
46 |
+
|
47 |
+
//check if country exists
|
48 |
+
if ( array_key_exists( $tax_rate['country_code'], $exists ) ) {
|
49 |
+
//if region already exists skip
|
50 |
+
if ( array_search( $tax_rate['region_code'], $exists[$tax_rate['country_code']] ) == $tax_rate['country_code'] ) {
|
51 |
+
continue;
|
52 |
+
} else {
|
53 |
+
//it's not in the array add it
|
54 |
+
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
55 |
+
|
56 |
+
//save it
|
57 |
+
$saved_rates[] = $tax_rate;
|
58 |
+
}// if
|
59 |
+
} else {
|
60 |
+
//add codes to exists array
|
61 |
+
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
62 |
+
|
63 |
+
//save it
|
64 |
+
$saved_rates[] = $tax_rate;
|
65 |
+
}// if
|
66 |
+
}// if
|
67 |
+
}// foreach
|
68 |
+
}// if
|
69 |
+
//replace post tax rates with filtered rates
|
70 |
+
update_option( 'wpec_taxes_' . $taxes_type, $saved_rates );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
public function display() {
|
75 |
+
$wpec_taxes_controller = new wpec_taxes_controller;
|
76 |
+
$wpec_taxes_options = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_options();
|
77 |
+
|
78 |
+
?>
|
79 |
+
<h3><?php _e( 'Tax Settings', 'wpsc' ); ?></h3>
|
80 |
+
<p>
|
81 |
+
<label for='wpec_taxes_enabled'>
|
82 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_enabled'] ) {
|
83 |
+
echo 'checked="checked"';
|
84 |
+
} ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
|
85 |
+
<?php _e( 'Turn tax on', 'wpsc' ); ?>
|
86 |
+
</label>
|
87 |
+
</p>
|
88 |
+
<p>
|
89 |
+
<label for='wpec_taxes_inprice1'>
|
90 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'exclusive' ) {
|
91 |
+
echo 'checked="checked"';
|
92 |
+
} ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
|
93 |
+
<?php _e( 'Product prices are tax exclusive - add tax to the price during checkout', 'wpsc' ); ?>
|
94 |
+
</label>
|
95 |
+
</p>
|
96 |
+
<p>
|
97 |
+
<label for='wpec_taxes_inprice2'>
|
98 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'inclusive' ) {
|
99 |
+
echo 'checked="checked"';
|
100 |
+
} ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
|
101 |
+
<?php _e( "Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item", 'wpsc' ); ?>
|
102 |
+
</label>
|
103 |
+
</p>
|
104 |
+
<h4><?php _e( 'Product Specific Tax', 'wpsc' ); ?></h4>
|
105 |
+
<p>
|
106 |
+
<label for='wpec_taxes_product_1'>
|
107 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'add' ) {
|
108 |
+
echo 'checked="checked"';
|
109 |
+
} ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
|
110 |
+
<?php _e( 'Add per product tax to tax percentage if product has a specific tax rate', 'wpsc' ); ?>
|
111 |
+
</label>
|
112 |
+
</p>
|
113 |
+
<p>
|
114 |
+
<label for='wpec_taxes_product_2'>
|
115 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'replace' ) {
|
116 |
+
echo 'checked="checked"';
|
117 |
+
} ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
|
118 |
+
<?php _e( 'Replace tax percentage with product specific tax rate', 'wpsc' ); ?>
|
119 |
+
</label>
|
120 |
+
</p>
|
121 |
+
|
122 |
+
<h4><?php _e( 'Tax Logic', 'wpsc' ); ?></h4>
|
123 |
+
<p>
|
124 |
+
<label for='wpec_taxes_logic_1'>
|
125 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) {
|
126 |
+
echo 'checked="checked"';
|
127 |
+
} ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
|
128 |
+
<?php _e( 'Apply tax when Billing and Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
|
129 |
+
</label>
|
130 |
+
<div id='billing_shipping_preference_container' style='margin-left: 20px;'>
|
131 |
+
<p>
|
132 |
+
<label for='wpec_billing_preference'>
|
133 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'billing_address' ) {
|
134 |
+
echo 'checked="checked"';
|
135 |
+
} ?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
136 |
+
<?php _e( 'Apply tax to Billing Address', 'wpsc' ); ?>
|
137 |
+
</label>
|
138 |
+
</p>
|
139 |
+
<p>
|
140 |
+
<label for='wpec_shipping_preference'>
|
141 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'shipping_address' ) {
|
142 |
+
echo 'checked="checked"';
|
143 |
+
} ?> type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
144 |
+
<?php _e( 'Apply tax to Shipping Address', 'wpsc' ); ?>
|
145 |
+
</label>
|
146 |
+
</p>
|
147 |
+
</div>
|
148 |
+
</p>
|
149 |
+
<p>
|
150 |
+
<label for='wpec_taxes_logic_2'>
|
151 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) {
|
152 |
+
echo 'checked="checked"';
|
153 |
+
} ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
|
154 |
+
<?php _e( 'Apply tax when Billing Country is the same as Tax Rate', 'wpsc' ); ?>
|
155 |
+
</label>
|
156 |
+
</p>
|
157 |
+
<p>
|
158 |
+
<label for='wpec_taxes_logic_3'>
|
159 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) {
|
160 |
+
echo 'checked="checked"';
|
161 |
+
} ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
|
162 |
+
<?php _e( 'Apply tax when Shipping Country is the same as Tax Rate', 'wpsc' ); ?>
|
163 |
+
</label>
|
164 |
+
</p>
|
165 |
+
<div id='metabox-holder' class="metabox-holder">
|
166 |
+
<div id='wpec-taxes-rates-container' class='postbox'>
|
167 |
+
<h3 class='hndle' style='cursor: default'><?php _e( 'Tax Rates', 'wpsc' ); ?></h3>
|
168 |
+
<div id='wpec-taxes-rates' class='inside'>
|
169 |
+
<!--Start Taxes Output-->
|
170 |
+
<?php
|
171 |
+
/**
|
172 |
+
* Add New Tax Rate - should add another paragraph with the
|
173 |
+
another key specified for the input array
|
174 |
+
* Delete - Should remove the given paragraph from the page
|
175 |
+
and either ajax delete it from the DB or mark it for
|
176 |
+
deletion and process it after the changes are made.
|
177 |
+
* Selecting a Country - should automatically populate the
|
178 |
+
regions select box. Selecting a different country should
|
179 |
+
remove the region select box. If the user selects a
|
180 |
+
different country with regions it shouldn't matter because
|
181 |
+
the code should automatically add the region select in.
|
182 |
+
* - Allow users to define tax for entire country even if regions exist.
|
183 |
+
* Shipping Tax - needs to be per region or per tax rate.
|
184 |
+
Remove the setting from the main Tax Settings area.
|
185 |
+
* Constraints -
|
186 |
+
1. Should not allow a user to add more than one
|
187 |
+
tax rate for the same area.
|
188 |
+
2. If a country tax rate is specified and then a region tax
|
189 |
+
rate, the region tax rate takes precedence.
|
190 |
+
* */
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Removed Shipping Restriction on Included tax - 01-20-2011
|
194 |
+
//if tax is included warn about shipping
|
195 |
+
if ( $wpec_taxes_controller->wpec_taxes_isincluded() ) {
|
196 |
+
echo '<p>' . __( 'Note: Tax is not applied to shipping when product prices are tax inclusive.' ) . '</p>';
|
197 |
+
}// if
|
198 |
+
**/
|
199 |
+
|
200 |
+
//get current tax rates
|
201 |
+
// TODO: Refactor to get rid of the need for wpec_taxes_build_form(). It's a horribly written function.
|
202 |
+
$tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
|
203 |
+
$tax_rate_count = 0;
|
204 |
+
if ( !empty( $tax_rates ) ) {
|
205 |
+
foreach ( $tax_rates as $tax_rate ) {
|
206 |
+
echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_rate_count, $tax_rate );
|
207 |
+
$tax_rate_count++;
|
208 |
+
}// foreach
|
209 |
+
}// if
|
210 |
+
?>
|
211 |
+
<!--End Taxes Output-->
|
212 |
+
<p id="wpsc-add-tax-rates">
|
213 |
+
<a href="#"><?php _e( 'Add New Tax Rate', 'wpsc' ); ?></a>
|
214 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
215 |
+
</p>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
<div id='wpec-taxes-bands-container' class='postbox'>
|
219 |
+
<h3 class='hndle' style='cursor: default'><?php _e( 'Tax Bands', 'wpsc' ); ?></h3>
|
220 |
+
<div id='wpec-taxes-bands' class='inside'>
|
221 |
+
|
222 |
+
<?php
|
223 |
+
echo '<p>' . __( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. <br /> Please visit the product page to apply your Tax Band.', 'wpsc' ) . '</p>';
|
224 |
+
|
225 |
+
//echo message regarding inclusive tax
|
226 |
+
if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
|
227 |
+
echo '<p>' . __( 'Note: Tax Bands do not take affect when product prices are tax exclusive.', 'wpsc' ) . '</p>';
|
228 |
+
}// if
|
229 |
+
|
230 |
+
$tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
|
231 |
+
$tax_band_count = 0;
|
232 |
+
if ( !empty( $tax_bands ) ) {
|
233 |
+
foreach ( $tax_bands as $tax_band ) {
|
234 |
+
echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_band_count, $tax_band, 'bands' );
|
235 |
+
$tax_band_count++;
|
236 |
+
}// foreach
|
237 |
+
}// if
|
238 |
+
?>
|
239 |
+
<p id="wpsc-add-tax-bands">
|
240 |
+
<a href="#"><?php _e( 'Add New Tax Band', 'wpsc' ); ?></a>
|
241 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
242 |
+
</p>
|
243 |
+
</div>
|
244 |
+
</div><!--wpec-taxes-bands-container-->
|
245 |
+
</div><!--metabox-holder-->
|
246 |
+
<?php
|
247 |
+
}
|
248 |
+
}
|
wpsc-admin/includes/tax_and_shipping.php
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
<?php
|
2 |
global $wpdb;
|
3 |
$changes_made = false;
|
4 |
-
|
5 |
-
if(preg_match("/[a-zA-Z]{2,4}/",$_GET['isocode']))
|
6 |
-
{
|
7 |
-
$country_isocode = $_GET['isocode'];
|
8 |
-
}
|
9 |
-
else
|
10 |
-
{
|
11 |
-
$country_isocode = get_option('base_country');
|
12 |
-
}
|
13 |
$base_region = get_option('base_region');
|
14 |
?>
|
15 |
<div class="wrap">
|
@@ -22,7 +14,7 @@ $base_region = get_option('base_region');
|
|
22 |
?>
|
23 |
<form action='' method='post' name='regional_tax' class='wpsc_form_track'>
|
24 |
<?php
|
25 |
-
$country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(
|
26 |
if(($country_data['has_regions'] == 1))
|
27 |
{
|
28 |
$region_data = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN('".$country_data['id']."') ",ARRAY_A) ;
|
1 |
<?php
|
2 |
global $wpdb;
|
3 |
$changes_made = false;
|
4 |
+
$country_isocode = preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ? $_GET['isocode'] : get_option( 'base_country' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
$base_region = get_option('base_region');
|
6 |
?>
|
7 |
<div class="wrap">
|
14 |
?>
|
15 |
<form action='' method='post' name='regional_tax' class='wpsc_form_track'>
|
16 |
<?php
|
17 |
+
$country_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(%s) LIMIT 1", $country_isocode ), ARRAY_A );
|
18 |
if(($country_data['has_regions'] == 1))
|
19 |
{
|
20 |
$region_data = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN('".$country_data['id']."') ",ARRAY_A) ;
|
wpsc-admin/includes/updating-functions.php
CHANGED
@@ -122,7 +122,7 @@ class WPSC_Update_Progress
|
|
122 |
if ( $this->eta == 0 )
|
123 |
echo __( 'Under a minute', 'wpsc' );
|
124 |
else
|
125 |
-
printf( _n( '%d minute', '%d minutes', $this->eta ), $this->eta );
|
126 |
echo '</div>';
|
127 |
}
|
128 |
|
@@ -186,7 +186,7 @@ function wpsc_update_step( $i, $total ) {
|
|
186 |
if ( $eta == 0 )
|
187 |
echo __( 'Under a minute', 'wpsc' );
|
188 |
else
|
189 |
-
printf( _n( '%d minute', '%d minutes', $eta ), $eta );
|
190 |
echo '</div>';
|
191 |
$milestone = $now;
|
192 |
}
|
@@ -257,9 +257,9 @@ function wpsc_convert_categories($new_parent_category, $group_id, $old_parent_ca
|
|
257 |
global $wpdb, $user_ID;
|
258 |
|
259 |
if($old_parent_category > 0) {
|
260 |
-
$categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN (
|
261 |
} else {
|
262 |
-
$categorisation = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN (
|
263 |
}
|
264 |
$wpsc_update = WPSC_Update::get_instance();
|
265 |
|
@@ -865,13 +865,13 @@ function old_get_product_meta($product_id, $key, $single = false) {
|
|
865 |
$product_id = (int)$product_id;
|
866 |
$meta_values = false;
|
867 |
if($product_id > 0) {
|
868 |
-
$meta_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN(
|
869 |
//exit($meta_id);
|
870 |
if(is_numeric($meta_id) && ($meta_id > 0)) {
|
871 |
if($single != false) {
|
872 |
$meta_values = maybe_unserialize($wpdb->get_var("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN('$key') AND `product_id` = '$product_id' LIMIT 1"));
|
873 |
} else {
|
874 |
-
$meta_values = $wpdb->get_col("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN(
|
875 |
$meta_values = array_map('maybe_unserialize', $meta_values);
|
876 |
}
|
877 |
}
|
122 |
if ( $this->eta == 0 )
|
123 |
echo __( 'Under a minute', 'wpsc' );
|
124 |
else
|
125 |
+
printf( _n( '%d minute', '%d minutes', $this->eta, 'wpsc' ), $this->eta );
|
126 |
echo '</div>';
|
127 |
}
|
128 |
|
186 |
if ( $eta == 0 )
|
187 |
echo __( 'Under a minute', 'wpsc' );
|
188 |
else
|
189 |
+
printf( _n( '%d minute', '%d minutes', $eta, 'wpsc' ), $eta );
|
190 |
echo '</div>';
|
191 |
$milestone = $now;
|
192 |
}
|
257 |
global $wpdb, $user_ID;
|
258 |
|
259 |
if($old_parent_category > 0) {
|
260 |
+
$categorisation = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN (%d) AND `category_parent` IN (%d)", $group_id, $old_parent_category ) );
|
261 |
} else {
|
262 |
+
$categorisation = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active` IN ('1') AND `group_id` IN (%d) AND `category_parent` IN (0)", $group_id ) );
|
263 |
}
|
264 |
$wpsc_update = WPSC_Update::get_instance();
|
265 |
|
865 |
$product_id = (int)$product_id;
|
866 |
$meta_values = false;
|
867 |
if($product_id > 0) {
|
868 |
+
$meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN(%s) AND `product_id` = %d LIMIT 1", $key, $product_id ) );
|
869 |
//exit($meta_id);
|
870 |
if(is_numeric($meta_id) && ($meta_id > 0)) {
|
871 |
if($single != false) {
|
872 |
$meta_values = maybe_unserialize($wpdb->get_var("SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN('$key') AND `product_id` = '$product_id' LIMIT 1"));
|
873 |
} else {
|
874 |
+
$meta_values = $wpdb->get_col( $wpdb->prepare( "SELECT `meta_value` FROM `".WPSC_TABLE_PRODUCTMETA."` WHERE `meta_key` IN(%s) AND `product_id` = %d", $key, $product_id ) );
|
875 |
$meta_values = array_map('maybe_unserialize', $meta_values);
|
876 |
}
|
877 |
}
|
wpsc-admin/includes/walker-variation-checklist.php
CHANGED
@@ -3,45 +3,49 @@
|
|
3 |
* Walker Variation Checklist
|
4 |
* Outputs checkboxes for variation sets
|
5 |
*/
|
6 |
-
class WPSC_Walker_Variation_Checklist extends Walker_Category_Checklist {
|
7 |
-
private $
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
function start_lvl( &$output, $depth, $args ) {
|
12 |
}
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
' . esc_html( apply_filters( 'the_category', $category->name ) ) . '
|
30 |
-
</label>';
|
31 |
-
} else {
|
32 |
-
// Start variation
|
33 |
-
$output .= '<div class="variation"' . ( $this->is_displayed ? '' : ' style="display:none;"' ) . '>
|
34 |
-
<label>
|
35 |
-
<input type="checkbox"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . 'name="edit_var_val[' . $category->parent . '][' . $category->term_id . ']" value="1">
|
36 |
-
' . esc_html( apply_filters( 'the_category', $category->name ) ) . '
|
37 |
-
</label>';
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
}
|
3 |
* Walker Variation Checklist
|
4 |
* Outputs checkboxes for variation sets
|
5 |
*/
|
6 |
+
class WPSC_Walker_Variation_Checklist extends Walker_Category_Checklist {
|
7 |
+
private $highlighted = array();
|
8 |
+
|
9 |
+
public function __construct( $highlighted = array() ) {
|
10 |
+
$this->highlighted = $highlighted;
|
|
|
11 |
}
|
12 |
+
|
13 |
+
public function start_el(&$output, $category, $depth, $args) {
|
14 |
+
extract($args);
|
15 |
+
if ( empty($taxonomy) )
|
16 |
+
$taxonomy = 'category';
|
17 |
+
|
18 |
+
$checked = in_array( $category->term_id, $selected_cats );
|
19 |
+
$input_class = ( $depth === 0 ) ? ' class="variation-set"' : '';
|
20 |
+
$li_classes = array( 'wpsc-variation-checklist-item' );
|
21 |
+
if ( $depth === 0 && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
22 |
+
$li_classes[] = 'expanded';
|
23 |
+
$li_classes[] = 'ajax';
|
24 |
+
} elseif ( $checked && $depth === 0 ) {
|
25 |
+
$li_classes[] = 'expanded';
|
26 |
+
} elseif ( in_array( $category->term_id, $this->highlighted ) ) {
|
27 |
+
$li_classes[] = 'ajax';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
+
ob_start();
|
30 |
+
?>
|
31 |
+
<li id="<?php echo esc_attr( $taxonomy ); ?>-<?php echo $category->term_id; ?>" class="<?php echo implode( ' ', $li_classes ); ?>">
|
32 |
+
<?php if ( $depth == 0 ): ?>
|
33 |
+
<a href="#" class="expand"><?php echo esc_html( _x( 'Expand', 'product variation set', 'wpsc' ) ); ?></a>
|
34 |
+
<?php endif ?>
|
35 |
+
|
36 |
+
<label class="selectit">
|
37 |
+
<input
|
38 |
+
<?php echo $input_class; ?>
|
39 |
+
type="checkbox" value="1"
|
40 |
+
<?php if ( $depth !== 0 ): ?>
|
41 |
+
name="edit_var_val[<?php echo $category->parent; ?>][<?php echo $category->term_id ?>]"
|
42 |
+
<?php endif ?>
|
43 |
+
id="in-<?php echo esc_attr( $taxonomy ) . '-' . $category->term_id; ?>"
|
44 |
+
<?php checked( $checked, true ); disabled( empty( $args['disabled'] ), false ); ?>
|
45 |
+
/>
|
46 |
+
<?php echo esc_html( $category->name ); ?>
|
47 |
+
</label>
|
48 |
+
<?php
|
49 |
+
$output .= ob_get_clean();
|
50 |
}
|
51 |
}
|
wpsc-admin/js/admin.js
CHANGED
@@ -1,28 +1,39 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
4 |
jQuery('td.hidden_alerts img').each(function(){
|
5 |
var t = jQuery(this);
|
6 |
t.appendTo(t.parents('tr').find('td.column-title strong'));
|
7 |
});
|
8 |
|
9 |
-
jQuery('a.update_variations_action').click(function(){
|
10 |
-
jQuery("<img class='loading' src='images/loading.gif' height='15' width='15' />").insertAfter(this);
|
11 |
-
var edit_var_val = jQuery('div.variation_checkboxes input:checked').serialize();
|
12 |
-
var description = jQuery('#content_ifr').contents().find('body').html();
|
13 |
-
var additional_description = jQuery('textarea#additional_description').text();
|
14 |
-
var name = jQuery('input#title').val();
|
15 |
-
var product_id = jQuery('input#product_id').val();
|
16 |
-
var post_values = edit_var_val + '&description=' + description + '&additional_description=' + additional_description + '&name=' + name + '&product_id=' + product_id;
|
17 |
-
jQuery('div#wpsc_product_variation_forms table.widefat tbody').fadeTo(200, 0, function(){
|
18 |
-
jQuery.post(ajaxurl + '?action=wpsc_update_variations',post_values, function(returned_data){
|
19 |
-
jQuery('div#wpsc_product_variation_forms table.widefat tbody').html(returned_data).fadeTo(200, 1);
|
20 |
-
jQuery('img.loading').hide();
|
21 |
-
});
|
22 |
-
});
|
23 |
-
return false;
|
24 |
-
|
25 |
-
});
|
26 |
/* Coupon edit functionality */
|
27 |
jQuery('.modify_coupon').hide();
|
28 |
jQuery('.wpsc_edit_coupon').click(function(){
|
@@ -88,98 +99,6 @@ jQuery(document).ready(function(){
|
|
88 |
|
89 |
});
|
90 |
|
91 |
-
jQuery('.wpsc_prod_thumb_option').livequery(function(){
|
92 |
-
jQuery(this).focus(function(){
|
93 |
-
jQuery('.wpsc_mass_resize').css('visibility', 'visible');
|
94 |
-
});
|
95 |
-
});
|
96 |
-
|
97 |
-
jQuery('.wpsc_prod_thumb_option').livequery(function(){
|
98 |
-
jQuery(this).blur(function(){
|
99 |
-
jQuery('.wpsc_mass_resize').css('visibility', 'hidden');
|
100 |
-
});
|
101 |
-
});
|
102 |
-
|
103 |
-
|
104 |
-
//Delete checkout options on settings>checkout page
|
105 |
-
jQuery('.wpsc_delete_option').livequery(function(){
|
106 |
-
jQuery(this).click(function(event){
|
107 |
-
jQuery(this).parent().parent('tr').remove();
|
108 |
-
event.preventDefault();
|
109 |
-
});
|
110 |
-
|
111 |
-
});
|
112 |
-
//Changing the checkout fields page
|
113 |
-
jQuery('#wpsc_checkout_sets').livequery(function(){
|
114 |
-
jQuery(this).change(function(){
|
115 |
-
|
116 |
-
});
|
117 |
-
|
118 |
-
});
|
119 |
-
//checkboxes on checkout page
|
120 |
-
|
121 |
-
jQuery('.wpsc_add_new_checkout_option').livequery(function(){
|
122 |
-
jQuery(this).click(function(event){
|
123 |
-
form_id = jQuery(this).attr('title');
|
124 |
-
id = form_id.replace('form_options', '');
|
125 |
-
output = "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label"+id+"[]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value"+id+"[]' /> <a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td></tr>";
|
126 |
-
jQuery(this).parent().parent('tr').after(output);
|
127 |
-
event.preventDefault();
|
128 |
-
});
|
129 |
-
|
130 |
-
});
|
131 |
-
|
132 |
-
|
133 |
-
jQuery('.wpsc_edit_checkout_options').livequery(function(){
|
134 |
-
jQuery(this).click(function(event){
|
135 |
-
if(!jQuery(this).hasClass('triggered')){
|
136 |
-
jQuery(this).addClass('triggered');
|
137 |
-
id = jQuery(this).attr('rel');
|
138 |
-
id = id.replace('form_options[', '');
|
139 |
-
id = id.replace(']', '');
|
140 |
-
post_values = "form_id="+id;
|
141 |
-
jQuery.post('index.php?wpsc_admin_action=check_form_options',post_values, function(returned_data){
|
142 |
-
if(returned_data != ''){
|
143 |
-
jQuery('#checkout_'+id).after(returned_data);
|
144 |
-
}else{
|
145 |
-
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 Option</a></td></tr>";
|
146 |
-
output += "<tr class='wpsc_grey'><td></td><td><input type='text' value='' name='wpsc_checkout_option_label["+id+"][]' /></td><td colspan='4'><input type='text' value='' name='wpsc_checkout_option_value["+id+"][]' /><a class='wpsc_delete_option' href='' ><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='Delete' title='delete' /></a></td></tr>";
|
147 |
-
jQuery('#checkout_'+id).after(output);
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
});
|
152 |
-
jQuery('table#wpsc_checkout_list').sortable('disable');
|
153 |
-
}
|
154 |
-
event.preventDefault();
|
155 |
-
});
|
156 |
-
|
157 |
-
|
158 |
-
});
|
159 |
-
|
160 |
-
//grid view checkbox ajax to deselect show images only when other checkboxes are selected
|
161 |
-
jQuery('#show_images_only').livequery(function(){
|
162 |
-
jQuery(this).click(function(){
|
163 |
-
imagesonly = jQuery(this).is(':checked');
|
164 |
-
if(imagesonly){
|
165 |
-
jQuery('#display_variations').attr('checked', false);
|
166 |
-
jQuery('#display_description').attr('checked', false);
|
167 |
-
jQuery('#display_addtocart').attr('checked', false);
|
168 |
-
jQuery('#display_moredetails').attr('checked', false);
|
169 |
-
|
170 |
-
}
|
171 |
-
});
|
172 |
-
});
|
173 |
-
jQuery('#display_variations, #display_description, #display_addtocart, #display_moredetails').livequery(function(){
|
174 |
-
jQuery(this).click(function(){
|
175 |
-
imagesonly = jQuery(this).is(':checked');
|
176 |
-
|
177 |
-
if(imagesonly){
|
178 |
-
jQuery('#show_images_only').attr('checked', false);
|
179 |
-
|
180 |
-
}
|
181 |
-
});
|
182 |
-
});
|
183 |
//new currency JS in admin product page
|
184 |
jQuery('div.new_layer').livequery(function(){
|
185 |
jQuery(this).hide();
|
@@ -238,74 +157,6 @@ jQuery(document).ready(function(){
|
|
238 |
});
|
239 |
});
|
240 |
|
241 |
-
//select all target markets in general settings page
|
242 |
-
jQuery('a.wpsc_select_all').livequery(function(){
|
243 |
-
jQuery(this).click(function(event){
|
244 |
-
jQuery('div#resizeable input:checkbox').attr('checked', true);
|
245 |
-
event.preventDefault();
|
246 |
-
|
247 |
-
});
|
248 |
-
|
249 |
-
});
|
250 |
-
//select all target markets in general settings page
|
251 |
-
jQuery('a.wpsc_select_none').livequery(function(){
|
252 |
-
jQuery(this).click(function(event){
|
253 |
-
jQuery('div#resizeable input:checkbox').attr('checked', false);
|
254 |
-
event.preventDefault();
|
255 |
-
|
256 |
-
});
|
257 |
-
|
258 |
-
});
|
259 |
-
if( pagenow == 'edit-wpsc_product_category' ) {
|
260 |
-
jQuery('table.tags').sortable({
|
261 |
-
axis: 'y',
|
262 |
-
items : 'tr',
|
263 |
-
containment: 'table.tags tbody',
|
264 |
-
placeholder: 'product-placeholder',
|
265 |
-
cursor: 'move',
|
266 |
-
tolerance: 'pointer',
|
267 |
-
update: function(event, ui){
|
268 |
-
categorySort(jQuery('table.tags').sortable('toArray'), 0);
|
269 |
-
}
|
270 |
-
});
|
271 |
-
|
272 |
-
function categorySort(order, parent){
|
273 |
-
var data = {
|
274 |
-
action: 'category_sort_order',
|
275 |
-
sort_order: order,
|
276 |
-
parent_id: parent
|
277 |
-
};
|
278 |
-
|
279 |
-
var id = '#debugData_';
|
280 |
-
|
281 |
-
jQuery.post(ajaxurl, data, function(response) {
|
282 |
-
jQuery(id).append(response);
|
283 |
-
});
|
284 |
-
return false;
|
285 |
-
}
|
286 |
-
|
287 |
-
jQuery('.edit-tags-php form').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data');
|
288 |
-
|
289 |
-
}
|
290 |
-
//Added for inline editing capabilities
|
291 |
-
jQuery('#wpsc_product_list a.wpsc_editinline').live('click', function() {
|
292 |
-
var t = jQuery(this),
|
293 |
-
tr = t.parents('tr');
|
294 |
-
tr.find('td input[type="text"].wpsc_ie_field').each(function(){
|
295 |
-
var ti = jQuery(this), p = ti.parents('td');
|
296 |
-
if (! p.hasClass('column-stock') || p.css('display') != 'none') {
|
297 |
-
ti.innerWidth(p.width());
|
298 |
-
}
|
299 |
-
}).show();
|
300 |
-
tr.find('td .wpsc_inline_actions').show().end().find('a.row-title, td > span').hide();
|
301 |
-
return false;
|
302 |
-
});
|
303 |
-
|
304 |
-
jQuery('#wpsc_product_list .wpsc_ie_cancel').live('click', function(){
|
305 |
-
jQuery(this).parents('tr:first').find('a.row-title, td > span').show();
|
306 |
-
jQuery(this).parents('tr:first').find('td input.wpsc_ie_field, td .wpsc_inline_actions').hide();
|
307 |
-
jQuery(this).parents('tr:first').find('.loading_indicator').css('visibility', 'hidden');
|
308 |
-
});
|
309 |
jQuery('#wpsc_product_list .wpsc_ie_save').live('click', function(){
|
310 |
jQuery(this).parents('tr:first').find('.loading_indicator').css('visibility', 'visible');
|
311 |
var id =jQuery(this).parents('tr:first').find('.wpsc_ie_id').val();
|
@@ -332,7 +183,7 @@ jQuery(document).ready(function(){
|
|
332 |
if(response.error){
|
333 |
alert(response.error);
|
334 |
jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').show();
|
335 |
-
jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').
|
336 |
jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
|
337 |
}
|
338 |
else{
|
@@ -344,8 +195,8 @@ jQuery(document).ready(function(){
|
|
344 |
jQuery('#post-' + response.id + ' .column-price .pricedisplay').html(jQuery(response.price).text());
|
345 |
jQuery('#post-' + response.id + ' .column-sale_price .pricedisplay').html(jQuery(response.special_price).text());
|
346 |
|
347 |
-
jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').
|
348 |
-
jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').
|
349 |
jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
|
350 |
}
|
351 |
});
|
@@ -382,27 +233,6 @@ jQuery(document).ready(function(){
|
|
382 |
});
|
383 |
}
|
384 |
|
385 |
-
jQuery('table#wpsc_checkout_list').livequery(function(event){
|
386 |
-
//this makes the checkout form fields sortable
|
387 |
-
jQuery(this).sortable({
|
388 |
-
|
389 |
-
items: 'tr.checkout_form_field',
|
390 |
-
axis: 'y',
|
391 |
-
containment: 'table#wpsc_checkout_list',
|
392 |
-
placeholder: 'checkout-placeholder',
|
393 |
-
handle: '.drag'
|
394 |
-
|
395 |
-
});
|
396 |
-
jQuery(this).bind('sortupdate', function(event, ui) {
|
397 |
-
|
398 |
-
//post_values = jQuery(this).sortable();
|
399 |
-
//post_values = "category_id="+category_id+"&"+checkout_order;
|
400 |
-
post_values = jQuery( 'table#wpsc_checkout_list').sortable( 'serialize');
|
401 |
-
jQuery.post( 'index.php?wpsc_admin_action=save_checkout_order', post_values, function(returned_data) { });
|
402 |
-
});
|
403 |
-
|
404 |
-
});
|
405 |
-
|
406 |
// this helps show the links in the product list table, it is partially done using CSS, but that breaks in IE6
|
407 |
jQuery("tr.product-edit").hover(
|
408 |
function() {
|
@@ -413,44 +243,6 @@ jQuery(document).ready(function(){
|
|
413 |
}
|
414 |
);
|
415 |
|
416 |
-
jQuery('tr.wpsc_trackingid_row').hide();
|
417 |
-
|
418 |
-
jQuery('.wpsc_show_trackingid').click(function(event){
|
419 |
-
purchlog_id = jQuery(this).attr('title');
|
420 |
-
if(jQuery('tr.log'+purchlog_id).hasClass('wpsc_hastracking')){
|
421 |
-
jQuery('tr.log'+purchlog_id).removeClass('wpsc_hastracking');
|
422 |
-
jQuery('tr.log'+purchlog_id).hide();
|
423 |
-
}else{
|
424 |
-
jQuery('tr.log'+purchlog_id).addClass('wpsc_hastracking');
|
425 |
-
jQuery('tr.log'+purchlog_id).show();
|
426 |
-
}
|
427 |
-
event.preventDefault();
|
428 |
-
});
|
429 |
-
// this changes the purchase log item status
|
430 |
-
jQuery('.selector').change(function(){
|
431 |
-
purchlog_id = jQuery(this).attr('title');
|
432 |
-
purchlog_status = jQuery(this).val();
|
433 |
-
post_values = "action=purchlog_edit_status&purchlog_id="+purchlog_id+"&purchlog_status="+purchlog_status;
|
434 |
-
var ajax_loading = jQuery(this).prev('.ajax-loading');
|
435 |
-
ajax_loading.css('visibility', 'visible');
|
436 |
-
jQuery.post( ajaxurl, post_values, function(returned_data) {
|
437 |
-
ajax_loading.css('visibility', 'hidden');
|
438 |
-
});
|
439 |
-
|
440 |
-
if(purchlog_status == 4){
|
441 |
-
jQuery('tr.log'+purchlog_id).show();
|
442 |
-
|
443 |
-
}
|
444 |
-
});
|
445 |
-
|
446 |
-
jQuery('.sendTrackingEmail').click(function(event){
|
447 |
-
purchlog_id = jQuery(this).attr('title');
|
448 |
-
post_values = "purchlog_id="+purchlog_id;
|
449 |
-
var ajax_loader = jQuery(this).prev('.ajax-loading');
|
450 |
-
ajax_loader.css('visibility', 'visible');
|
451 |
-
jQuery.post( 'index.php?wpsc_admin_action=purchlog_email_trackid', post_values, function(returned_data) { ajax_loader.css('visibility', 'hidden'); });
|
452 |
-
event.preventDefault();
|
453 |
-
});
|
454 |
|
455 |
jQuery("a.thickbox").livequery(function(){
|
456 |
tb_init(this);
|
@@ -471,7 +263,7 @@ jQuery(document).ready(function(){
|
|
471 |
});
|
472 |
jQuery('.editinline').live('click', function(){
|
473 |
setTimeout('editinline_get_id()',200);
|
474 |
-
|
475 |
});
|
476 |
|
477 |
jQuery('a.add_variation_item_form').livequery(function(){
|
@@ -510,13 +302,6 @@ jQuery(document).ready(function(){
|
|
510 |
});
|
511 |
});
|
512 |
|
513 |
-
jQuery('a.add_new_form_set').livequery(function(){
|
514 |
-
jQuery(this).click( function() {
|
515 |
-
jQuery(".add_new_form_set_forms").toggle();
|
516 |
-
return false;
|
517 |
-
});
|
518 |
-
});
|
519 |
-
|
520 |
|
521 |
jQuery("#add-product-image").click(function(){
|
522 |
swfu.selectFiles();
|
@@ -550,28 +335,7 @@ jQuery(document).ready(function(){
|
|
550 |
for( var i in input_set) {
|
551 |
set[i] = jQuery(input_set[i]).val();
|
552 |
}
|
553 |
-
|
554 |
-
/*
|
555 |
-
img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
|
556 |
-
|
557 |
-
jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
|
558 |
-
jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt ='' /></a>");
|
559 |
-
// jQuery('#gallery_image_'+set[0]).parent('li').attr('id', "product_image_"+img_id);
|
560 |
-
//for(i=1;i<set.length;i++) {
|
561 |
-
// jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
|
562 |
-
// jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
|
563 |
-
//}
|
564 |
-
|
565 |
-
for(i=1;i<set.length;i++) {
|
566 |
-
jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
|
567 |
-
jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
|
568 |
-
|
569 |
-
element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
|
570 |
-
if(element_id == 0) {
|
571 |
-
// jQuery('#gallery_image_'+set[i]).parent('li').attr('id', "product_image_"+img_id);
|
572 |
-
}
|
573 |
-
}
|
574 |
-
*/
|
575 |
order = set.join(',');
|
576 |
product_id = jQuery('#product_id').val();
|
577 |
|
@@ -640,69 +404,6 @@ jQuery(document).ready(function(){
|
|
640 |
jQuery(this).parent().parent('tr').remove();
|
641 |
});
|
642 |
});
|
643 |
-
/* shipping options start */
|
644 |
-
// gets shipping form for admin page
|
645 |
-
// show or hide the stock input forms
|
646 |
-
|
647 |
-
jQuery(".wpsc-payment-actions a").livequery(function(){
|
648 |
-
jQuery(this).click( function () {
|
649 |
-
var module = jQuery(this).attr('rel');
|
650 |
-
//console.log(module);
|
651 |
-
jQuery.ajax({
|
652 |
-
method: "post",
|
653 |
-
url: "index.php",
|
654 |
-
data: "wpsc_admin_action=get_payment_form&paymentname="+module,
|
655 |
-
success: function(returned_data){
|
656 |
-
// console.log(returned_data);
|
657 |
-
eval(returned_data);
|
658 |
-
//jQuery(".gateway_settings").children(".form-table").html(html)
|
659 |
-
jQuery('.gateway_settings h3.hndle').html(payment_name_html);
|
660 |
-
jQuery("td.gateway_settings table.form-table").html('<tr><td><input type="hidden" name="paymentname" value="'+module+'" /></td></tr>'+payment_form_html);
|
661 |
-
if(has_submit_button != '') {
|
662 |
-
jQuery('.gateway_settings div.submit').css('display', 'block');
|
663 |
-
} else {
|
664 |
-
jQuery('.gateway_settings div.submit').css('display', 'none');
|
665 |
-
}
|
666 |
-
}
|
667 |
-
});
|
668 |
-
return false;
|
669 |
-
|
670 |
-
});
|
671 |
-
});
|
672 |
-
|
673 |
-
jQuery('#addweightlayer').livequery(function(){
|
674 |
-
jQuery(this).click(function(){
|
675 |
-
jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_WEIGHT_IS+"</i><input type='text' name='weight_layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='weight_shipping[]' size='10'> <a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
|
676 |
-
});
|
677 |
-
|
678 |
-
});
|
679 |
-
|
680 |
-
jQuery('#addlayer').livequery(function(){
|
681 |
-
jQuery(this).click(function(){
|
682 |
-
jQuery(this).parent().append("<div class='wpsc_newlayer'><tr class='rate_row'><td><i style='color:grey'>"+TXT_WPSC_IF_PRICE_IS+"</i><input type='text' name='layer[]' size='10'> <i style='color:grey'>"+TXT_WPSC_AND_ABOVE+"</i></td><td><input type='text' name='shipping[]' size='10'> <a href='' class='delete_button nosubmit' >"+TXT_WPSC_DELETE+"</a></td></tr></div>");
|
683 |
-
//bind_shipping_rate_deletion();
|
684 |
-
return false;
|
685 |
-
});
|
686 |
-
|
687 |
-
});
|
688 |
-
|
689 |
-
jQuery('table#gateway_options a.delete_button').livequery(function(){
|
690 |
-
jQuery(this).click(function () {
|
691 |
-
this_row = jQuery(this).parent().parent('tr .rate_row');
|
692 |
-
// alert(this_row);
|
693 |
-
//jQuery(this_row).hide();
|
694 |
-
if(jQuery(this).hasClass('nosubmit')) {
|
695 |
-
// if the row was added using JS, just scrap it
|
696 |
-
this_row = jQuery(this).parent('div .wpsc_newlayer');
|
697 |
-
jQuery(this_row).remove();
|
698 |
-
} else {
|
699 |
-
// otherwise, empty it and submit it
|
700 |
-
jQuery('input', this_row).val('');
|
701 |
-
jQuery(this).parents('form').submit();
|
702 |
-
}
|
703 |
-
return false;
|
704 |
-
});
|
705 |
-
});
|
706 |
|
707 |
// hover for gallery view
|
708 |
jQuery("div.previewimage").livequery(function(){
|
@@ -746,24 +447,6 @@ jQuery(document).ready(function(){
|
|
746 |
});
|
747 |
});
|
748 |
|
749 |
-
// Options page ajax tab display
|
750 |
-
jQuery('#sidemenu li').click(function(){
|
751 |
-
page_title = jQuery(this).attr('id');
|
752 |
-
|
753 |
-
wpnonce = jQuery('a',this).attr('href').match(/_wpnonce=(\w{1,})/);
|
754 |
-
post_values = "wpsc_admin_action=settings_page_ajax&page_title="+page_title+"&_wpnonce="+wpnonce[1];
|
755 |
-
jQuery.post('admin.php?', post_values, function(html){
|
756 |
-
//console.log(html);
|
757 |
-
jQuery('a.current').removeClass('current');
|
758 |
-
jQuery('#'+page_title+' a' ).addClass('current');
|
759 |
-
jQuery('#wpsc_options_page').html('');
|
760 |
-
jQuery('#wpsc_options_page').html(html);
|
761 |
-
|
762 |
-
});
|
763 |
-
return false;
|
764 |
-
|
765 |
-
});
|
766 |
-
|
767 |
jQuery('.wpsc_featured_product_toggle').livequery(function(){
|
768 |
jQuery(this).click(function(event){
|
769 |
target_url = jQuery(this).attr('href');
|
@@ -796,28 +479,6 @@ jQuery(document).ready(function(){
|
|
796 |
jQuery(this).find('.wpsc_ie_sale_price').val(sale_price);
|
797 |
jQuery(this).find('.wpsc_ie_sku').val(sku);
|
798 |
});
|
799 |
-
|
800 |
-
// Form change tracking code.
|
801 |
-
jQuery('form.wpsc_form_track input, form.wpsc_form_track textarea').live('change', function() {
|
802 |
-
jQuery(this).parents('form.wpsc_form_track:first').addClass('wpsc_form_changed');
|
803 |
-
});
|
804 |
-
|
805 |
-
jQuery('form.wpsc_form_track').live('submit', function() {
|
806 |
-
jQuery(this).removeClass('wpsc_form_changed');
|
807 |
-
|
808 |
-
});
|
809 |
-
|
810 |
-
// We'd ideally want to be using window.onbeforeonload to toss in a prompt, but that event is too
|
811 |
-
// unreliable from a browser to the next. Hooking onto anchors is the next best thing.
|
812 |
-
jQuery('form.wpsc_form_track a').live('click', function() {
|
813 |
-
if (jQuery(this).attr('href') && jQuery(this).attr('href') != '#' && !jQuery(this).hasClass('wpsc_select_all') && !jQuery(this).hasClass('wpsc_select_none')) {
|
814 |
-
if (jQuery('form.wpsc_form_changed').size()) {
|
815 |
-
if (!confirm(wpsc_adminL10n.unsaved_changes_detected)) {
|
816 |
-
return false;
|
817 |
-
}
|
818 |
-
}
|
819 |
-
}
|
820 |
-
});
|
821 |
});
|
822 |
|
823 |
// function for adding more custom meta
|
@@ -954,63 +615,10 @@ function fillcategoryform(catid) {
|
|
954 |
function submit_status_form(id) {
|
955 |
document.getElementById(id).submit();
|
956 |
}
|
957 |
-
function showaddform() {
|
958 |
-
jQuery('#blank_item').css('display', 'none');
|
959 |
-
jQuery('#productform').css('display', 'none');
|
960 |
-
jQuery('#additem').css('display', 'block');
|
961 |
-
return false;
|
962 |
-
}
|
963 |
-
//used to add new form fields in the checkout setting page
|
964 |
-
function add_form_field(e) {
|
965 |
-
var time = new Date(),
|
966 |
-
new_element_number = time.getTime(),
|
967 |
-
new_element_id = "form_id_"+new_element_number,
|
968 |
-
new_element_contents = '<tr class="checkout_form_field" id="'+new_element_id+'">';
|
969 |
-
|
970 |
-
new_element_contents += "<td class='drag'></td>";
|
971 |
-
new_element_contents += "<td class='namecol'><input type='text' name='new_form_name["+new_element_number+"]' value='' /></td>\n\r";
|
972 |
-
new_element_contents += "<td class='typecol'><select class='wpsc_checkout_selectboxes' name='new_form_type["+new_element_number+"]'>"+HTML_FORM_FIELD_TYPES+"</select></td>\n\r";
|
973 |
-
new_element_contents += "<td class='typecol'><select name='new_form_unique_name["+new_element_number+"]'>"+HTML_FORM_FIELD_UNIQUE_NAMES+"</select></td>\n\r";
|
974 |
-
new_element_contents += "<td class='mandatorycol' style='text-align: center;'><input type='checkbox' name='new_form_mandatory["+new_element_number+"]' value='1' /></td>\n\r";
|
975 |
-
new_element_contents += "<td><a class='image_link' href='#' onclick='return remove_new_form_field(\""+new_element_id+"\");'><img src='" + WPSC_CORE_IMAGES_URL + "/trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a></td>\n\r";
|
976 |
-
new_element_contents += '</tr>';
|
977 |
-
jQuery('#checkout_message').css('display', 'block');
|
978 |
-
jQuery("#wpsc_checkout_list_body").append(new_element_contents);
|
979 |
-
|
980 |
-
return false;
|
981 |
-
}
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
function remove_new_form_field(id) {
|
986 |
-
element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
|
987 |
-
if(element_count > 1) {
|
988 |
-
target_element = document.getElementById(id);
|
989 |
-
document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
|
990 |
-
}
|
991 |
-
return false;
|
992 |
-
}
|
993 |
-
|
994 |
-
|
995 |
-
function submit_change_country() {
|
996 |
-
document.cart_options.submit();
|
997 |
-
//document.cart_options.submit();
|
998 |
-
}
|
999 |
|
1000 |
function getcurrency(id) {
|
1001 |
//ajax.post("index.php",gercurrency,"wpsc_admin_action=change_currency¤cyid="+id);
|
1002 |
}
|
1003 |
-
//delete checkout fields from checkout settings page
|
1004 |
-
function remove_form_field(id,form_id) {
|
1005 |
-
var delete_variation_value=function(results) { }
|
1006 |
-
element_count = document.getElementById("wpsc_checkout_list_body").childNodes.length;
|
1007 |
-
if(element_count > 1) {
|
1008 |
-
ajax.post("index.php",delete_variation_value,"admin=true&ajax=true&remove_form_field=true&form_id="+form_id);
|
1009 |
-
target_element = document.getElementById(id);
|
1010 |
-
document.getElementById("wpsc_checkout_list_body").removeChild(target_element);
|
1011 |
-
}
|
1012 |
-
return false;
|
1013 |
-
}
|
1014 |
|
1015 |
function showadd_categorisation_form() {
|
1016 |
if(jQuery('div_categorisation').css('display') != 'block') {
|
@@ -1066,6 +674,6 @@ function editinline_get_id(){
|
|
1066 |
}else{
|
1067 |
jQuery(".wpsc-cols").css('display', 'block');
|
1068 |
}
|
1069 |
-
|
1070 |
|
1071 |
}
|
1 |
+
(function($){
|
2 |
+
if( pagenow == 'edit-wpsc_product_category' ) {
|
3 |
+
function category_sort(e, ui){
|
4 |
+
var order = $(this).sortable('toArray'),
|
5 |
+
data = {
|
6 |
+
action: 'category_sort_order',
|
7 |
+
sort_order: order,
|
8 |
+
parent_id: 0
|
9 |
+
};
|
10 |
+
|
11 |
+
jQuery.post(ajaxurl, data);
|
12 |
+
}
|
13 |
+
|
14 |
+
$(function(){
|
15 |
+
var table = $('body.edit-tags-php .wp-list-table');
|
16 |
+
table.find('tbody tr').each(function(){
|
17 |
+
var t = $(this),
|
18 |
+
id = t.attr('id').replace(/[^0-9]+/g, '');
|
19 |
+
t.data('level', WPSC_Term_List_Levels[id]);
|
20 |
+
t.data('id', id);
|
21 |
+
});
|
22 |
+
table.wpsc_sortable_table({
|
23 |
+
stop : category_sort
|
24 |
+
});
|
25 |
|
26 |
+
$('.edit-tags-php form').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data');
|
27 |
+
});
|
28 |
+
}
|
29 |
+
})(jQuery);
|
30 |
+
|
31 |
+
jQuery(document).ready(function(){
|
32 |
jQuery('td.hidden_alerts img').each(function(){
|
33 |
var t = jQuery(this);
|
34 |
t.appendTo(t.parents('tr').find('td.column-title strong'));
|
35 |
});
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/* Coupon edit functionality */
|
38 |
jQuery('.modify_coupon').hide();
|
39 |
jQuery('.wpsc_edit_coupon').click(function(){
|
99 |
|
100 |
});
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
//new currency JS in admin product page
|
103 |
jQuery('div.new_layer').livequery(function(){
|
104 |
jQuery(this).hide();
|
157 |
});
|
158 |
});
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
jQuery('#wpsc_product_list .wpsc_ie_save').live('click', function(){
|
161 |
jQuery(this).parents('tr:first').find('.loading_indicator').css('visibility', 'visible');
|
162 |
var id =jQuery(this).parents('tr:first').find('.wpsc_ie_id').val();
|
183 |
if(response.error){
|
184 |
alert(response.error);
|
185 |
jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').show();
|
186 |
+
jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').show();
|
187 |
jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
|
188 |
}
|
189 |
else{
|
195 |
jQuery('#post-' + response.id + ' .column-price .pricedisplay').html(jQuery(response.price).text());
|
196 |
jQuery('#post-' + response.id + ' .column-sale_price .pricedisplay').html(jQuery(response.special_price).text());
|
197 |
|
198 |
+
jQuery('#post-' + response.id + ' a.row-title, #post-' + response.id + ' td > span').hide();
|
199 |
+
jQuery('#post-' + response.id + ' td input.wpsc_ie_field, #post-' + response.id + ' td .wpsc_inline_actions').show();
|
200 |
jQuery('#post-' + response.id + ' .loading_indicator').css('visibility', 'hidden');
|
201 |
}
|
202 |
});
|
233 |
});
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
// this helps show the links in the product list table, it is partially done using CSS, but that breaks in IE6
|
237 |
jQuery("tr.product-edit").hover(
|
238 |
function() {
|
243 |
}
|
244 |
);
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
jQuery("a.thickbox").livequery(function(){
|
248 |
tb_init(this);
|
263 |
});
|
264 |
jQuery('.editinline').live('click', function(){
|
265 |
setTimeout('editinline_get_id()',200);
|
266 |
+
|
267 |
});
|
268 |
|
269 |
jQuery('a.add_variation_item_form').livequery(function(){
|
302 |
});
|
303 |
});
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
jQuery("#add-product-image").click(function(){
|
307 |
swfu.selectFiles();
|
335 |
for( var i in input_set) {
|
336 |
set[i] = jQuery(input_set[i]).val();
|
337 |
}
|
338 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
order = set.join(',');
|
340 |
product_id = jQuery('#product_id').val();
|
341 |
|
404 |
jQuery(this).parent().parent('tr').remove();
|
405 |
});
|
406 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
// hover for gallery view
|
409 |
jQuery("div.previewimage").livequery(function(){
|
447 |
});
|
448 |
});
|
449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
jQuery('.wpsc_featured_product_toggle').livequery(function(){
|
451 |
jQuery(this).click(function(event){
|
452 |
target_url = jQuery(this).attr('href');
|
479 |
jQuery(this).find('.wpsc_ie_sale_price').val(sale_price);
|
480 |
jQuery(this).find('.wpsc_ie_sku').val(sku);
|
481 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
});
|
483 |
|
484 |
// function for adding more custom meta
|
615 |
function submit_status_form(id) {
|
616 |
document.getElementById(id).submit();
|
617 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
|
619 |
function getcurrency(id) {
|
620 |
//ajax.post("index.php",gercurrency,"wpsc_admin_action=change_currency¤cyid="+id);
|
621 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
|
623 |
function showadd_categorisation_form() {
|
624 |
if(jQuery('div_categorisation').css('display') != 'block') {
|
674 |
}else{
|
675 |
jQuery(".wpsc-cols").css('display', 'block');
|
676 |
}
|
677 |
+
|
678 |
|
679 |
}
|
wpsc-admin/js/purchase-logs.js
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
$.extend(WPSC_Purchase_Logs_Admin, {
|
3 |
+
blur_timeout : null,
|
4 |
+
reset_textbox_width : true,
|
5 |
+
|
6 |
+
init : function() {
|
7 |
+
$(function(){
|
8 |
+
$('table.purchase-logs').delegate('.wpsc-purchase-log-status', 'change', WPSC_Purchase_Logs_Admin.event_log_status_change).
|
9 |
+
delegate('.wpsc-purchase-log-tracking-id', 'focus', WPSC_Purchase_Logs_Admin.event_tracking_id_focused).
|
10 |
+
delegate('.column-tracking a.add', 'click', WPSC_Purchase_Logs_Admin.event_button_add_clicked).
|
11 |
+
delegate('.wpsc-purchase-log-tracking-id', 'blur', WPSC_Purchase_Logs_Admin.event_tracking_id_blurred).
|
12 |
+
delegate('.column-tracking a.save', 'click', WPSC_Purchase_Logs_Admin.event_button_save_clicked).
|
13 |
+
delegate('.column-tracking .send-email a', 'click', WPSC_Purchase_Logs_Admin.event_button_send_email_clicked).
|
14 |
+
delegate('.wpsc-purchase-log-tracking-id', 'keypress', WPSC_Purchase_Logs_Admin.event_enter_key_pressed);
|
15 |
+
|
16 |
+
});
|
17 |
+
},
|
18 |
+
|
19 |
+
event_enter_key_pressed : function(e) {
|
20 |
+
var code = e.keyCode ? e.keyCode : e.which;
|
21 |
+
if (code == 13) {
|
22 |
+
$(this).siblings('.save').click();
|
23 |
+
e.preventDefault();
|
24 |
+
}
|
25 |
+
},
|
26 |
+
|
27 |
+
event_button_send_email_clicked : function() {
|
28 |
+
var t = $(this);
|
29 |
+
|
30 |
+
var post_data = {
|
31 |
+
'action' : 'wpsc_purchase_log_send_tracking_email',
|
32 |
+
'log_id' : t.closest('div').data('log-id'),
|
33 |
+
'nonce' : WPSC_Purchase_Logs_Admin.nonce
|
34 |
+
};
|
35 |
+
|
36 |
+
var ajax_callback = function(response) {
|
37 |
+
if (response != 'success') {
|
38 |
+
alert(WPSC_Purchase_Logs_Admin.send_tracking_email_error_dialog);
|
39 |
+
t.show().siblings('em').remove();
|
40 |
+
} else {
|
41 |
+
t.siblings('em').addClass('sent').text(WPSC_Purchase_Logs_Admin.sent_message);
|
42 |
+
t.remove();
|
43 |
+
}
|
44 |
+
};
|
45 |
+
|
46 |
+
t.hide().after('<em>' + WPSC_Purchase_Logs_Admin.sending_message + '</em>');
|
47 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
48 |
+
|
49 |
+
return false;
|
50 |
+
},
|
51 |
+
|
52 |
+
event_button_save_clicked : function() {
|
53 |
+
WPSC_Purchase_Logs_Admin.reset_textbox_width = false;
|
54 |
+
|
55 |
+
var t = $(this), textbox = t.siblings('.wpsc-purchase-log-tracking-id'), spinner = t.siblings('.ajax-feedback');
|
56 |
+
|
57 |
+
var post_data = {
|
58 |
+
'action' : 'wpsc_purchase_log_save_tracking_id',
|
59 |
+
'value' : textbox.val(),
|
60 |
+
'log_id' : t.parent().data('log-id'),
|
61 |
+
'nonce' : WPSC_Purchase_Logs_Admin.nonce
|
62 |
+
};
|
63 |
+
|
64 |
+
var ajax_callback = function(response) {
|
65 |
+
spinner.toggleClass('ajax-feedback-active');
|
66 |
+
textbox.blur();
|
67 |
+
if (response == 'success') {
|
68 |
+
t.parent().removeClass('empty');
|
69 |
+
} else {
|
70 |
+
alert(WPSC_Purchase_Logs_Admin.tracking_error_dialog);
|
71 |
+
}
|
72 |
+
};
|
73 |
+
|
74 |
+
t.hide();
|
75 |
+
spinner.toggleClass('ajax-feedback-active');
|
76 |
+
textbox.width(160);
|
77 |
+
|
78 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
79 |
+
|
80 |
+
return false;
|
81 |
+
},
|
82 |
+
|
83 |
+
event_button_add_clicked : function() {
|
84 |
+
$(this).siblings('.wpsc-purchase-log-tracking-id').trigger('focus');
|
85 |
+
return false;
|
86 |
+
},
|
87 |
+
|
88 |
+
event_tracking_id_blurred : function() {
|
89 |
+
var t = $(this);
|
90 |
+
var reset_width = function() {
|
91 |
+
if (WPSC_Purchase_Logs_Admin.reset_textbox_width) {
|
92 |
+
t.siblings('a.save').hide();
|
93 |
+
t.width('');
|
94 |
+
if (t.val() === '') {
|
95 |
+
t.siblings('.add').show();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
WPSC_Purchase_Logs_Admin.reset_textbox_width = true;
|
100 |
+
};
|
101 |
+
|
102 |
+
WPSC_Purchase_Logs_Admin.blur_timeout = setTimeout(reset_width, 100);
|
103 |
+
},
|
104 |
+
|
105 |
+
event_tracking_id_focused : function() {
|
106 |
+
var t = $(this);
|
107 |
+
t.width(128);
|
108 |
+
t.siblings('a.save').show();
|
109 |
+
t.siblings('a.add').hide();
|
110 |
+
},
|
111 |
+
|
112 |
+
event_log_status_change : function() {
|
113 |
+
var post_data = {
|
114 |
+
nonce : WPSC_Purchase_Logs_Admin.nonce,
|
115 |
+
action : 'wpsc_change_purchase_log_status',
|
116 |
+
id : $(this).data('log-id'),
|
117 |
+
new_status : $(this).val()
|
118 |
+
},
|
119 |
+
spinner = $(this).siblings('.ajax-feedback'),
|
120 |
+
t = $(this);
|
121 |
+
spinner.addClass('ajax-feedback-active');
|
122 |
+
var ajax_callback = function(response) {
|
123 |
+
spinner.removeClass('ajax-feedback-active');
|
124 |
+
if (response != 'success') {
|
125 |
+
alert(WPSC_Purchase_Logs_Admin.status_error_dialog);
|
126 |
+
}
|
127 |
+
};
|
128 |
+
|
129 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
130 |
+
}
|
131 |
+
});
|
132 |
+
|
133 |
+
})(jQuery);
|
134 |
+
|
135 |
+
WPSC_Purchase_Logs_Admin.init();
|
wpsc-admin/js/settings-page.js
ADDED
@@ -0,0 +1,884 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WPSC_Settings_Page object and functions.
|
3 |
+
*
|
4 |
+
* Dependencies: jQuery, jQuery.query
|
5 |
+
*
|
6 |
+
* The following properties of WPSC_Settings_Page have been set by wp_localize_script():
|
7 |
+
* - current_tab: The ID of the currently active tab
|
8 |
+
* - nonce : The nonce used to verify request to load tab content via AJAX
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @requires jQuery
|
13 |
+
* @requires jQuery.query
|
14 |
+
*/
|
15 |
+
|
16 |
+
(function($){
|
17 |
+
|
18 |
+
$.extend(WPSC_Settings_Page, /** @lends WPSC_Settings_Page */ {
|
19 |
+
/**
|
20 |
+
* Set to true if there are modified settings.
|
21 |
+
* @type {Boolean}
|
22 |
+
* @since 3.8.8
|
23 |
+
*/
|
24 |
+
unsaved_settings : false,
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Event binding for WPSC_Settings_Page
|
28 |
+
* @since 3.8.8
|
29 |
+
*/
|
30 |
+
init : function() {
|
31 |
+
// make sure the event object contains the 'state' property
|
32 |
+
$.event.props.push('state');
|
33 |
+
|
34 |
+
// set the history state of the current page
|
35 |
+
if (history.replaceState) {
|
36 |
+
(function(){
|
37 |
+
history.replaceState({url : location.search + location.hash}, '', location.search + location.hash);
|
38 |
+
})();
|
39 |
+
}
|
40 |
+
|
41 |
+
// load the correct settings tab when back/forward browser button is used
|
42 |
+
$(window).bind('popstate', WPSC_Settings_Page.event_pop_state);
|
43 |
+
|
44 |
+
$(function(){
|
45 |
+
$('#wpsc_options').delegate('a.nav-tab' , 'click' , WPSC_Settings_Page.event_tab_button_clicked).
|
46 |
+
delegate('input, textarea, select', 'change', WPSC_Settings_Page.event_settings_changed).
|
47 |
+
delegate('#wpsc-settings-form' , 'submit', WPSC_Settings_Page.event_settings_form_submitted);
|
48 |
+
$(window).bind('beforeunload', WPSC_Settings_Page.event_before_unload);
|
49 |
+
$(WPSC_Settings_Page).trigger('wpsc_settings_tab_loaded');
|
50 |
+
$(WPSC_Settings_Page).trigger('wpsc_settings_tab_loaded_' + WPSC_Settings_Page.current_tab);
|
51 |
+
});
|
52 |
+
},
|
53 |
+
|
54 |
+
/**
|
55 |
+
* This prevents the confirm dialog triggered by event_before_unload from being displayed.
|
56 |
+
* @since 3.8.8
|
57 |
+
*/
|
58 |
+
event_settings_form_submitted : function() {
|
59 |
+
WPSC_Settings_Page.unsaved_settings = false;
|
60 |
+
},
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Mark the page as "unsaved" when a field is modified
|
64 |
+
* @since 3.8.8
|
65 |
+
*/
|
66 |
+
event_settings_changed : function() {
|
67 |
+
WPSC_Settings_Page.unsaved_settings = true;
|
68 |
+
},
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Display a confirm dialog when the user is trying to navigate
|
72 |
+
* away with unsaved settings
|
73 |
+
* @since 3.8.8
|
74 |
+
*/
|
75 |
+
event_before_unload : function() {
|
76 |
+
if (WPSC_Settings_Page.unsaved_settings) {
|
77 |
+
return WPSC_Settings_Page.before_unload_dialog;
|
78 |
+
}
|
79 |
+
},
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Load the settings tab when tab buttons are clicked
|
83 |
+
* @since 3.8.8
|
84 |
+
*/
|
85 |
+
event_tab_button_clicked : function() {
|
86 |
+
var href = $(this).attr('href');
|
87 |
+
WPSC_Settings_Page.load_tab(href);
|
88 |
+
return false;
|
89 |
+
},
|
90 |
+
|
91 |
+
/**
|
92 |
+
* When back/forward browser button is clicked, load the correct tab
|
93 |
+
* @param {Object} e Event object
|
94 |
+
* @since 3.8.8
|
95 |
+
*/
|
96 |
+
event_pop_state : function(e) {
|
97 |
+
if (e.state) {
|
98 |
+
WPSC_Settings_Page.load_tab(e.state.url, false);
|
99 |
+
}
|
100 |
+
},
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Display a small spinning wheel when loading a tab via AJAX
|
104 |
+
* @param {String} tab_id Tab ID
|
105 |
+
* @since 3.8.8
|
106 |
+
*/
|
107 |
+
toggle_ajax_state : function(tab_id) {
|
108 |
+
var tab_button = $('a[data-tab-id="' + tab_id + '"]');
|
109 |
+
tab_button.toggleClass('nav-tab-loading');
|
110 |
+
},
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Use AJAX to load a tab to the settings page. If there are unsaved settings in the
|
114 |
+
* current tab, a confirm dialog will be displayed.
|
115 |
+
*
|
116 |
+
* @param {String} tab_id The ID string of the tab
|
117 |
+
* @param {Boolean} push_state True (Default) if we need to history.pushState.
|
118 |
+
* False if this is a result of back/forward browser button being pushed.
|
119 |
+
* @since 3.8.8
|
120 |
+
*/
|
121 |
+
load_tab : function(url, push_state) {
|
122 |
+
if (WPSC_Settings_Page.unsaved_settings && ! confirm(WPSC_Settings_Page.ajax_navigate_confirm_dialog)) {
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
if (typeof push_state == 'undefined') {
|
127 |
+
push_state = true;
|
128 |
+
}
|
129 |
+
|
130 |
+
var query = $.query.load(url);
|
131 |
+
var tab_id = query.get('tab');
|
132 |
+
var post_data = $.extend({}, query.get(), {
|
133 |
+
'action' : 'wpsc_navigate_settings_tab',
|
134 |
+
'nonce' : WPSC_Settings_Page.nonce,
|
135 |
+
'current_url' : location.href,
|
136 |
+
'tab' : tab_id
|
137 |
+
});
|
138 |
+
var spinner = $('#wpsc-settings-page-title .ajax-feedback');
|
139 |
+
|
140 |
+
spinner.addClass('ajax-feedback-active');
|
141 |
+
WPSC_Settings_Page.toggle_ajax_state(tab_id);
|
142 |
+
|
143 |
+
// pushState to save this page load into history, and alter the address field of the browser
|
144 |
+
if (push_state && history.pushState) {
|
145 |
+
history.pushState({'url' : url}, '', url);
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Replace the option tab content with the AJAX response, also change
|
150 |
+
* the action URL of the form and switch the active tab.
|
151 |
+
* @param {String} response HTML response string
|
152 |
+
* @since 3.8.8
|
153 |
+
*/
|
154 |
+
var ajax_callback = function(response) {
|
155 |
+
var t = WPSC_Settings_Page;
|
156 |
+
t.unsaved_settings = false;
|
157 |
+
t.toggle_ajax_state(tab_id);
|
158 |
+
$('#options_' + WPSC_Settings_Page.current_tab).replaceWith(response);
|
159 |
+
WPSC_Settings_Page.current_tab = tab_id;
|
160 |
+
$('.nav-tab-active').removeClass('nav-tab-active');
|
161 |
+
$('[data-tab-id="' + tab_id + '"]').addClass('nav-tab-active');
|
162 |
+
$('#wpsc_options_page form').attr('action', url);
|
163 |
+
$(t).trigger('wpsc_settings_tab_loaded');
|
164 |
+
$(t).trigger('wpsc_settings_tab_loaded_' + tab_id);
|
165 |
+
spinner.removeClass('ajax-feedback-active');
|
166 |
+
}
|
167 |
+
|
168 |
+
$.post(ajaxurl, post_data, ajax_callback, 'html');
|
169 |
+
}
|
170 |
+
});
|
171 |
+
|
172 |
+
/**
|
173 |
+
* General tab
|
174 |
+
* @namespace
|
175 |
+
* @since 3.8.8
|
176 |
+
*/
|
177 |
+
WPSC_Settings_Page.General = {
|
178 |
+
/**
|
179 |
+
* Event binding for base country drop down
|
180 |
+
* @since 3.8.8
|
181 |
+
*/
|
182 |
+
event_init : function() {
|
183 |
+
var wrapper = $('#options_general');
|
184 |
+
wrapper.delegate('#wpsc-base-country-drop-down', 'change', WPSC_Settings_Page.General.event_base_country_changed).
|
185 |
+
delegate('.wpsc-select-all', 'click', WPSC_Settings_Page.General.event_select_all).
|
186 |
+
delegate('.wpsc-select-none', 'click', WPSC_Settings_Page.General.event_select_none);
|
187 |
+
},
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Select all countries for Target Markets
|
191 |
+
* @since 3.8.8
|
192 |
+
*/
|
193 |
+
event_select_all : function() {
|
194 |
+
$('#wpsc-target-markets input:checkbox').each(function(){ this.checked = true; });
|
195 |
+
return false;
|
196 |
+
},
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Deselect all countries for Target Markets
|
200 |
+
* @since 3.8.8
|
201 |
+
*/
|
202 |
+
event_select_none : function() {
|
203 |
+
$('#wpsc-target-markets input:checkbox').each(function(){ this.checked = false; });
|
204 |
+
return false;
|
205 |
+
},
|
206 |
+
|
207 |
+
/**
|
208 |
+
* When country is changed, load the region / state drop down using AJAX
|
209 |
+
* @since 3.8.8
|
210 |
+
*/
|
211 |
+
event_base_country_changed : function() {
|
212 |
+
var span = $('#wpsc-base-region-drop-down');
|
213 |
+
span.find('select').remove();
|
214 |
+
span.find('img').toggleClass('ajax-feedback-active');
|
215 |
+
|
216 |
+
var postdata = {
|
217 |
+
action : 'wpsc_display_region_list',
|
218 |
+
country : $('#wpsc-base-country-drop-down').val(),
|
219 |
+
nonce : WPSC_Settings_Page.nonce
|
220 |
+
};
|
221 |
+
|
222 |
+
var ajax_callback = function(response) {
|
223 |
+
span.find('img').toggleClass('ajax-feedback-active');
|
224 |
+
if (response !== '') {
|
225 |
+
span.prepend(response);
|
226 |
+
}
|
227 |
+
};
|
228 |
+
$.post(ajaxurl, postdata, ajax_callback, 'html');
|
229 |
+
}
|
230 |
+
};
|
231 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_general', WPSC_Settings_Page.General.event_init);
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Presentation tab
|
235 |
+
* @namespace
|
236 |
+
* @since 3.8.8
|
237 |
+
*/
|
238 |
+
WPSC_Settings_Page.Presentation = {
|
239 |
+
/**
|
240 |
+
* IDs of checkboxes for Grid View (excluding the Show Images Only checkbox)
|
241 |
+
* @type {Array}
|
242 |
+
* @since 3.8.8
|
243 |
+
*/
|
244 |
+
grid_view_boxes : ['wpsc-display-variations', 'wpsc-display-description', 'wpsc-display-add-to-cart', 'wpsc-display-more-details'],
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Event binding for Grid View checkboxes
|
248 |
+
* @since 3.8.8
|
249 |
+
*/
|
250 |
+
event_init : function() {
|
251 |
+
var wrapper = $('#options_presentation'),
|
252 |
+
checkbox_selector = '#' + WPSC_Settings_Page.Presentation.grid_view_boxes.join(',#');
|
253 |
+
wrapper.delegate('#wpsc-show-images-only', 'click', WPSC_Settings_Page.Presentation.event_show_images_only_clicked);
|
254 |
+
wrapper.delegate(checkbox_selector , 'click', WPSC_Settings_Page.Presentation.event_grid_view_boxes_clicked);
|
255 |
+
},
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Deselect "Show Images Only" checkbox when any other Grid View checkboxes are selected
|
259 |
+
* @since 3.8.8
|
260 |
+
*/
|
261 |
+
event_grid_view_boxes_clicked : function() {
|
262 |
+
document.getElementById('wpsc-show-images-only').checked = false;
|
263 |
+
},
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Deselect all other Grid View checkboxes when "Show Images Only" is selected
|
267 |
+
* @since 3.8.8
|
268 |
+
*/
|
269 |
+
event_show_images_only_clicked : function() {
|
270 |
+
var i;
|
271 |
+
if ($(this).is(':checked')) {
|
272 |
+
for (i in WPSC_Settings_Page.Presentation.grid_view_boxes) {
|
273 |
+
document.getElementById(WPSC_Settings_Page.Presentation.grid_view_boxes[i]).checked = false;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
};
|
278 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_presentation', WPSC_Settings_Page.Presentation.event_init);
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Checkout Tab
|
282 |
+
* @namespace
|
283 |
+
* @since 3.8.8
|
284 |
+
*/
|
285 |
+
WPSC_Settings_Page.Checkout = {
|
286 |
+
new_field_count : 0,
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Event binding for Checkout tab
|
290 |
+
* @since 3.8.8
|
291 |
+
*/
|
292 |
+
event_init : function() {
|
293 |
+
var wrapper = $('#options_checkout');
|
294 |
+
wrapper.delegate('.add_new_form_set', 'click', WPSC_Settings_Page.Checkout.event_add_new_form_set).
|
295 |
+
delegate('.actionscol a.add', 'click', WPSC_Settings_Page.Checkout.event_add_new_field).
|
296 |
+
delegate('.actionscol a.delete', 'click', WPSC_Settings_Page.Checkout.event_delete_field).
|
297 |
+
delegate('a.edit-options', 'click', WPSC_Settings_Page.Checkout.event_edit_field_options).
|
298 |
+
delegate('select[name^="form_type"], select[name^="new_field_type"]', 'change', WPSC_Settings_Page.Checkout.event_form_type_changed).
|
299 |
+
delegate('.field-option-cell-wrapper .add', 'click', WPSC_Settings_Page.Checkout.event_add_field_option).
|
300 |
+
delegate('.field-option-cell-wrapper .delete', 'click', WPSC_Settings_Page.Checkout.event_delete_field_option);
|
301 |
+
$('#wpsc-settings-form').bind('submit', WPSC_Settings_Page.Checkout.event_form_submit);
|
302 |
+
|
303 |
+
wrapper.find('#wpsc_checkout_list').
|
304 |
+
sortable({
|
305 |
+
items : 'tr.checkout_form_field',
|
306 |
+
axis : 'y',
|
307 |
+
containment : 'parent',
|
308 |
+
placeholder : 'checkout-placeholder',
|
309 |
+
handle : '.drag',
|
310 |
+
sort : WPSC_Settings_Page.Checkout.event_sort,
|
311 |
+
helper : WPSC_Settings_Page.Checkout.fix_sortable_helper,
|
312 |
+
start : WPSC_Settings_Page.Checkout.event_sort_start,
|
313 |
+
stop : WPSC_Settings_Page.Checkout.event_sort_stop,
|
314 |
+
update : WPSC_Settings_Page.Checkout.event_sort_update,
|
315 |
+
});
|
316 |
+
},
|
317 |
+
|
318 |
+
event_add_field_option : function() {
|
319 |
+
var target_row = $(this).closest('tr'),
|
320 |
+
prototype = target_row.siblings('.new-option').clone(),
|
321 |
+
options_row = $(this).closest('.form-field-options'),
|
322 |
+
id = options_row.data('field-id'),
|
323 |
+
options_field_name;
|
324 |
+
|
325 |
+
if (! id) {
|
326 |
+
id = options_row.data('new-field-id');
|
327 |
+
options_field_name = 'new_field_options[' + id + ']';
|
328 |
+
} else {
|
329 |
+
options_field_name = 'form_options[' + id + ']';
|
330 |
+
}
|
331 |
+
|
332 |
+
prototype.removeClass('new-option');
|
333 |
+
prototype.find('.field-option-cell-wrapper').hide();
|
334 |
+
prototype.find('.column-labels input').attr('name', options_field_name + '[label][]');
|
335 |
+
prototype.find('.column-values input').attr('name', options_field_name + '[value][]');
|
336 |
+
prototype.insertAfter(target_row).show().find('.field-option-cell-wrapper').slideDown(150);
|
337 |
+
prototype.find('input[type="text"]').eq(0).focus();
|
338 |
+
|
339 |
+
WPSC_Settings_Page.unsaved_settings = true;
|
340 |
+
return false;
|
341 |
+
},
|
342 |
+
|
343 |
+
event_delete_field_option : function() {
|
344 |
+
var target_row = $(this).closest('tr'),
|
345 |
+
prototype = target_row.siblings('.new-option');
|
346 |
+
|
347 |
+
target_row.find('.field-option-cell-wrapper').slideUp(150, function(){
|
348 |
+
var clone;
|
349 |
+
if (prototype.siblings().size() == 1) {
|
350 |
+
clone = prototype.clone().removeClass('new-option');
|
351 |
+
clone.find('.field-option-cell-wrapper').hide();
|
352 |
+
clone.show().insertAfter(target_row);
|
353 |
+
clone.find('.field-option-cell-wrapper').slideDown(150);
|
354 |
+
}
|
355 |
+
target_row.remove();
|
356 |
+
});
|
357 |
+
|
358 |
+
WPSC_Settings_Page.unsaved_settings = true;
|
359 |
+
|
360 |
+
return false;
|
361 |
+
},
|
362 |
+
|
363 |
+
event_form_type_changed : function() {
|
364 |
+
var t = $(this),
|
365 |
+
target_row = t.closest('tr'),
|
366 |
+
id = target_row.data('field-id'),
|
367 |
+
link = target_row.find('.edit-options'),
|
368 |
+
options_row_id = 'wpsc-field-edit-options-' + id;
|
369 |
+
|
370 |
+
if (! id) {
|
371 |
+
id = target_row.data('new-field-id');
|
372 |
+
options_row_id = 'wpsc-new-field-edit-options-' + id;
|
373 |
+
}
|
374 |
+
|
375 |
+
if ($.inArray(t.val(), ['select', 'radio', 'checkbox']) !== -1) {
|
376 |
+
link.show();
|
377 |
+
} else {
|
378 |
+
link.hide().text(WPSC_Settings_Page.edit_field_options).removeClass('expanded');
|
379 |
+
$('#wpsc-field-edit-options-' + id).find('.cell-wrapper').slideUp(150, function(){
|
380 |
+
$(this).closest('tr').remove();
|
381 |
+
target_row.removeClass('editing-options');
|
382 |
+
});
|
383 |
+
}
|
384 |
+
},
|
385 |
+
|
386 |
+
event_edit_field_options : function() {
|
387 |
+
var t = $(this), target = t.closest('tr'),
|
388 |
+
id, options_row, label_inputs, options_field_name,
|
389 |
+
prototype_option, options_row_id, data_name;
|
390 |
+
|
391 |
+
id = target.data('field-id');
|
392 |
+
|
393 |
+
if (id) {
|
394 |
+
options_field_name = 'form_options[' + id + ']';
|
395 |
+
options_row_id = 'wpsc-field-edit-options-' + id;
|
396 |
+
data_name = 'field-id';
|
397 |
+
} else {
|
398 |
+
id = target.data('new-field-id');
|
399 |
+
options_field_name = 'new_field_options[' + id + ']';
|
400 |
+
options_row_id = 'wpsc-new-field-edit-options-' + id;
|
401 |
+
data_name = 'new-field-id';
|
402 |
+
}
|
403 |
+
|
404 |
+
options_row = $('#' + options_row_id);
|
405 |
+
|
406 |
+
if (t.hasClass('expanded')) {
|
407 |
+
options_row.find('.cell-wrapper').slideUp(150, function(){
|
408 |
+
$(this).closest('tr').hide();
|
409 |
+
target.removeClass('editing-options');
|
410 |
+
});
|
411 |
+
t.removeClass('expanded');
|
412 |
+
t.text(WPSC_Settings_Page.edit_field_options);
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
|
416 |
+
t.addClass('expanded');
|
417 |
+
t.text(WPSC_Settings_Page.hide_edit_field_options);
|
418 |
+
target.addClass('editing-options');
|
419 |
+
|
420 |
+
if (options_row.size() > 0) {
|
421 |
+
options_row.show().find('.cell-wrapper').slideDown(150);
|
422 |
+
return false;
|
423 |
+
}
|
424 |
+
|
425 |
+
options_row = $('#field-options-prototype').clone();
|
426 |
+
prototype_option = options_row.find('.new-option');
|
427 |
+
|
428 |
+
options_row.
|
429 |
+
attr('id', options_row_id).
|
430 |
+
data(data_name, id);
|
431 |
+
|
432 |
+
if (target.hasClass('new-field')) {
|
433 |
+
options_row.addClass('new-field-options');
|
434 |
+
}
|
435 |
+
|
436 |
+
|
437 |
+
prototype_option.find('.column-labels input').attr('name', options_field_name + '[label][]');
|
438 |
+
prototype_option.find('.column-values input').attr('name', options_field_name + '[value][]');
|
439 |
+
|
440 |
+
label_inputs = target.find('input[name^="' + options_field_name + '[label]"]');
|
441 |
+
|
442 |
+
label_inputs.each(function(){
|
443 |
+
var prototype = options_row.find('.new-option'),
|
444 |
+
appended_row = prototype.clone().removeClass('new-option'),
|
445 |
+
input_label = $(this),
|
446 |
+
input_value = $(this).next(),
|
447 |
+
new_label_field = $('<input type="text" />').attr('name', input_label.attr('name')).val(input_label.val()),
|
448 |
+
new_value_field = $('<input type="text" />').attr('name', input_value.attr('name')).val(input_value.val());
|
449 |
+
|
450 |
+
appended_row.find('.column-labels input').replaceWith(new_label_field);
|
451 |
+
appended_row.find('.column-values input').replaceWith(new_value_field);
|
452 |
+
options_row.find('tbody').append(appended_row);
|
453 |
+
input_value.remove();
|
454 |
+
input_label.remove();
|
455 |
+
});
|
456 |
+
|
457 |
+
prototype_option.hide();
|
458 |
+
if (label_inputs.size() == 0) {
|
459 |
+
prototype_option.clone().removeClass('new-option').show().appendTo(options_row.find('tbody'));
|
460 |
+
}
|
461 |
+
|
462 |
+
options_row.find('.cell-wrapper').hide();
|
463 |
+
options_row.insertAfter(target).show().find('.cell-wrapper').slideDown(150);
|
464 |
+
return false;
|
465 |
+
},
|
466 |
+
|
467 |
+
event_form_submit : function() {
|
468 |
+
var sort_order = $('#wpsc_checkout_list').sortable('toArray');
|
469 |
+
for (index in sort_order) {
|
470 |
+
$(this).append('<input type="hidden" name="sort_order[]" value="' + sort_order[index] + '" />');
|
471 |
+
}
|
472 |
+
return true;
|
473 |
+
},
|
474 |
+
|
475 |
+
event_add_new_field : function() {
|
476 |
+
var target_row = $(this).closest('tr'),
|
477 |
+
new_row = $('#field-prototype').clone(),
|
478 |
+
id;
|
479 |
+
|
480 |
+
WPSC_Settings_Page.Checkout.new_field_count ++;
|
481 |
+
id = WPSC_Settings_Page.Checkout.new_field_count;
|
482 |
+
new_row.
|
483 |
+
attr('id', 'new-field-' + id).
|
484 |
+
addClass('checkout_form_field').
|
485 |
+
data('new-field-id', id);
|
486 |
+
new_row.find('.cell-wrapper').hide();
|
487 |
+
new_row.find('input, select').each(function(){
|
488 |
+
var t = $(this),
|
489 |
+
name = t.attr('name'),
|
490 |
+
new_name = name.replace('[0]', '[' + id + ']');
|
491 |
+
|
492 |
+
t.attr('name', new_name);
|
493 |
+
});
|
494 |
+
new_row.insertAfter(target_row).show().find('.cell-wrapper').slideDown(150);
|
495 |
+
|
496 |
+
WPSC_Settings_Page.unsaved_settings = true;
|
497 |
+
return false;
|
498 |
+
},
|
499 |
+
|
500 |
+
event_delete_field : function() {
|
501 |
+
var target_row = $(this).closest('tr');
|
502 |
+
target_row.find('.cell-wrapper').slideUp(150, function(){
|
503 |
+
var id = target_row.data('field-id');
|
504 |
+
|
505 |
+
if (id) {
|
506 |
+
$('#wpsc-field-edit-options-' + id).remove();
|
507 |
+
} else {
|
508 |
+
id = target_row.data('new-field-id');
|
509 |
+
$('#wpsc-new-field-edit-options-' + id).remove();
|
510 |
+
}
|
511 |
+
target_row.remove();
|
512 |
+
});
|
513 |
+
|
514 |
+
WPSC_Settings_Page.unsaved_settings = true;
|
515 |
+
return false;
|
516 |
+
},
|
517 |
+
|
518 |
+
/**
|
519 |
+
* This hack is to make sure the dragged row has 100% width
|
520 |
+
*
|
521 |
+
* @param {Object} e Event object
|
522 |
+
* @param {Object} tr The row being dragged
|
523 |
+
* @return {Object} helper The helper object (which is a clone of the row)
|
524 |
+
*/
|
525 |
+
fix_sortable_helper : function(e, tr) {
|
526 |
+
var row = tr.clone().width(tr.width());
|
527 |
+
row.find('td').each(function(index){
|
528 |
+
var td_class = $(this).attr('class'), original = tr.find('.' + td_class), old_html = $(this).html();
|
529 |
+
$(this).find('.cell-wrapper').width(original.width());
|
530 |
+
});
|
531 |
+
return row;
|
532 |
+
},
|
533 |
+
|
534 |
+
/**
|
535 |
+
* The placeholder in this case will be an empty <tr> element. Need to add
|
536 |
+
* a <td> inside for styling purpose.
|
537 |
+
* @param {Object} e Event Object
|
538 |
+
* @param {Object} ui UI Object
|
539 |
+
*/
|
540 |
+
event_sort_start : function(e, ui) {
|
541 |
+
var t = $(this);
|
542 |
+
|
543 |
+
$('.form-field-options').find('.cell-wrapper').slideUp(150, function(){
|
544 |
+
var options_row = $(this).closest('tr'),
|
545 |
+
id = options_row.data('field-id'),
|
546 |
+
row_id = '#checkout_' + id;
|
547 |
+
|
548 |
+
if (! id) {
|
549 |
+
id = options_row.data('new-field-id');
|
550 |
+
row_id = '#new-field-' + id;
|
551 |
+
}
|
552 |
+
options_row.hide();
|
553 |
+
t.sortable('refreshPositions');
|
554 |
+
$(row_id).removeClass('editing-options');
|
555 |
+
});
|
556 |
+
|
557 |
+
ui.placeholder.html('<td colspan="7"> </td>');
|
558 |
+
},
|
559 |
+
|
560 |
+
event_sort_stop : function(e,ui) {
|
561 |
+
$('.form-field-options').each(function(){
|
562 |
+
var options_row = $(this),
|
563 |
+
id = $(this).data('field-id'),
|
564 |
+
target_row_id = '#checkout_' + id,
|
565 |
+
target_row;
|
566 |
+
|
567 |
+
if (! id) {
|
568 |
+
id = $(this).data('new-field-id');
|
569 |
+
target_row_id = '#new-field-' + id;
|
570 |
+
}
|
571 |
+
target_row = $(target_row_id);
|
572 |
+
options_row.insertAfter(target_row).show().find('.cell-wrapper').slideDown(150, function(){
|
573 |
+
target_row.addClass('editing-options');
|
574 |
+
});
|
575 |
+
});
|
576 |
+
},
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Update sort order via AJAX.
|
580 |
+
* @param {Object} e Event Object
|
581 |
+
* @param {Object} ui UI Object
|
582 |
+
*/
|
583 |
+
event_sort_update : function(e, ui) {
|
584 |
+
if (ui.item.hasClass('new-field')) {
|
585 |
+
return;
|
586 |
+
}
|
587 |
+
|
588 |
+
var spinner = $(ui.item).find('.ajax-feedback');
|
589 |
+
var post_data = {
|
590 |
+
action : 'wpsc_update_checkout_fields_order',
|
591 |
+
nonce : WPSC_Settings_Page.nonce,
|
592 |
+
sort_order : $('table#wpsc_checkout_list').sortable('toArray')
|
593 |
+
};
|
594 |
+
var ajax_callback = function(response) {
|
595 |
+
spinner.toggleClass('ajax-feedback-active');
|
596 |
+
ui.item.find('.drag a').show();
|
597 |
+
if (response != 'success') {
|
598 |
+
alert(WPSC_Settings_Page.checkout_field_sort_error_dialog);
|
599 |
+
}
|
600 |
+
};
|
601 |
+
ui.item.find('.drag a').hide();
|
602 |
+
spinner.toggleClass('ajax-feedback-active');
|
603 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
604 |
+
},
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Toggle "Add New Form Set" field
|
608 |
+
* @since 3.8.8
|
609 |
+
*/
|
610 |
+
event_add_new_form_set : function() {
|
611 |
+
$(".add_new_form_set_forms").toggle();
|
612 |
+
return false;
|
613 |
+
}
|
614 |
+
};
|
615 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_checkout', WPSC_Settings_Page.Checkout.event_init);
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Taxes tab
|
619 |
+
* @namespace
|
620 |
+
* @since 3.8.8
|
621 |
+
*/
|
622 |
+
WPSC_Settings_Page.Taxes = {
|
623 |
+
/**
|
624 |
+
* Event binding for Taxes tab
|
625 |
+
* @since 3.8.8
|
626 |
+
*/
|
627 |
+
event_init : function() {
|
628 |
+
var wrapper = $('#options_taxes');
|
629 |
+
wrapper.delegate('#wpsc-add-tax-rates a' , 'click' , WPSC_Settings_Page.Taxes.event_add_tax_rate).
|
630 |
+
delegate('.wpsc-taxes-rates-delete' , 'click' , WPSC_Settings_Page.Taxes.event_delete_tax_rate).
|
631 |
+
delegate('#wpsc-add-tax-bands a' , 'click' , WPSC_Settings_Page.Taxes.event_add_tax_band).
|
632 |
+
delegate('.wpsc-taxes-bands-delete' , 'click' , WPSC_Settings_Page.Taxes.event_delete_tax_band).
|
633 |
+
delegate('.wpsc-taxes-country-drop-down', 'change', WPSC_Settings_Page.Taxes.event_country_drop_down_changed);
|
634 |
+
},
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Load the region drop down via AJAX if the country has regions
|
638 |
+
* @since 3.8.8
|
639 |
+
*/
|
640 |
+
event_country_drop_down_changed : function() {
|
641 |
+
var c = $(this),
|
642 |
+
post_data = {
|
643 |
+
action : 'wpec_taxes_ajax',
|
644 |
+
wpec_taxes_action : 'wpec_taxes_get_regions',
|
645 |
+
current_key : c.data('key'),
|
646 |
+
taxes_type : c.data('type'),
|
647 |
+
country_code : c.val(),
|
648 |
+
nonce : WPSC_Settings_Page.nonce
|
649 |
+
},
|
650 |
+
spinner = c.siblings('.ajax-feedback'),
|
651 |
+
ajax_callback = function(response) {
|
652 |
+
spinner.toggleClass('ajax-feedback-active');
|
653 |
+
if (response != '') {
|
654 |
+
c.after(response);
|
655 |
+
}
|
656 |
+
};
|
657 |
+
spinner.toggleClass('ajax-feedback-active');
|
658 |
+
c.siblings('.wpsc-taxes-region-drop-down').remove();
|
659 |
+
|
660 |
+
$.post(ajaxurl, post_data, ajax_callback, 'html');
|
661 |
+
},
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Add new tax rate field when "Add Tax Rate" is clicked
|
665 |
+
* @since 3.8.8
|
666 |
+
* TODO: rewrote the horrible code in class wpec_taxes_controller. There's really no need for AJAX here.
|
667 |
+
*/
|
668 |
+
event_add_tax_rate : function() {
|
669 |
+
WPSC_Settings_Page.Taxes.add_field('rates');
|
670 |
+
return false;
|
671 |
+
},
|
672 |
+
|
673 |
+
/**
|
674 |
+
* Remove a tax rate row when "Delete" on that row is clicked.
|
675 |
+
* @since 3.8.8
|
676 |
+
*/
|
677 |
+
event_delete_tax_rate : function() {
|
678 |
+
$(this).parents('.wpsc-tax-rates-row').remove();
|
679 |
+
return false;
|
680 |
+
},
|
681 |
+
|
682 |
+
/**
|
683 |
+
* Add new tax band field when "Add Tax Band" is clicked.
|
684 |
+
* @since 3.8.8
|
685 |
+
*/
|
686 |
+
event_add_tax_band : function() {
|
687 |
+
WPSC_Settings_Page.Taxes.add_field('bands');
|
688 |
+
return false;
|
689 |
+
},
|
690 |
+
|
691 |
+
/**
|
692 |
+
* Delete a tax band field when "Delete" is clicked.
|
693 |
+
* @return {[type]}
|
694 |
+
*/
|
695 |
+
event_delete_tax_band : function() {
|
696 |
+
$(this).parents('.wpsc-tax-bands-row').remove();
|
697 |
+
return false;
|
698 |
+
},
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Add a field to the Tax Rate / Tax Band form, depending on the supplied type
|
702 |
+
* @param {String} Either "bands" or "rates" to specify the type of field
|
703 |
+
* @since 3.8.8
|
704 |
+
*/
|
705 |
+
add_field : function(type) {
|
706 |
+
var button_wrapper = $('#wpsc-add-tax-' + type);
|
707 |
+
count = $('.wpsc-tax-' + type + '-row').size(),
|
708 |
+
post_data = {
|
709 |
+
action : 'wpec_taxes_ajax',
|
710 |
+
wpec_taxes_action : 'wpec_taxes_build_' + type + '_form',
|
711 |
+
current_key : count,
|
712 |
+
nonce : WPSC_Settings_Page.nonce,
|
713 |
+
},
|
714 |
+
ajax_callback = function(response) {
|
715 |
+
button_wrapper.before(response).find('img').toggleClass('ajax-feedback-active');
|
716 |
+
};
|
717 |
+
|
718 |
+
button_wrapper.find('img').toggleClass('ajax-feedback-active');
|
719 |
+
$.post(ajaxurl, post_data, ajax_callback, 'html');
|
720 |
+
}
|
721 |
+
}
|
722 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_taxes', WPSC_Settings_Page.Taxes.event_init);
|
723 |
+
|
724 |
+
/**
|
725 |
+
* Shipping Tab
|
726 |
+
* @namespace
|
727 |
+
* @since 3.8.8
|
728 |
+
*/
|
729 |
+
WPSC_Settings_Page.Shipping = {
|
730 |
+
/**
|
731 |
+
* Event binding for Shipping tab.
|
732 |
+
* @since 3.8.8
|
733 |
+
*/
|
734 |
+
event_init : function() {
|
735 |
+
WPSC_Settings_Page.Shipping.wrapper = $('#options_shipping');
|
736 |
+
WPSC_Settings_Page.Shipping.table_rate = WPSC_Settings_Page.Shipping.wrapper.find('.table-rate');
|
737 |
+
WPSC_Settings_Page.Shipping.wrapper.
|
738 |
+
delegate('.edit-shipping-module' , 'click' , WPSC_Settings_Page.Shipping.event_edit_shipping_module).
|
739 |
+
delegate('.table-rate .add' , 'click' , WPSC_Settings_Page.Shipping.event_add_table_rate_layer).
|
740 |
+
delegate('.table-rate .delete' , 'click' , WPSC_Settings_Page.Shipping.event_delete_table_rate_layer).
|
741 |
+
delegate('.table-rate input[type="text"]', 'keypress', WPSC_Settings_Page.Shipping.event_enter_key_pressed);
|
742 |
+
},
|
743 |
+
|
744 |
+
/**
|
745 |
+
* When Enter key is pressed inside the table rate fields, it should either move
|
746 |
+
* focus to the next input field (just like tab), or create a new row and do that.
|
747 |
+
*
|
748 |
+
* This is to prevent accidental form submission.
|
749 |
+
*
|
750 |
+
* @param {Object} e Event object
|
751 |
+
* @since 3.8.8
|
752 |
+
*/
|
753 |
+
event_enter_key_pressed : function(e) {
|
754 |
+
var code = e.keyCode ? e.keyCode : e.which;
|
755 |
+
if (code == 13) {
|
756 |
+
var add_button = $(this).siblings('.actions').find('.add');
|
757 |
+
if (add_button.size() > 0) {
|
758 |
+
add_button.trigger('click', [true]);
|
759 |
+
} else {
|
760 |
+
$(this).closest('td').siblings('td').find('input').focus();
|
761 |
+
}
|
762 |
+
e.preventDefault();
|
763 |
+
}
|
764 |
+
},
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Add a layer row to the table rate form
|
768 |
+
* @param {Object} e Event object
|
769 |
+
* @param {Boolean} focus_on_new_row Defaults to false. Whether to automatically put focus on the first input of the new row.
|
770 |
+
* @since 3.8.8
|
771 |
+
*/
|
772 |
+
event_add_table_rate_layer : function(e, focus_on_new_row) {
|
773 |
+
if (typeof focus_on_new_row === 'undefined') {
|
774 |
+
focus_on_new_row = false;
|
775 |
+
}
|
776 |
+
|
777 |
+
var this_row = $(this).closest('tr'),
|
778 |
+
clone = this_row.clone();
|
779 |
+
|
780 |
+
clone.find('input').val('');
|
781 |
+
clone.find('.cell-wrapper').hide();
|
782 |
+
clone.insertAfter(this_row).find('.cell-wrapper').slideDown(150, function() {
|
783 |
+
if (focus_on_new_row) {
|
784 |
+
clone.find('input').eq(0).focus();
|
785 |
+
}
|
786 |
+
});
|
787 |
+
WPSC_Settings_Page.Shipping.refresh_alt_row();
|
788 |
+
return false;
|
789 |
+
},
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Delete a table rate layer row.
|
793 |
+
* @since 3.8.8
|
794 |
+
*/
|
795 |
+
event_delete_table_rate_layer : function() {
|
796 |
+
var this_row = $(this).closest('tr');
|
797 |
+
if (WPSC_Settings_Page.Shipping.wrapper.find('.table-rate tr:not(.js-warning)').size() == 1) {
|
798 |
+
this_row.find('input').val('');
|
799 |
+
this_row.fadeOut(150, function(){ $(this).fadeIn(150); } );
|
800 |
+
} else {
|
801 |
+
this_row.find('.cell-wrapper').slideUp(150, function(){
|
802 |
+
this_row.remove();
|
803 |
+
WPSC_Settings_Page.Shipping.refresh_alt_row();
|
804 |
+
});
|
805 |
+
}
|
806 |
+
return false;
|
807 |
+
},
|
808 |
+
|
809 |
+
/**
|
810 |
+
* Load Shipping Module settings form via AJAX when "Edit" is clicked.
|
811 |
+
* @since 3.8.8
|
812 |
+
*/
|
813 |
+
event_edit_shipping_module : function() {
|
814 |
+
var element = $(this),
|
815 |
+
shipping_module_id = element.data('module-id'),
|
816 |
+
spinner = element.siblings('.ajax-feedback'),
|
817 |
+
post_data = {
|
818 |
+
action : 'wpsc_shipping_module_settings_form',
|
819 |
+
'shipping_module_id' : shipping_module_id,
|
820 |
+
nonce : WPSC_Settings_Page.nonce
|
821 |
+
},
|
822 |
+
ajax_callback = function(response) {
|
823 |
+
if (history.pushState) {
|
824 |
+
var new_url = '?page=wpsc-settings&tab=' + WPSC_Settings_Page.current_tab + '&shipping_module_id=' + shipping_module_id;
|
825 |
+
history.pushState({url : new_url}, '', new_url);
|
826 |
+
}
|
827 |
+
spinner.toggleClass('ajax-feedback-active');
|
828 |
+
$('#wpsc-shipping-module-settings').replaceWith(response);
|
829 |
+
};
|
830 |
+
|
831 |
+
spinner.toggleClass('ajax-feedback-active');
|
832 |
+
$.post(ajaxurl, post_data, ajax_callback, 'html');
|
833 |
+
return false;
|
834 |
+
},
|
835 |
+
|
836 |
+
/**
|
837 |
+
* Refresh the zebra rows of the table
|
838 |
+
* @since 3.8.8
|
839 |
+
*/
|
840 |
+
refresh_alt_row : function() {
|
841 |
+
WPSC_Settings_Page.Shipping.wrapper.find('.alternate').removeClass('alternate');
|
842 |
+
WPSC_Settings_Page.Shipping.wrapper.find('#wpsc-shipping-module-settings tr:odd').addClass('alternate');
|
843 |
+
}
|
844 |
+
};
|
845 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_shipping', WPSC_Settings_Page.Shipping.event_init);
|
846 |
+
|
847 |
+
/**
|
848 |
+
* Payments Tab
|
849 |
+
* @namespace
|
850 |
+
* @since 3.8.8
|
851 |
+
*/
|
852 |
+
WPSC_Settings_Page.Gateway = {
|
853 |
+
event_init : function() {
|
854 |
+
var wrapper = $('#options_gateway');
|
855 |
+
wrapper.delegate('.edit-payment-module', 'click', WPSC_Settings_Page.Gateway.event_edit_payment_gateway);
|
856 |
+
},
|
857 |
+
|
858 |
+
event_edit_payment_gateway : function() {
|
859 |
+
var element = $(this),
|
860 |
+
payment_gateway_id = element.data('gateway-id'),
|
861 |
+
spinner = element.siblings('.ajax-feedback'),
|
862 |
+
post_data = {
|
863 |
+
action : 'wpsc_payment_gateway_settings_form',
|
864 |
+
'payment_gateway_id' : payment_gateway_id,
|
865 |
+
nonce : WPSC_Settings_Page.nonce
|
866 |
+
},
|
867 |
+
ajax_callback = function(response) {
|
868 |
+
if (history.pushState) {
|
869 |
+
var new_url = '?page=wpsc-settings&tab=' + WPSC_Settings_Page.current_tab + '&payment_gateway_id=' + payment_gateway_id;
|
870 |
+
history.pushState({url : new_url}, '', new_url);
|
871 |
+
}
|
872 |
+
spinner.toggleClass('ajax-feedback-active');
|
873 |
+
$('#wpsc-payment-gateway-settings-panel').replaceWith(response);
|
874 |
+
};
|
875 |
+
|
876 |
+
spinner.toggleClass('ajax-feedback-active');
|
877 |
+
$.post(ajaxurl, post_data, ajax_callback, 'html');
|
878 |
+
return false;
|
879 |
+
}
|
880 |
+
};
|
881 |
+
$(WPSC_Settings_Page).bind('wpsc_settings_tab_loaded_gateway', WPSC_Settings_Page.Gateway.event_init);
|
882 |
+
})(jQuery);
|
883 |
+
|
884 |
+
WPSC_Settings_Page.init();
|
wpsc-admin/js/sortable-table.js
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
var collapse_item = function(item) {
|
3 |
+
item.addClass('collapsed').hide(150);
|
4 |
+
|
5 |
+
var element = item, level, current_level = item.data('level'), id;
|
6 |
+
while (element.size() > 0) {
|
7 |
+
element = element.prev();
|
8 |
+
if (element.data('level') < current_level) {
|
9 |
+
item.data('parent', element.data('id'));
|
10 |
+
element.attr('rel', element.data('id')); // makes it easier to select using attribute
|
11 |
+
break;
|
12 |
+
}
|
13 |
+
}
|
14 |
+
};
|
15 |
+
|
16 |
+
var restrict_sortable_within_same_level = function(item, table) {
|
17 |
+
var current_level = item.data('level'), element, level;
|
18 |
+
table.find('.sortable').removeClass('sortable');
|
19 |
+
item.addClass('sortable');
|
20 |
+
|
21 |
+
element = item;
|
22 |
+
|
23 |
+
while (element.size() > 0) {
|
24 |
+
element = element.prev();
|
25 |
+
level = element.data('level');
|
26 |
+
if (level < current_level) {
|
27 |
+
break;
|
28 |
+
} else if (level > current_level) {
|
29 |
+
collapse_item(element);
|
30 |
+
} else if (level == current_level) {
|
31 |
+
element.addClass('sortable');
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
element = item;
|
36 |
+
while (element.size() > 0) {
|
37 |
+
element = element.next();
|
38 |
+
level = element.data('level');
|
39 |
+
if (level < current_level) {
|
40 |
+
break;
|
41 |
+
} else if (level > current_level) {
|
42 |
+
collapse_item(element);
|
43 |
+
} else if (level == current_level) {
|
44 |
+
element.addClass('sortable');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
table.sortable('refresh');
|
49 |
+
table.find('.alternate').removeClass('alternate');
|
50 |
+
table.find('tbody tr:not(.collapsed):even').addClass('alternate');
|
51 |
+
};
|
52 |
+
|
53 |
+
var event_sort_start = function(e, ui) {
|
54 |
+
var colspan = $(this).find('thead th:visible').size();
|
55 |
+
ui.placeholder.html('<td colspan="' + colspan + '"></td>').find('td').height(ui.item.height());
|
56 |
+
restrict_sortable_within_same_level(ui.item, $(this));
|
57 |
+
};
|
58 |
+
|
59 |
+
var event_sort_update = function(e, ui) {
|
60 |
+
var t = $(this);
|
61 |
+
t.find('tbody tr').addClass('sortable');
|
62 |
+
t.find('tr.collapsed').each(function(){
|
63 |
+
var item = $(this),
|
64 |
+
parent = item.siblings('[rel="' + item.data('parent') + '"]');
|
65 |
+
item.insertAfter(parent).removeClass('collapsed').show(150);
|
66 |
+
});
|
67 |
+
t.find('.alternate').removeClass('alternate');
|
68 |
+
t.find('tbody tr:even').addClass('alternate');
|
69 |
+
};
|
70 |
+
|
71 |
+
var fix_helper_width = function(e, tr) {
|
72 |
+
var row = tr.clone().width(tr.width());
|
73 |
+
row.children().each(function(index){
|
74 |
+
var original = tr.children().eq(index), old_html = $(this).html();
|
75 |
+
$(this).wrapInner('<div class="cell-wrapper"></div>').find('.cell-wrapper').width(original.width());
|
76 |
+
});
|
77 |
+
return row;
|
78 |
+
};
|
79 |
+
|
80 |
+
$.fn.wpsc_sortable_table = function(user_options) {
|
81 |
+
var options = {
|
82 |
+
update : function(){}
|
83 |
+
};
|
84 |
+
$.extend(options, user_options);
|
85 |
+
|
86 |
+
$(this).each(function(){
|
87 |
+
var t = $(this);
|
88 |
+
t.find('tr').addClass('sortable');
|
89 |
+
t.sortable({
|
90 |
+
axix : 'y',
|
91 |
+
items : 'tr.sortable',
|
92 |
+
containment : t,
|
93 |
+
placeholder : 'wpsc-sortable-table-placeholder',
|
94 |
+
helper : fix_helper_width,
|
95 |
+
cursor : 'move',
|
96 |
+
stop : options.stop,
|
97 |
+
start : event_sort_start,
|
98 |
+
update : event_sort_update
|
99 |
+
});
|
100 |
+
});
|
101 |
+
};
|
102 |
+
})(jQuery);
|
wpsc-admin/js/variations.js
CHANGED
@@ -1,62 +1,238 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
*/
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
.variation_checkboxes
|
9 |
-
|
10 |
-
.
|
11 |
-
.
|
12 |
-
.variation_checkbox input
|
13 |
|
14 |
-
.
|
15 |
-
.
|
16 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
} else {
|
35 |
-
|
36 |
-
jQuery('div.variation', variation_set).hide();
|
37 |
}
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
var
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
} else {
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
});
|
58 |
-
|
59 |
-
});
|
60 |
|
|
|
|
|
|
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
var new_variation_set_count = 0;
|
|
|
3 |
|
4 |
+
$(function(){
|
5 |
+
var table = $('body.edit-tags-php .wp-list-table');
|
6 |
+
table.find('tbody tr').each(function(){
|
7 |
+
var t = $(this),
|
8 |
+
id = t.attr('id').replace(/[^0-9]+/g, '');
|
9 |
+
t.data('level', WPSC_Term_List_Levels[id]);
|
10 |
+
t.data('id', id);
|
11 |
+
});
|
12 |
|
13 |
+
table.wpsc_sortable_table({
|
14 |
+
stop : variation_sort
|
15 |
+
});
|
16 |
|
17 |
+
$('.variation_checkboxes').delegate('.variation-set', 'click', event_toggle_checkboxes).
|
18 |
+
delegate('a.expand', 'click', event_toggle_children).
|
19 |
+
delegate('.selectit input:checkbox', 'click', event_display_apply_variations).
|
20 |
+
delegate('.children input:checkbox', 'click', event_toggle_parent);
|
|
|
21 |
|
22 |
+
$('a.update_variations_action').bind('click', event_apply_variations);
|
23 |
+
$('a.add_variation_set_action').bind('click', event_add_new_variation_set);
|
24 |
+
$('#add-new-variation-set .button').bind('click', event_variation_set_add);
|
25 |
+
$('#add-new-variation-set input[type="text"]').bind('keypress', event_variation_set_inputs_keypress).
|
26 |
+
bind('focus', event_variation_set_inputs_focus).
|
27 |
+
bind('blur', event_variation_set_inputs_blur);
|
28 |
+
});
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Save variation sort order when user has finished dragging & dropping
|
32 |
+
* @param {Object} e Event Object
|
33 |
+
* @param {Object} ui UI Object
|
34 |
+
* @since 3.8.8
|
35 |
+
*/
|
36 |
+
var variation_sort = function(e, ui){
|
37 |
+
var order = $(this).sortable('toArray'),
|
38 |
+
data = {
|
39 |
+
action: 'variation_sort_order',
|
40 |
+
sort_order: order,
|
41 |
+
parent_id: 0
|
42 |
+
};
|
43 |
+
jQuery.post(ajaxurl, data);
|
44 |
+
}
|
45 |
|
46 |
+
/**
|
47 |
+
* Save new variation set using AJAX
|
48 |
+
* @since 3.8.8
|
49 |
+
*/
|
50 |
+
var event_variation_set_add = function() {
|
51 |
+
var form = $('#add-new-variation-set');
|
52 |
|
53 |
+
form.find('.error').removeClass('error');
|
54 |
+
|
55 |
+
form.find('input[type="text"]').each(function(){
|
56 |
+
var t = $(this);
|
57 |
+
if (t.val() == '') {
|
58 |
+
t.parent().addClass('error');
|
59 |
+
}
|
60 |
+
});
|
61 |
|
62 |
+
if (form.find('.error').size() === 0) {
|
63 |
+
var spinner = $(this).siblings('.ajax-feedback'),
|
64 |
+
post_data = {
|
65 |
+
action : 'wpsc_add_variation_set',
|
66 |
+
variation_set : $('#new-variation-set-name').val(),
|
67 |
+
variants : $('#new-variants').val(),
|
68 |
+
post_id : $('input[name="post_ID"]').val()
|
69 |
+
},
|
70 |
+
ajax_callback = function(response) {
|
71 |
+
var checklist, color, set_id, existing_set;
|
72 |
+
if (response != '-1') {
|
73 |
+
checklist = $('.variation_checkboxes');
|
74 |
+
response = $(response);
|
75 |
+
set_id = response.attr('id');
|
76 |
+
existing_set = checklist.find('#' + set_id);
|
77 |
+
if (existing_set.size() > 0) {
|
78 |
+
existing_set.find('.children').append(response.find('.children .ajax'));
|
79 |
+
} else {
|
80 |
+
checklist.append(response);
|
81 |
+
}
|
82 |
|
83 |
+
color = checklist.find('li').css('backgroundColor') || '#FFFFFF';
|
84 |
+
checklist.find('.ajax').
|
85 |
+
animate({ backgroundColor: '#FFFF33' }, 'fast').
|
86 |
+
animate({ backgroundColor: color }, 'fast', function(){
|
87 |
+
$(this).css('backgroundColor', 'transparent');
|
88 |
+
}).
|
89 |
+
removeClass('ajax');
|
90 |
+
}
|
91 |
+
form.hide().find('input:text').val('');
|
92 |
+
form.find('label').show().css('opacity', '1');
|
93 |
+
spinner.toggleClass('ajax-feedback-active');
|
94 |
+
};
|
95 |
+
|
96 |
+
spinner.toggleClass('ajax-feedback-active');
|
97 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
98 |
+
|
99 |
+
}
|
100 |
|
101 |
+
return false;
|
102 |
+
};
|
103 |
|
104 |
+
/**
|
105 |
+
* Dim the new variation set inputs' labels when focused.
|
106 |
+
* @since 3.8.8
|
107 |
+
*/
|
108 |
+
var event_variation_set_inputs_focus = function() {
|
109 |
+
$(this).siblings('label').animate({opacity:0.5}, 150);
|
110 |
+
};
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Restore opacity to the "new variation set" inputs' labels when blurred.
|
114 |
+
* @since 3.8.8
|
115 |
+
*/
|
116 |
+
var event_variation_set_inputs_blur = function() {
|
117 |
+
var t = $(this);
|
118 |
+
if (t.val() == '') {
|
119 |
+
t.siblings('label').show().animate({opacity:1}, 150);
|
120 |
+
}
|
121 |
+
};
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Remove class "error" when something is typed into the new variation set textboxes
|
125 |
+
* @since 3.8.8
|
126 |
+
*/
|
127 |
+
var event_variation_set_inputs_keypress = function(e) {
|
128 |
+
var code = e.keyCode ? e.keyCode : e.which;
|
129 |
+
if (code == 13) {
|
130 |
+
$('#add-new-variation-set .button').trigger('click');
|
131 |
+
e.preventDefault();
|
132 |
} else {
|
133 |
+
$(this).siblings('label').hide().removeClass('error');
|
|
|
134 |
}
|
135 |
+
};
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Show the Add Variation Set form and focus on the first text field
|
139 |
+
* @since 3.8.8
|
140 |
+
*/
|
141 |
+
var event_add_new_variation_set = function() {
|
142 |
+
var t = $(this);
|
143 |
+
$('#add-new-variation-set').show().find('#new-variation-set-name').focus();
|
144 |
+
};
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Save variation combinations via AJAX
|
148 |
+
* @since 3.8.8
|
149 |
+
*/
|
150 |
+
var event_apply_variations = function() {
|
151 |
+
var t = $(this),
|
152 |
+
spinner = t.siblings('.ajax-feedback'),
|
153 |
+
boxes = $('.variation_checkboxes input:checked'),
|
154 |
+
values = [],
|
155 |
+
post_data = {
|
156 |
+
action : 'wpsc_update_variations',
|
157 |
+
description : $('#content_ifr').contents().find('body').html(),
|
158 |
+
additional_description : $('textareaa#additional_description').text(),
|
159 |
+
name : $('input#title').val(),
|
160 |
+
product_id : $('input#product_id').val()
|
161 |
+
},
|
162 |
+
ajax_callback = function(response){
|
163 |
+
$('div#wpsc_product_variation_forms table.widefat tbody').html(response);
|
164 |
+
spinner.toggleClass('ajax-feedback-active');
|
165 |
+
};
|
166 |
+
|
167 |
+
boxes.each(function(){
|
168 |
+
var t = $(this);
|
169 |
+
post_data[t.attr('name')] = t.val();
|
170 |
+
});
|
171 |
+
|
172 |
+
post_data.edit_var_val = values;
|
173 |
+
spinner.toggleClass('ajax-feedback-active');
|
174 |
+
|
175 |
+
$.post(ajaxurl, post_data, ajax_callback);
|
176 |
+
|
177 |
+
return false;
|
178 |
+
};
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Deselect or Select all children variations when variation set is ticked.
|
182 |
+
* @since 3.8.8
|
183 |
+
*/
|
184 |
+
var event_toggle_checkboxes = function() {
|
185 |
+
var t = $(this), checked;
|
186 |
+
|
187 |
+
if (t.is(':checked')) {
|
188 |
+
checked = true;
|
189 |
} else {
|
190 |
+
checked = false;
|
191 |
+
}
|
192 |
+
|
193 |
+
t.closest('li').find('.children input:checkbox').each(function(){
|
194 |
+
this.checked = checked;
|
195 |
+
});
|
|
|
|
|
|
|
196 |
|
197 |
+
if (checked !== t.closest('li').hasClass('expanded'))
|
198 |
+
t.parent().siblings('.expand').trigger('click');
|
199 |
+
};
|
200 |
|
201 |
+
/**
|
202 |
+
* Show children variant checkboxes when the triangle is clicked.
|
203 |
+
* @since 3.8.8
|
204 |
+
*/
|
205 |
+
var event_toggle_children = function() {
|
206 |
+
var t = $(this);
|
207 |
+
t.siblings('ul').slideToggle(150);
|
208 |
+
t.closest('li').toggleClass('expanded');
|
209 |
+
return false;
|
210 |
+
};
|
211 |
|
212 |
+
/**
|
213 |
+
* Show the update variation button.
|
214 |
+
* @since 3.8.8
|
215 |
+
*/
|
216 |
+
var event_display_apply_variations = function() {
|
217 |
+
$('.update-variations').fadeIn(150);
|
218 |
+
};
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Deselect the variation set if none of its variants are selected.
|
222 |
+
* Or select the variation set when at least one of its variants is selected.
|
223 |
+
* @since 3.8.8
|
224 |
+
*/
|
225 |
+
var event_toggle_parent = function() {
|
226 |
+
var t = $(this),
|
227 |
+
parent = t.closest('.children').parent();
|
228 |
+
parent_checkbox = parent.find('.variation-set'),
|
229 |
+
checked = this.checked;
|
230 |
+
|
231 |
+
if (this.checked) {
|
232 |
+
parent_checkbox[0].checked = true;
|
233 |
+
} else if (parent.find('.children input:checked').size() == 0) {
|
234 |
+
parent_checkbox[0].checked = false;
|
235 |
+
parent.find('.expand').trigger('click');
|
236 |
+
}
|
237 |
+
};
|
238 |
+
})(jQuery);
|
wpsc-admin/settings-page.php
ADDED
@@ -0,0 +1,590 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP e-Commerce Settings Page API.
|
4 |
+
*
|
5 |
+
* Third-party plugin / theme developers can add their own tabs to WPEC store settings page.
|
6 |
+
*
|
7 |
+
* Let's say you want to create a tab for your plugin called "Recommendation System", for example.
|
8 |
+
* You first need to register the tab ID and title like this:
|
9 |
+
*
|
10 |
+
* <code>
|
11 |
+
* function my_plugin_settings_tabs( $settings_page ) {
|
12 |
+
* $settings_page->register_tab( 'recommendation_system', 'Recommendation System' );
|
13 |
+
* }
|
14 |
+
* add_action( 'wpsc_load_settings_tab_class', 'my_plugin_settings_tabs', 10, 1 );
|
15 |
+
* </code>
|
16 |
+
*
|
17 |
+
* Note that you need to hook into 'wpsc_load_settings_tab_class' to do this.
|
18 |
+
*
|
19 |
+
* The next step is to create a class for your tab which inherits from the base 'WPSC_Settings_Tab'.
|
20 |
+
* The name of the class needs to follow this convention: all the words have to be capitalized and
|
21 |
+
* separated with an underscore, and prefixed with 'WPSC_Settings_Tab_'.
|
22 |
+
*
|
23 |
+
* In our example, because we registered our tab ID as 'recommendation_system', the class name should
|
24 |
+
* be 'WPSC_Settings_Tab_Recommendation_System'.
|
25 |
+
*
|
26 |
+
* <code>
|
27 |
+
* class WPSC_Settings_Tab_Recommendation_System extends WPSC_Settings_Tab
|
28 |
+
* {
|
29 |
+
* public function display() {
|
30 |
+
* echo '<h3>Recommendation System Settings</h3>';
|
31 |
+
* // output your tab content here
|
32 |
+
* }
|
33 |
+
* }
|
34 |
+
* </code>
|
35 |
+
*
|
36 |
+
* All tab has to implement a method `display()` which outputs the HTML content for the tab.
|
37 |
+
* You don't need to output the <form> element because it will be done for you.
|
38 |
+
*
|
39 |
+
* When outputting your form fields for the tab, name the fields 'wpsc_options[$your_option_name]'
|
40 |
+
* so that they will automatically get saved to the database when the user submits the form. E.g.:
|
41 |
+
*
|
42 |
+
* <code>
|
43 |
+
* <input type="text" value="something" name="wpsc_options[some_option]" />
|
44 |
+
* </code>
|
45 |
+
*
|
46 |
+
* If you need to handle the form submission yourself, create a method in your tab class called
|
47 |
+
* 'callback_submit_options()'. Then process your submitted fields there.
|
48 |
+
*
|
49 |
+
* <code>
|
50 |
+
* class WPSC_Settings_Tab_Recommendation_System extends WPSC_Settings_Tab
|
51 |
+
* {
|
52 |
+
* // ...
|
53 |
+
* public function callback_submit_options() {
|
54 |
+
* if ( isset( $_POST['my_option'] ) )
|
55 |
+
* update_option( 'my_option', $_POST['my_option'] );
|
56 |
+
* }
|
57 |
+
* // ...
|
58 |
+
* }
|
59 |
+
* </code>
|
60 |
+
*
|
61 |
+
* @package wp-e-commerce
|
62 |
+
* @subpackage settings-api
|
63 |
+
*/
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Abstract class for setting tabs
|
67 |
+
*
|
68 |
+
* @abstract
|
69 |
+
* @since 3.8.8
|
70 |
+
* @package wp-e-commerce
|
71 |
+
* @subpackage settings-api
|
72 |
+
*/
|
73 |
+
abstract class WPSC_Settings_Tab
|
74 |
+
{
|
75 |
+
/**
|
76 |
+
* Display the content of the tab. This function has to be overridden.
|
77 |
+
*
|
78 |
+
* @since 3.8.8
|
79 |
+
* @abstract
|
80 |
+
* @access public
|
81 |
+
*/
|
82 |
+
abstract public function display();
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Constructor
|
86 |
+
*
|
87 |
+
* @since 3.8.8
|
88 |
+
* @access public
|
89 |
+
*/
|
90 |
+
public function __construct() {}
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Settings Page class. Singleton pattern.
|
95 |
+
*
|
96 |
+
* @since 3.8.8
|
97 |
+
* @package wp-e-commerce
|
98 |
+
* @subpackage settings-api
|
99 |
+
* @final
|
100 |
+
*/
|
101 |
+
final class WPSC_Settings_Page
|
102 |
+
{
|
103 |
+
/**
|
104 |
+
* @staticvar object The active object instance
|
105 |
+
* @since 3.8.8
|
106 |
+
* @access private
|
107 |
+
*/
|
108 |
+
private static $instance;
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @staticvar array An array of default tabs containing pairs of id => title
|
112 |
+
* @since 3.8.8
|
113 |
+
* @access private
|
114 |
+
*/
|
115 |
+
private static $default_tabs;
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Initialize default tabs and add necessary action hooks.
|
119 |
+
*
|
120 |
+
* @since 3.8.8
|
121 |
+
*
|
122 |
+
* @uses add_action() Attaches to wpsc_register_settings_tabs hook
|
123 |
+
* @uses add_action() Attaches to wpsc_load_settings_tab_class hook
|
124 |
+
*
|
125 |
+
* @see wpsc_load_settings_page()
|
126 |
+
*
|
127 |
+
* @access public
|
128 |
+
* @static
|
129 |
+
*/
|
130 |
+
public static function init() {
|
131 |
+
self::$default_tabs = array(
|
132 |
+
'general' => _x( 'General' , 'General settings tab in Settings->Store page' , 'wpsc' ),
|
133 |
+
'presentation' => _x( 'Presentation', 'Presentation settings tab in Settings->Store page', 'wpsc' ),
|
134 |
+
'admin' => _x( 'Admin' , 'Admin settings tab in Settings->Store page' , 'wpsc' ),
|
135 |
+
'taxes' => _x( 'Taxes' , 'Taxes settings tab in Settings->Store page' , 'wpsc' ),
|
136 |
+
'shipping' => _x( 'Shipping' , 'Shipping settings tab in Settings->Store page' , 'wpsc' ),
|
137 |
+
'gateway' => _x( 'Payments' , 'Payments settings tab in Settings->Store page' , 'wpsc' ),
|
138 |
+
'checkout' => _x( 'Checkout' , 'Checkout settings tab in Settings->Store page' , 'wpsc' ),
|
139 |
+
'marketing' => _x( 'Marketing' , 'Marketing settings tab in Settings->Store page' , 'wpsc' ),
|
140 |
+
'import' => _x( 'Import' , 'Import settings tab in Settings->Store page' , 'wpsc' )
|
141 |
+
);
|
142 |
+
|
143 |
+
add_action( 'wpsc_register_settings_tabs' , array( 'WPSC_Settings_Page', 'register_default_tabs' ), 1 );
|
144 |
+
add_action( 'wpsc_load_settings_tab_class', array( 'WPSC_Settings_Page', 'load_default_tab_class' ), 1 );
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get active object instance
|
149 |
+
*
|
150 |
+
* @since 3.8.8
|
151 |
+
*
|
152 |
+
* @access public
|
153 |
+
* @static
|
154 |
+
* @return object
|
155 |
+
*/
|
156 |
+
public static function get_instance() {
|
157 |
+
if ( ! self::$instance ) {
|
158 |
+
self::$instance = new WPSC_Settings_Page();
|
159 |
+
}
|
160 |
+
|
161 |
+
return self::$instance;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Automatically load tab classes inside wpsc-admin/includes/settings-tabs.
|
166 |
+
*
|
167 |
+
* @since 3.8.8
|
168 |
+
*
|
169 |
+
* @see WPSC_Settings_Page::init()
|
170 |
+
*
|
171 |
+
* @uses WPSC_Settings_Page::get_current_tab_id() Gets current tab ID
|
172 |
+
*
|
173 |
+
* @access public
|
174 |
+
* @param object $page_instance The WPSC_Settings_Page instance
|
175 |
+
* @static
|
176 |
+
*/
|
177 |
+
public static function load_default_tab_class( $page_instance ) {
|
178 |
+
$current_tab_id = $page_instance->get_current_tab_id();
|
179 |
+
if ( array_key_exists( $current_tab_id, self::$default_tabs ) ) {
|
180 |
+
require_once( 'includes/settings-tabs/' . $current_tab_id . '.php' );
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Register the default tabs' ids and titles.
|
186 |
+
*
|
187 |
+
* @since 3.8.8
|
188 |
+
*
|
189 |
+
* @see WPSC_Settings_Page::init()
|
190 |
+
*
|
191 |
+
* @uses WPSC_Settings_Page::register_tab() Registers default tabs' idds and titles.
|
192 |
+
*
|
193 |
+
* @access public
|
194 |
+
* @param object $page_instance The WPSC_Settings_Page instance
|
195 |
+
* @static
|
196 |
+
*/
|
197 |
+
public static function register_default_tabs( $page_instance ) {
|
198 |
+
foreach ( self::$default_tabs as $id => $title ) {
|
199 |
+
$page_instance->register_tab( $id, $title );
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Current tab ID
|
205 |
+
* @since 3.8.8
|
206 |
+
* @access private
|
207 |
+
* @var string
|
208 |
+
*/
|
209 |
+
private $current_tab_id;
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Current tab object
|
213 |
+
* @since 3.8.8
|
214 |
+
* @access private
|
215 |
+
* @var object
|
216 |
+
*/
|
217 |
+
private $current_tab;
|
218 |
+
|
219 |
+
/**
|
220 |
+
* An array containing registered tabs
|
221 |
+
* @since 3.8.8
|
222 |
+
* @access private
|
223 |
+
* @var array
|
224 |
+
*/
|
225 |
+
private $tabs;
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Constructor
|
229 |
+
*
|
230 |
+
* @since 3.8.8
|
231 |
+
*
|
232 |
+
* @uses do_action() Calls wpsc_register_settings_tabs hook.
|
233 |
+
* @uses apply_filters Calls wpsc_settings_tabs hook.
|
234 |
+
* @uses WPSC_Settings_Page::set_current_tab() Set current tab to the specified ID
|
235 |
+
*
|
236 |
+
* @access public
|
237 |
+
* @param string $tab_id Optional. If specified then the current tab will be set to this ID.
|
238 |
+
*/
|
239 |
+
public function __construct( $tab_id = null ) {
|
240 |
+
do_action( 'wpsc_register_settings_tabs', $this );
|
241 |
+
$this->tabs = apply_filters( 'wpsc_settings_tabs', $this->tabs );
|
242 |
+
$this->set_current_tab( $tab_id );
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Returns the current tab object
|
247 |
+
*
|
248 |
+
* @since 3.8.8
|
249 |
+
*
|
250 |
+
* @uses do_action() Calls wpsc_load_settings_tab_class hook.
|
251 |
+
* @uses WPSC_Settings_Tab() constructing a new settings tab object
|
252 |
+
*
|
253 |
+
* @access public
|
254 |
+
* @return object WPSC_Settings_Tab object
|
255 |
+
*/
|
256 |
+
public function get_current_tab() {
|
257 |
+
if ( ! $this->current_tab ) {
|
258 |
+
do_action( 'wpsc_load_settings_tab_class', $this );
|
259 |
+
$class_name = ucwords( str_replace( array( '-', '_' ), ' ', $this->current_tab_id ) );
|
260 |
+
$class_name = str_replace( ' ', '_', $class_name );
|
261 |
+
$class_name = 'WPSC_Settings_Tab_' . $class_name;
|
262 |
+
if ( class_exists( $class_name ) ) {
|
263 |
+
$reflection = new ReflectionClass( $class_name );
|
264 |
+
$this->current_tab = $reflection->newInstance();
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
return $this->current_tab;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Get current tab ID
|
273 |
+
* @since 3.8.8
|
274 |
+
* @access public
|
275 |
+
* @return string
|
276 |
+
*/
|
277 |
+
public function get_current_tab_id() {
|
278 |
+
return $this->current_tab_id;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Set current tab to the specified tab ID.
|
283 |
+
*
|
284 |
+
* @since 3.8.8
|
285 |
+
*
|
286 |
+
* @uses check_admin_referer() Prevent CSRF
|
287 |
+
* @uses WPSC_Settings_Page::get_current_tab() Initializes the current tab object.
|
288 |
+
* @uses WPSC_Settings_Page::save_options() Saves the submitted options to the database.
|
289 |
+
* @uses WPSC_Settings_Tab::callback_submit_options() If this method exists in the tab object, it will be called after WPSC_Settings_Page::save_options().
|
290 |
+
*
|
291 |
+
* @access public
|
292 |
+
* @param string $tab_id Optional. The Tab ID. If this is not specified, the $_GET['tab'] variable will be used. If that variable also does not exists, the first tab will be used.
|
293 |
+
*/
|
294 |
+
public function set_current_tab( $tab_id = null ) {
|
295 |
+
if ( ! $tab_id ) {
|
296 |
+
if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->tabs ) )
|
297 |
+
$this->current_tab_id = $_GET['tab'];
|
298 |
+
else
|
299 |
+
$this->current_tab_id = array_shift( array_keys( $this->tabs ) );
|
300 |
+
} else {
|
301 |
+
$this->current_tab_id = $tab_id;
|
302 |
+
}
|
303 |
+
|
304 |
+
$this->current_tab = $this->get_current_tab();
|
305 |
+
|
306 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'submit_options' ) ) {
|
307 |
+
check_admin_referer( 'update-options', 'wpsc-update-options' );
|
308 |
+
$this->save_options();
|
309 |
+
if ( is_callable( array( $this->current_tab, 'callback_submit_options' ) ) )
|
310 |
+
$this->current_tab->callback_submit_options();
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Register a tab's ID and title
|
316 |
+
*
|
317 |
+
* @since 3.8.8
|
318 |
+
*
|
319 |
+
* @access public
|
320 |
+
* @param string $id Tab ID.
|
321 |
+
* @param string $title Tab title.
|
322 |
+
*/
|
323 |
+
public function register_tab( $id, $title ) {
|
324 |
+
$this->tabs[$id] = $title;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Get an array containing tabs' IDs and titles
|
329 |
+
*
|
330 |
+
* @since 3.8.8
|
331 |
+
*
|
332 |
+
* @access public
|
333 |
+
* @return array
|
334 |
+
*/
|
335 |
+
public function get_tabs() {
|
336 |
+
return $this->tabs;
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Get the HTML class of a tab.
|
341 |
+
* @since 3.8.8
|
342 |
+
* @param string $id Tab ID
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
private function tab_class( $id ) {
|
346 |
+
$class = 'nav-tab';
|
347 |
+
if ( $id == $this->current_tab_id )
|
348 |
+
$class .= ' nav-tab-active';
|
349 |
+
return $class;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Get the form's submit (action) url.
|
354 |
+
* @since 3.8.8
|
355 |
+
* @access private
|
356 |
+
* @return string
|
357 |
+
*/
|
358 |
+
private function submit_url() {
|
359 |
+
$location = add_query_arg( 'tab', $this->current_tab_id );
|
360 |
+
return $location;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Output HTML of tab navigation.
|
365 |
+
* @since 3.8.8
|
366 |
+
* @access public
|
367 |
+
* @uses esc_html Prevents xss
|
368 |
+
*/
|
369 |
+
public function output_tabs() {
|
370 |
+
?>
|
371 |
+
<h2 class="nav-tab-wrapper">
|
372 |
+
<?php foreach ( $this->tabs as $id => $title ): ?>
|
373 |
+
<a data-tab-id="<?php echo esc_attr( $id ); ?>" class="<?php echo $this->tab_class( $id ); ?>" href="<?php echo esc_attr( '?page=wpsc-settings&tab=' . $id ); ?>"><?php echo esc_html( $this->tabs[$id] ); ?></a>
|
374 |
+
<?php endforeach ?>
|
375 |
+
</h2>
|
376 |
+
<?php
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Display the current tab.
|
381 |
+
* @since 3.8.8
|
382 |
+
* @uses do_action() Calls wpsc_{$current_tab_id}_settings_page hook.
|
383 |
+
* @uses WPSC_Settings_Tab::display() Displays the tab.
|
384 |
+
* @access public
|
385 |
+
*/
|
386 |
+
public function display_current_tab() {
|
387 |
+
?>
|
388 |
+
<div id="options_<?php echo esc_attr( $this->current_tab_id ); ?>">
|
389 |
+
<?php
|
390 |
+
if ( is_callable( array( $this->current_tab, 'display' ) ) ) {
|
391 |
+
$this->current_tab->display();
|
392 |
+
}
|
393 |
+
?>
|
394 |
+
|
395 |
+
<?php do_action('wpsc_' . $this->current_tab_id . '_settings_page'); ?>
|
396 |
+
</div>
|
397 |
+
<?php
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Display the settings page.
|
402 |
+
* @since 3.8.8
|
403 |
+
* @uses esc_html_e() Sanitize HTML
|
404 |
+
* @uses esc_attr() Sanitize HTML attributes
|
405 |
+
* @uses wp_nonce_field() Prevent CSRF
|
406 |
+
* @uses WPSC_Settings_Page::output_tabs() Display tab navigation.
|
407 |
+
* @uses WPSC_Settings_Page::display_current_tab() Display current tab.
|
408 |
+
* @access public
|
409 |
+
*/
|
410 |
+
public function display() {
|
411 |
+
?>
|
412 |
+
<div id="wpsc_options" class="wrap">
|
413 |
+
<div id="icon_card" class="icon32"></div>
|
414 |
+
<h2 id="wpsc-settings-page-title">
|
415 |
+
<?php esc_html_e( 'Store Settings', 'wpsc' ); ?>
|
416 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
|
417 |
+
</h2>
|
418 |
+
<?php $this->output_tabs(); ?>
|
419 |
+
<div id='wpsc_options_page'>
|
420 |
+
<form method='post' action='<?php echo esc_attr( $this->submit_url() ); ?>' id='wpsc-settings-form'>
|
421 |
+
<?php $this->display_current_tab(); ?>
|
422 |
+
<div class="submit">
|
423 |
+
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
424 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
425 |
+
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'wpsc' ); ?>" name="updateoption" />
|
426 |
+
</div>
|
427 |
+
</form>
|
428 |
+
</div>
|
429 |
+
</div>
|
430 |
+
<?php
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Save submitted options to the database.
|
435 |
+
* @since 3.8.8
|
436 |
+
* @uses check_admin_referer() Prevents CSRF.
|
437 |
+
* @uses update_option() Saves options to the database.
|
438 |
+
* @uses wpdb::query() Queries the database.
|
439 |
+
* @uses wpdb::get_col() Queries the database.
|
440 |
+
* @access public
|
441 |
+
*/
|
442 |
+
private function save_options( $selected='' ) {
|
443 |
+
global $wpdb, $wpsc_gateways;
|
444 |
+
$updated = 0;
|
445 |
+
|
446 |
+
//This is to change the Overall target market selection
|
447 |
+
check_admin_referer( 'update-options', 'wpsc-update-options' );
|
448 |
+
if ( isset( $_POST['change-settings'] ) ) {
|
449 |
+
if ( isset( $_POST['wpsc_also_bought'] ) && $_POST['wpsc_also_bought'] == 'on' )
|
450 |
+
update_option( 'wpsc_also_bought', 1 );
|
451 |
+
else
|
452 |
+
update_option( 'wpsc_also_bought', 0 );
|
453 |
+
|
454 |
+
if ( isset( $_POST['display_find_us'] ) && $_POST['display_find_us'] == 'on' )
|
455 |
+
update_option( 'display_find_us', 1 );
|
456 |
+
else
|
457 |
+
update_option( 'display_find_us', 0 );
|
458 |
+
|
459 |
+
if ( isset( $_POST['wpsc_share_this'] ) && $_POST['wpsc_share_this'] == 'on' )
|
460 |
+
update_option( 'wpsc_share_this', 1 );
|
461 |
+
else
|
462 |
+
update_option( 'wpsc_share_this', 0 );
|
463 |
+
|
464 |
+
}
|
465 |
+
if (empty($_POST['countrylist2']) && !empty($_POST['wpsc_options']['currency_sign_location']))
|
466 |
+
$selected = 'none';
|
467 |
+
|
468 |
+
if ( !isset( $_POST['countrylist2'] ) )
|
469 |
+
$_POST['countrylist2'] = '';
|
470 |
+
if ( !isset( $_POST['country_id'] ) )
|
471 |
+
$_POST['country_id'] = '';
|
472 |
+
if ( !isset( $_POST['country_tax'] ) )
|
473 |
+
$_POST['country_tax'] = '';
|
474 |
+
|
475 |
+
if ( $_POST['countrylist2'] != null || !empty($selected) ) {
|
476 |
+
$AllSelected = false;
|
477 |
+
if ( $selected == 'all' ) {
|
478 |
+
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '1'" );
|
479 |
+
$AllSelected = true;
|
480 |
+
}
|
481 |
+
if ( $selected == 'none' ) {
|
482 |
+
$wpdb->query( "UPDATE `" . WPSC_TABLE_CURRENCY_LIST . "` SET visible = '0'" );
|
483 |
+
$AllSelected = true;
|
484 |
+
}
|
485 |
+
if ( $AllSelected != true ) {
|
486 |
+
$countrylist = $wpdb->get_col( "SELECT id FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC " );
|
487 |
+
//find the countries not selected
|
488 |
+
$unselectedCountries = array_diff( $countrylist, $_POST['countrylist2'] );
|
489 |
+
foreach ( $unselectedCountries as $unselected ) {
|
490 |
+
$wpdb->update(
|
491 |
+
WPSC_TABLE_CURRENCY_LIST,
|
492 |
+
array(
|
493 |
+
'visible' => 0
|
494 |
+
),
|
495 |
+
array(
|
496 |
+
'id' => $unselected
|
497 |
+
),
|
498 |
+
'%d',
|
499 |
+
'%d'
|
500 |
+
);
|
501 |
+
}
|
502 |
+
|
503 |
+
//find the countries that are selected
|
504 |
+
$selectedCountries = array_intersect( $countrylist, $_POST['countrylist2'] );
|
505 |
+
foreach ( $selectedCountries as $selected ) {
|
506 |
+
$wpdb->update(
|
507 |
+
WPSC_TABLE_CURRENCY_LIST,
|
508 |
+
array(
|
509 |
+
'visible' => 1
|
510 |
+
),
|
511 |
+
array(
|
512 |
+
'id' => $selected
|
513 |
+
),
|
514 |
+
'%d',
|
515 |
+
'%d'
|
516 |
+
);
|
517 |
+
}
|
518 |
+
}
|
519 |
+
}
|
520 |
+
$previous_currency = get_option( 'currency_type' );
|
521 |
+
|
522 |
+
//To update options
|
523 |
+
if ( isset( $_POST['wpsc_options'] ) ) {
|
524 |
+
// make sure stock keeping time is a number
|
525 |
+
if ( isset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] ) ) {
|
526 |
+
$skt =& $_POST['wpsc_options']['wpsc_stock_keeping_time']; // I hate repeating myself
|
527 |
+
$skt = (float) $skt;
|
528 |
+
if ( $skt <= 0 || ( $skt < 1 && $_POST['wpsc_options']['wpsc_stock_keeping_interval'] == 'hour' ) ) {
|
529 |
+
unset( $_POST['wpsc_options']['wpsc_stock_keeping_time'] );
|
530 |
+
unset( $_POST['wpsc_options']['wpsc_stock_keeping_interval'] );
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
foreach ( $_POST['wpsc_options'] as $key => $value ) {
|
535 |
+
if ( $value != get_option( $key ) ) {
|
536 |
+
update_option( $key, $value );
|
537 |
+
$updated++;
|
538 |
+
|
539 |
+
}
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
if ( $previous_currency != get_option( 'currency_type' ) ) {
|
544 |
+
$currency_code = $wpdb->get_var( "SELECT `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` IN ('" . absint( get_option( 'currency_type' ) ) . "')" );
|
545 |
+
|
546 |
+
$selected_gateways = get_option( 'custom_gateway_options' );
|
547 |
+
$already_changed = array( );
|
548 |
+
foreach ( $selected_gateways as $selected_gateway ) {
|
549 |
+
if ( isset( $wpsc_gateways[$selected_gateway]['supported_currencies'] ) ) {
|
550 |
+
if ( in_array( $currency_code, $wpsc_gateways[$selected_gateway]['supported_currencies']['currency_list'] ) ) {
|
551 |
+
|
552 |
+
$option_name = $wpsc_gateways[$selected_gateway]['supported_currencies']['option_name'];
|
553 |
+
|
554 |
+
if ( !in_array( $option_name, $already_changed ) ) {
|
555 |
+
update_option( $option_name, $currency_code );
|
556 |
+
$already_changed[] = $option_name;
|
557 |
+
}
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
|
564 |
+
if ( is_object( $shipping ) )
|
565 |
+
$shipping->submit_form();
|
566 |
+
}
|
567 |
+
|
568 |
+
|
569 |
+
//This is for submitting shipping details to the shipping module
|
570 |
+
if ( !isset( $_POST['update_gateways'] ) )
|
571 |
+
$_POST['update_gateways'] = '';
|
572 |
+
if ( !isset( $_POST['custom_shipping_options'] ) )
|
573 |
+
$_POST['custom_shipping_options'] = null;
|
574 |
+
if ( $_POST['update_gateways'] == 'true' ) {
|
575 |
+
|
576 |
+
update_option( 'custom_shipping_options', $_POST['custom_shipping_options'] );
|
577 |
+
|
578 |
+
$shipadd = 0;
|
579 |
+
foreach ( $GLOBALS['wpsc_shipping_modules'] as $shipping ) {
|
580 |
+
foreach ( (array)$_POST['custom_shipping_options'] as $shippingoption ) {
|
581 |
+
if ( $shipping->internal_name == $shippingoption ) {
|
582 |
+
$shipadd++;
|
583 |
+
}
|
584 |
+
}
|
585 |
+
}
|
586 |
+
}
|
587 |
+
}
|
588 |
+
}
|
589 |
+
|
590 |
+
WPSC_Settings_Page::init();
|
wpsc-core/images/drag.png
ADDED
Binary file
|
wpsc-core/js/tinymce3/window.php
CHANGED
@@ -6,7 +6,7 @@ $allProducts = get_posts('post_type=wpsc-product&nopaging=true');
|
|
6 |
|
7 |
//Check capabilities
|
8 |
if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
|
9 |
-
wp_die(__(
|
10 |
|
11 |
global $wpdb;
|
12 |
?>
|
6 |
|
7 |
//Check capabilities
|
8 |
if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
|
9 |
+
wp_die( __( 'You don\'t have permission to be doing that!', 'wpsc' ) );
|
10 |
|
11 |
global $wpdb;
|
12 |
?>
|
wpsc-core/wpsc-constants.php
CHANGED
@@ -26,9 +26,9 @@ function wpsc_core_constants() {
|
|
26 |
if(!defined('WPSC_URL'))
|
27 |
define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
|
28 |
// Define Plugin version
|
29 |
-
define( 'WPSC_VERSION', '3.8.
|
30 |
-
define( 'WPSC_MINOR_VERSION', '
|
31 |
-
define( 'WPSC_PRESENTABLE_VERSION', '3.8.
|
32 |
|
33 |
// Define Debug Variables for developers
|
34 |
define( 'WPSC_DEBUG', false );
|
@@ -112,10 +112,11 @@ function wpsc_core_constants_table_names() {
|
|
112 |
define( 'WPSC_META_PREFIX', '_wpsc_' );
|
113 |
|
114 |
// These tables are required, either for speed, or because there are no
|
115 |
-
// existing
|
116 |
define( 'WPSC_TABLE_PURCHASE_LOGS', "{$wp_table_prefix}wpsc_purchase_logs" );
|
117 |
define( 'WPSC_TABLE_CART_CONTENTS', "{$wp_table_prefix}wpsc_cart_contents" );
|
118 |
define( 'WPSC_TABLE_SUBMITED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data" );
|
|
|
119 |
define( 'WPSC_TABLE_CURRENCY_LIST', "{$wp_table_prefix}wpsc_currency_list" );
|
120 |
|
121 |
// These tables may be needed in some situations, but are not vital to
|
26 |
if(!defined('WPSC_URL'))
|
27 |
define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
|
28 |
// Define Plugin version
|
29 |
+
define( 'WPSC_VERSION', '3.8.8-dev' );
|
30 |
+
define( 'WPSC_MINOR_VERSION', '463466' );
|
31 |
+
define( 'WPSC_PRESENTABLE_VERSION', '3.8.8-dev' );
|
32 |
|
33 |
// Define Debug Variables for developers
|
34 |
define( 'WPSC_DEBUG', false );
|
112 |
define( 'WPSC_META_PREFIX', '_wpsc_' );
|
113 |
|
114 |
// These tables are required, either for speed, or because there are no
|
115 |
+
// existing WordPress tables suitable for the data stored in them.
|
116 |
define( 'WPSC_TABLE_PURCHASE_LOGS', "{$wp_table_prefix}wpsc_purchase_logs" );
|
117 |
define( 'WPSC_TABLE_CART_CONTENTS', "{$wp_table_prefix}wpsc_cart_contents" );
|
118 |
define( 'WPSC_TABLE_SUBMITED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data" );
|
119 |
+
define( 'WPSC_TABLE_SUBMITTED_FORM_DATA', "{$wp_table_prefix}wpsc_submited_form_data" );
|
120 |
define( 'WPSC_TABLE_CURRENCY_LIST', "{$wp_table_prefix}wpsc_currency_list" );
|
121 |
|
122 |
// These tables may be needed in some situations, but are not vital to
|
wpsc-core/wpsc-functions.php
CHANGED
@@ -10,6 +10,62 @@
|
|
10 |
* @since 3.8
|
11 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
add_filter( 'intermediate_image_sizes_advanced', 'wpsc_intermediate_image_sizes_advanced', 10, 1 );
|
14 |
|
15 |
function wpsc_intermediate_image_sizes_advanced($sizes){
|
@@ -361,7 +417,7 @@ function wpsc_register_post_types() {
|
|
361 |
'parent_item_colon' => __( 'Parent Variations:', 'wpsc' ),
|
362 |
'edit_item' => __( 'Edit Variation', 'wpsc' ),
|
363 |
'update_item' => __( 'Update Variation', 'wpsc' ),
|
364 |
-
'add_new_item' => __( 'Add New Variation
|
365 |
'new_item_name' => __( 'New Variation Name', 'wpsc' ),
|
366 |
);
|
367 |
|
@@ -434,7 +490,8 @@ function wpsc_filter_request( $q ) {
|
|
434 |
|
435 |
if ( ! empty( $posts ) ) {
|
436 |
$q['wpsc-product'] = $q['name'] = $end_node;
|
437 |
-
|
|
|
438 |
} else {
|
439 |
$q['wpsc_product_category'] = $end_node;
|
440 |
unset( $q['name'] );
|
@@ -1161,8 +1218,11 @@ function wpsc_product_link( $permalink, $post, $leavename ) {
|
|
1161 |
}
|
1162 |
}
|
1163 |
|
1164 |
-
if(isset($category_slug) && empty($category_slug))
|
1165 |
-
|
|
|
|
|
|
|
1166 |
$rewritereplace = array(
|
1167 |
$category_slug,
|
1168 |
$post_name
|
10 |
* @since 3.8
|
11 |
*/
|
12 |
|
13 |
+
add_filter( 'term_name', 'wpsc_term_list_levels', 10, 2 );
|
14 |
+
|
15 |
+
/**
|
16 |
+
* When doing variation and product category drag&drop sort, we want to restrict
|
17 |
+
* drag & drop to the same level (children of a category cannot be dropped under
|
18 |
+
* another parent category). To do this, we need to be able to specify depth level
|
19 |
+
* of the term items being output to the term list table.
|
20 |
+
*
|
21 |
+
* Unfortunately, there's no way we can do that with WP hooks. So this is a work around.
|
22 |
+
* This function is added to "term_name" filter. Its job is to record the depth level of
|
23 |
+
* each terms into a global variable. This global variable will later be output to JS in
|
24 |
+
* wpsc_print_term_list_levels_script().
|
25 |
+
*
|
26 |
+
* Not an elegant solution, but it works.
|
27 |
+
*
|
28 |
+
* @param string $term_name
|
29 |
+
* @param object $term
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
function wpsc_term_list_levels( $term_name, $term ) {
|
33 |
+
global $wp_list_table, $wpsc_term_list_levels;
|
34 |
+
|
35 |
+
$screen = get_current_screen();
|
36 |
+
if ( ! in_array( $screen->id, array( 'edit-wpsc-variation', 'edit-wpsc_product_category' ) ) )
|
37 |
+
return $term_name;
|
38 |
+
|
39 |
+
if ( ! isset( $wpsc_term_list_levels ) )
|
40 |
+
$wpsc_term_list_levels = array();
|
41 |
+
|
42 |
+
$wpsc_term_list_levels[$term->term_id] = $wp_list_table->level;
|
43 |
+
|
44 |
+
return $term_name;
|
45 |
+
}
|
46 |
+
|
47 |
+
add_filter( 'admin_footer', 'wpsc_print_term_list_levels_script' );
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Print $wpsc_term_list_levels as JS.
|
51 |
+
* @see wpsc_term_list_levels()
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
function wpsc_print_term_list_levels_script() {
|
55 |
+
global $wpsc_term_list_levels;
|
56 |
+
$screen = get_current_screen();
|
57 |
+
if ( ! in_array( $screen->id, array( 'edit-wpsc-variation', 'edit-wpsc_product_category' ) ) )
|
58 |
+
return;
|
59 |
+
|
60 |
+
?>
|
61 |
+
<script type="text/javascript">
|
62 |
+
//<![CDATA[
|
63 |
+
var WPSC_Term_List_Levels = <?php echo json_encode( $wpsc_term_list_levels ); ?>;
|
64 |
+
//]]>
|
65 |
+
</script>
|
66 |
+
<?php
|
67 |
+
}
|
68 |
+
|
69 |
add_filter( 'intermediate_image_sizes_advanced', 'wpsc_intermediate_image_sizes_advanced', 10, 1 );
|
70 |
|
71 |
function wpsc_intermediate_image_sizes_advanced($sizes){
|
417 |
'parent_item_colon' => __( 'Parent Variations:', 'wpsc' ),
|
418 |
'edit_item' => __( 'Edit Variation', 'wpsc' ),
|
419 |
'update_item' => __( 'Update Variation', 'wpsc' ),
|
420 |
+
'add_new_item' => __( 'Add New Variation', 'wpsc' ),
|
421 |
'new_item_name' => __( 'New Variation Name', 'wpsc' ),
|
422 |
);
|
423 |
|
490 |
|
491 |
if ( ! empty( $posts ) ) {
|
492 |
$q['wpsc-product'] = $q['name'] = $end_node;
|
493 |
+
if ( !empty( $parent_node ) )
|
494 |
+
$q['wpsc_product_category'] = $parent_node;
|
495 |
} else {
|
496 |
$q['wpsc_product_category'] = $end_node;
|
497 |
unset( $q['name'] );
|
1218 |
}
|
1219 |
}
|
1220 |
|
1221 |
+
if( isset( $category_slug ) && empty( $category_slug ) )
|
1222 |
+
$category_slug = 'product';
|
1223 |
+
|
1224 |
+
$category_slug = apply_filters( 'wpsc_product_permalink_cat_slug', $category_slug, $post_id );
|
1225 |
+
|
1226 |
$rewritereplace = array(
|
1227 |
$category_slug,
|
1228 |
$post_name
|
wpsc-core/wpsc-installer.php
CHANGED
@@ -34,13 +34,9 @@ function wpsc_install() {
|
|
34 |
|
35 |
$table_name = $wpdb->prefix . "wpsc_product_list";
|
36 |
$first_install = false;
|
37 |
-
$result = mysql_list_tables( DB_NAME );
|
38 |
-
$tables = array();
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
if ( !in_array( $table_name, $tables ) ) {
|
44 |
$first_install = true;
|
45 |
add_option( 'wpsc_purchaselogs_fixed', true );
|
46 |
}
|
@@ -704,26 +700,26 @@ function wpsc_add_region_list() {
|
|
704 |
function wpsc_add_checkout_fields() {
|
705 |
global $wpdb;
|
706 |
$data_forms = $wpdb->get_results( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "`", ARRAY_A );
|
707 |
-
|
708 |
if ( isset( $data_forms[0] ) && $data_forms[0]['count'] == 0 ) {
|
709 |
|
710 |
-
$sql = " INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name`) VALUES ( '" . __( 'Your billing/contact details', 'wpsc' ) . "', 'heading', '0', '0', '', '1', 1,''),
|
711 |
-
( '" . __( 'First Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 2,'billingfirstname'),
|
712 |
-
( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '1', '1', '', '1', 3,'billinglastname'),
|
713 |
-
( '" . __( 'Address', 'wpsc' ) . "', 'address', '1', '0', '', '1', 4,'billingaddress'),
|
714 |
-
( '" . __( 'City', 'wpsc' ) . "', 'city', '1', '0', '', '1', 5,'billingcity'),
|
715 |
-
( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '', '1', 6,'billingstate'),
|
716 |
-
( '" . __( 'Country', 'wpsc' ) . "', 'country', '1', '0', '', '1', 7,'billingcountry'),
|
717 |
-
( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '', '1', 8,'billingpostcode'),
|
718 |
-
( '" . __( 'Email', 'wpsc' ) . "', 'email', '1', '1', '', '1', 9,'billingemail'),
|
719 |
-
( '" . __( 'Shipping Address', 'wpsc' ) . "', 'heading', '0', '0', '', '1', 10,'delivertoafriend'),
|
720 |
-
( '" . __( 'First Name', 'wpsc' ) . "', 'text', '0', '0', '', '1', 11,'shippingfirstname'),
|
721 |
-
( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '0', '0', '', '1', 12,'shippinglastname'),
|
722 |
-
( '" . __( 'Address', 'wpsc' ) . "', 'address', '0', '0', '', '1', 13,'shippingaddress'),
|
723 |
-
( '" . __( 'City', 'wpsc' ) . "', 'city', '0', '0', '', '1', 14,'shippingcity'),
|
724 |
-
( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '', '1', 15,'shippingstate'),
|
725 |
-
( '" . __( 'Country', 'wpsc' ) . "', 'delivery_country', '0', '0', '', '1', 16,'shippingcountry'),
|
726 |
-
( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '', '1', 17,'shippingpostcode');";
|
727 |
|
728 |
$wpdb->query( $sql );
|
729 |
$wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name` ) VALUES ( '" . __( 'Phone', 'wpsc' ) . "', 'text', '1', '0', '', '1', '8','billingphone');" );
|
34 |
|
35 |
$table_name = $wpdb->prefix . "wpsc_product_list";
|
36 |
$first_install = false;
|
|
|
|
|
37 |
|
38 |
+
if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name ) {
|
39 |
+
// Table doesn't exist
|
|
|
|
|
40 |
$first_install = true;
|
41 |
add_option( 'wpsc_purchaselogs_fixed', true );
|
42 |
}
|
700 |
function wpsc_add_checkout_fields() {
|
701 |
global $wpdb;
|
702 |
$data_forms = $wpdb->get_results( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "`", ARRAY_A );
|
703 |
+
|
704 |
if ( isset( $data_forms[0] ) && $data_forms[0]['count'] == 0 ) {
|
705 |
|
706 |
+
$sql = " INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name`) VALUES ( '" . __( 'Your billing/contact details', 'wpsc' ) . "', 'heading', '0', '0', '1', '1', 1,''),
|
707 |
+
( '" . __( 'First Name', 'wpsc' ) . "', 'text', '1', '1', '1', '1', 2,'billingfirstname'),
|
708 |
+
( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '1', '1', '1', '1', 3,'billinglastname'),
|
709 |
+
( '" . __( 'Address', 'wpsc' ) . "', 'address', '1', '0', '1', '1', 4,'billingaddress'),
|
710 |
+
( '" . __( 'City', 'wpsc' ) . "', 'city', '1', '0', '1', '1', 5,'billingcity'),
|
711 |
+
( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 6,'billingstate'),
|
712 |
+
( '" . __( 'Country', 'wpsc' ) . "', 'country', '1', '0', '1', '1', 7,'billingcountry'),
|
713 |
+
( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 8,'billingpostcode'),
|
714 |
+
( '" . __( 'Email', 'wpsc' ) . "', 'email', '1', '1', '1', '1', 9,'billingemail'),
|
715 |
+
( '" . __( 'Shipping Address', 'wpsc' ) . "', 'heading', '0', '0', '1', '1', 10,'delivertoafriend'),
|
716 |
+
( '" . __( 'First Name', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 11,'shippingfirstname'),
|
717 |
+
( '" . __( 'Last Name', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 12,'shippinglastname'),
|
718 |
+
( '" . __( 'Address', 'wpsc' ) . "', 'address', '0', '0', '1', '1', 13,'shippingaddress'),
|
719 |
+
( '" . __( 'City', 'wpsc' ) . "', 'city', '0', '0', '1', '1', 14,'shippingcity'),
|
720 |
+
( '" . __( 'State', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 15,'shippingstate'),
|
721 |
+
( '" . __( 'Country', 'wpsc' ) . "', 'delivery_country', '0', '0', '1', '1', 16,'shippingcountry'),
|
722 |
+
( '" . __( 'Postal Code', 'wpsc' ) . "', 'text', '0', '0', '1', '1', 17,'shippingpostcode');";
|
723 |
|
724 |
$wpdb->query( $sql );
|
725 |
$wpdb->query( "INSERT INTO `" . WPSC_TABLE_CHECKOUT_FORMS . "` ( `name`, `type`, `mandatory`, `display_log`, `default`, `active`, `checkout_order`, `unique_name` ) VALUES ( '" . __( 'Phone', 'wpsc' ) . "', 'text', '1', '0', '', '1', '8','billingphone');" );
|
wpsc-includes/ajax.functions.php
CHANGED
@@ -9,7 +9,6 @@
|
|
9 |
* @since 3.7
|
10 |
*/
|
11 |
function wpsc_special_widget() {
|
12 |
-
global $wpdb;
|
13 |
wpsc_add_to_cart();
|
14 |
}
|
15 |
|
@@ -22,7 +21,7 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] ==
|
|
22 |
* No parameters, returns nothing
|
23 |
*/
|
24 |
function wpsc_add_to_cart() {
|
25 |
-
global $
|
26 |
/// default values
|
27 |
$default_parameters['variation_values'] = null;
|
28 |
$default_parameters['quantity'] = 1;
|
@@ -146,7 +145,7 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] ==
|
|
146 |
}
|
147 |
|
148 |
function wpsc_get_cart() {
|
149 |
-
global $
|
150 |
|
151 |
ob_start();
|
152 |
|
@@ -191,7 +190,7 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] ==
|
|
191 |
* No parameters, returns nothing
|
192 |
*/
|
193 |
function wpsc_empty_cart() {
|
194 |
-
global $
|
195 |
$wpsc_cart->empty_cart( false );
|
196 |
|
197 |
if ( $_REQUEST['ajax'] == 'true' ) {
|
@@ -233,9 +232,9 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && (($_REQUEST['wpsc_ajax_action'] =
|
|
233 |
* No parameters, returns nothing
|
234 |
*/
|
235 |
function wpsc_coupon_price( $currCoupon = '' ) {
|
236 |
-
global $
|
237 |
if ( isset( $_POST['coupon_num'] ) && $_POST['coupon_num'] != '' ) {
|
238 |
-
$coupon =
|
239 |
$_SESSION['coupon_numbers'] = $coupon;
|
240 |
$wpsc_coupons = new wpsc_coupons( $coupon );
|
241 |
|
@@ -252,7 +251,7 @@ function wpsc_coupon_price( $currCoupon = '' ) {
|
|
252 |
$wpsc_cart->coupons_amount = 0;
|
253 |
$wpsc_cart->coupons_name = '';
|
254 |
} else if ( $currCoupon != '' ) {
|
255 |
-
$coupon =
|
256 |
$_SESSION['coupon_numbers'] = $coupon;
|
257 |
$wpsc_coupons = new wpsc_coupons( $coupon );
|
258 |
|
@@ -275,7 +274,7 @@ if ( isset( $_POST['coupon_num'] ) ) {
|
|
275 |
* No parameters, returns nothing
|
276 |
*/
|
277 |
function wpsc_update_item_quantity() {
|
278 |
-
global $
|
279 |
|
280 |
if ( is_numeric( $_POST['key'] ) ) {
|
281 |
$key = (int)$_POST['key'];
|
@@ -319,7 +318,7 @@ function wpsc_update_product_rating() {
|
|
319 |
global $wpdb;
|
320 |
$nowtime = time();
|
321 |
$product_id = absint( $_POST['product_id'] );
|
322 |
-
$ip_number = $
|
323 |
$rating = absint( $_POST['product_rating'] );
|
324 |
|
325 |
$cookie_data = explode( ",", $_COOKIE['voting_cookie'][$product_id] );
|
@@ -356,7 +355,7 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] ==
|
|
356 |
* No parameters, returns nothing
|
357 |
*/
|
358 |
function wpsc_update_shipping_price() {
|
359 |
-
global $
|
360 |
$quote_shipping_method = $_POST['key1'];
|
361 |
$quote_shipping_option = $_POST['key'];
|
362 |
if(!empty($quote_shipping_option) && !empty($quote_shipping_method)){
|
@@ -383,8 +382,8 @@ if ( isset( $_REQUEST['wpsc_ajax_action'] ) && ($_REQUEST['wpsc_ajax_action'] ==
|
|
383 |
function wpsc_get_rating_count() {
|
384 |
global $wpdb, $wpsc_cart;
|
385 |
$prodid = $_POST['product_id'];
|
386 |
-
$
|
387 |
-
echo $
|
388 |
exit();
|
389 |
}
|
390 |
|
@@ -398,7 +397,7 @@ if ( isset( $_REQUEST['get_rating_count'] ) && ($_REQUEST['get_rating_count'] ==
|
|
398 |
* No parameters, returns nothing
|
399 |
*/
|
400 |
function wpsc_update_product_price() {
|
401 |
-
|
402 |
$from = '';
|
403 |
$change_price = true;
|
404 |
$product_id = (int) $_POST['product_id'];
|
@@ -464,6 +463,7 @@ if ( isset( $_REQUEST['update_product_price'] ) && ($_REQUEST['update_product_pr
|
|
464 |
*/
|
465 |
function wpsc_update_location() {
|
466 |
global $wpdb, $wpsc_cart;
|
|
|
467 |
if ( $_POST['country'] != null ) {
|
468 |
$_SESSION['wpsc_delivery_country'] = $_POST['country'];
|
469 |
if ( $_SESSION['wpsc_selected_country'] == null ) {
|
@@ -488,12 +488,12 @@ function wpsc_update_location() {
|
|
488 |
$_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
|
489 |
}
|
490 |
|
491 |
-
$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('"
|
492 |
if ( $delivery_region_count < 1 ) {
|
493 |
$_SESSION['wpsc_delivery_region'] = null;
|
494 |
}
|
495 |
|
496 |
-
$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('"
|
497 |
if ( $selected_region_count < 1 ) {
|
498 |
$_SESSION['wpsc_selected_region'] = null;
|
499 |
}
|
@@ -505,9 +505,8 @@ function wpsc_update_location() {
|
|
505 |
$wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option );
|
506 |
}
|
507 |
|
508 |
-
if ( isset( $_GET['ajax'] ) && $_GET['ajax'] == 'true' )
|
509 |
-
exit
|
510 |
-
}
|
511 |
}
|
512 |
|
513 |
// execute on POST and GET
|
@@ -531,9 +530,13 @@ if ( isset( $_REQUEST['wpsc_action'] ) && ($_REQUEST['wpsc_action'] == 'cart_htm
|
|
531 |
*/
|
532 |
function wpsc_submit_checkout() {
|
533 |
global $wpdb, $wpsc_cart, $user_ID, $nzshpcrt_gateways, $wpsc_shipping_modules, $wpsc_gateways;
|
|
|
534 |
$num_items = 0;
|
535 |
$use_shipping = 0;
|
536 |
$disregard_shipping = 0;
|
|
|
|
|
|
|
537 |
$_SESSION['wpsc_checkout_misc_error_messages'] = array( );
|
538 |
$wpsc_checkout = new wpsc_checkout();
|
539 |
$selected_gateways = get_option( 'custom_gateway_options' );
|
@@ -546,7 +549,7 @@ function wpsc_submit_checkout() {
|
|
546 |
$_SESSION['wpsc_checkout_misc_error_messages'][] = __( 'Please agree to the terms and conditions, otherwise we cannot process your order.', 'wpsc' );
|
547 |
$is_valid = false;
|
548 |
}
|
549 |
-
$selectedCountry = $wpdb->get_results( "SELECT id, country FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE isocode='"
|
550 |
foreach ( $wpsc_cart->cart_items as $cartitem ) {
|
551 |
if( ! empty( $cartitem->meta[0]['no_shipping'] ) ) continue;
|
552 |
$categoriesIDs = $cartitem->category_id_list;
|
@@ -660,7 +663,7 @@ function wpsc_submit_checkout() {
|
|
660 |
if ( isset( $current_gateway_data['api_version'] ) && $current_gateway_data['api_version'] >= 2.0 ) {
|
661 |
$merchant_instance = new $current_gateway_data['class_name']( $purchase_log_id );
|
662 |
$merchant_instance->construct_value_array();
|
663 |
-
|
664 |
$merchant_instance->submit();
|
665 |
} elseif ( ($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google') ) {
|
666 |
$gateway_used = $current_gateway_data['internalname'];
|
@@ -686,7 +689,7 @@ if ( isset( $_REQUEST['wpsc_action'] ) && ($_REQUEST['wpsc_action'] == 'submit_c
|
|
686 |
}
|
687 |
|
688 |
function wpsc_product_rss() {
|
689 |
-
global $wp_query
|
690 |
list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
|
691 |
header( "Content-Type: application/xml; charset=UTF-8" );
|
692 |
header( 'Content-Disposition: inline; filename="E-Commerce_Product_List.rss"' );
|
@@ -700,7 +703,7 @@ if ( isset( $_REQUEST['wpsc_action'] ) && ($_REQUEST['wpsc_action'] == "rss") )
|
|
700 |
}
|
701 |
|
702 |
function wpsc_gateway_notification() {
|
703 |
-
global $
|
704 |
$gateway_name = $_GET['gateway'];
|
705 |
// work out what gateway we are getting the request from, run the appropriate code.
|
706 |
if ( ($gateway_name != null) && isset( $wpsc_gateways[$gateway_name]['class_name'] ) ) {
|
@@ -739,7 +742,7 @@ function wpsc_change_tax() {
|
|
739 |
|
740 |
$previous_country = $_SESSION['wpsc_selected_country'];
|
741 |
if ( isset( $_POST['billing_country'] ) ) {
|
742 |
-
$wpsc_selected_country = $
|
743 |
$_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
|
744 |
}
|
745 |
|
@@ -748,14 +751,14 @@ function wpsc_change_tax() {
|
|
748 |
$_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
|
749 |
}
|
750 |
|
751 |
-
$check_country_code = $wpdb->get_var( "
|
752 |
|
753 |
if ( $_SESSION['wpsc_selected_country'] != $check_country_code ) {
|
754 |
$wpsc_selected_region = null;
|
755 |
}
|
756 |
|
757 |
if ( isset( $_POST['shipping_country'] ) ) {
|
758 |
-
$wpsc_delivery_country = $
|
759 |
$_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
|
760 |
}
|
761 |
if ( isset( $_POST['shipping_region'] ) ) {
|
@@ -763,7 +766,7 @@ function wpsc_change_tax() {
|
|
763 |
$_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
|
764 |
}
|
765 |
|
766 |
-
$check_country_code = $wpdb->get_var( "
|
767 |
|
768 |
if ( $wpsc_delivery_country != $check_country_code ) {
|
769 |
$wpsc_delivery_region = null;
|
@@ -837,7 +840,7 @@ function wpsc_change_tax() {
|
|
837 |
}
|
838 |
|
839 |
if ( ($form_selected_country != null) && ($onchange_function != null) ) {
|
840 |
-
$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('
|
841 |
if ( $region_list != null ) {
|
842 |
$title = (empty($_POST['billing_country']))?'shippingstate':'billingstate';
|
843 |
$output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='$onchange_function(\"region_country_form_$form_id\", \"$form_id\");' title='" . $title . "'>\n\r";
|
@@ -880,10 +883,6 @@ function wpsc_change_tax() {
|
|
880 |
}
|
881 |
}
|
882 |
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
if ( $tax > 0 ) {
|
888 |
echo "jQuery(\"tr.total_tax\").show();\n\r";
|
889 |
} else {
|
@@ -919,7 +918,7 @@ function wpsc_scale_image() {
|
|
919 |
$generate_thumbnail = true;
|
920 |
} else {
|
921 |
if ( isset( $_REQUEST['intermediate_size'] ) )
|
922 |
-
|
923 |
$generate_thumbnail = false;
|
924 |
}
|
925 |
|
@@ -983,11 +982,11 @@ function wpsc_download_file() {
|
|
983 |
// strip out anything that isnt 'a' to 'z' or '0' to '9'
|
984 |
ini_set('max_execution_time',10800);
|
985 |
$downloadid = preg_replace( "/[^a-z0-9]+/i", '', strtolower( $_GET['downloadid'] ) );
|
986 |
-
$download_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `uniqueid` = '
|
|
|
|
|
|
|
987 |
|
988 |
-
if ( ($download_data == null) && is_numeric( $downloadid ) ) {
|
989 |
-
$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 );
|
990 |
-
}
|
991 |
|
992 |
if ( (get_option( 'wpsc_ip_lock_downloads' ) == 1) && ($_SERVER['REMOTE_ADDR'] != null) ) {
|
993 |
$ip_number = $_SERVER['REMOTE_ADDR'];
|
@@ -1021,7 +1020,8 @@ function wpsc_download_file() {
|
|
1021 |
$wpdb->update( WPSC_TABLE_DOWNLOAD_STATUS, array(
|
1022 |
'downloads' => $download_count
|
1023 |
), array( 'id' => $download_data['id'] ) );
|
1024 |
-
|
|
|
1025 |
$dl = 0;
|
1026 |
|
1027 |
foreach ( $cart_contents as $cart_content ) {
|
9 |
* @since 3.7
|
10 |
*/
|
11 |
function wpsc_special_widget() {
|
|
|
12 |
wpsc_add_to_cart();
|
13 |
}
|
14 |
|
21 |
* No parameters, returns nothing
|
22 |
*/
|
23 |
function wpsc_add_to_cart() {
|
24 |
+
global $wpsc_cart;
|
25 |
/// default values
|
26 |
$default_parameters['variation_values'] = null;
|
27 |
$default_parameters['quantity'] = 1;
|
145 |
}
|
146 |
|
147 |
function wpsc_get_cart() {
|
148 |
+
global $wpsc_cart;
|
149 |
|
150 |
ob_start();
|
151 |
|
190 |
* No parameters, returns nothing
|
191 |
*/
|
192 |
function wpsc_empty_cart() {
|
193 |
+
global $wpsc_cart;
|
194 |
$wpsc_cart->empty_cart( false );
|
195 |
|
196 |
if ( $_REQUEST['ajax'] == 'true' ) {
|
232 |
* No parameters, returns nothing
|
233 |
*/
|
234 |
function wpsc_coupon_price( $currCoupon = '' ) {
|
235 |
+
global $wpsc_cart, $wpsc_coupons;
|
236 |
if ( isset( $_POST['coupon_num'] ) && $_POST['coupon_num'] != '' ) {
|
237 |
+
$coupon = esc_sql( $_POST['coupon_num'] );
|
238 |
$_SESSION['coupon_numbers'] = $coupon;
|
239 |
$wpsc_coupons = new wpsc_coupons( $coupon );
|
240 |
|
251 |
$wpsc_cart->coupons_amount = 0;
|
252 |
$wpsc_cart->coupons_name = '';
|
253 |
} else if ( $currCoupon != '' ) {
|
254 |
+
$coupon = esc_sql( $currCoupon );
|
255 |
$_SESSION['coupon_numbers'] = $coupon;
|
256 |
$wpsc_coupons = new wpsc_coupons( $coupon );
|
257 |
|
274 |
* No parameters, returns nothing
|
275 |
*/
|
276 |
function wpsc_update_item_quantity() {
|
277 |
+
global $wpsc_cart;
|
278 |
|
279 |
if ( is_numeric( $_POST['key'] ) ) {
|
280 |
$key = (int)$_POST['key'];
|
318 |
global $wpdb;
|
319 |
$nowtime = time();
|
320 |
$product_id = absint( $_POST['product_id'] );
|
321 |
+
$ip_number = $_SERVER['REMOTE_ADDR'];
|
322 |
$rating = absint( $_POST['product_rating'] );
|
323 |
|
324 |
$cookie_data = explode( ",", $_COOKIE['voting_cookie'][$product_id] );
|
355 |
* No parameters, returns nothing
|
356 |
*/
|
357 |
function wpsc_update_shipping_price() {
|
358 |
+
global $wpsc_cart;
|
359 |
$quote_shipping_method = $_POST['key1'];
|
360 |
$quote_shipping_option = $_POST['key'];
|
361 |
if(!empty($quote_shipping_option) && !empty($quote_shipping_method)){
|
382 |
function wpsc_get_rating_count() {
|
383 |
global $wpdb, $wpsc_cart;
|
384 |
$prodid = $_POST['product_id'];
|
385 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) AS `count` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `productid` = %d", $prodid ) );
|
386 |
+
echo $count . "," . $prodid;
|
387 |
exit();
|
388 |
}
|
389 |
|
397 |
* No parameters, returns nothing
|
398 |
*/
|
399 |
function wpsc_update_product_price() {
|
400 |
+
|
401 |
$from = '';
|
402 |
$change_price = true;
|
403 |
$product_id = (int) $_POST['product_id'];
|
463 |
*/
|
464 |
function wpsc_update_location() {
|
465 |
global $wpdb, $wpsc_cart;
|
466 |
+
|
467 |
if ( $_POST['country'] != null ) {
|
468 |
$_SESSION['wpsc_delivery_country'] = $_POST['country'];
|
469 |
if ( $_SESSION['wpsc_selected_country'] == null ) {
|
488 |
$_SESSION['wpsc_zipcode'] = $_POST['zipcode'];
|
489 |
}
|
490 |
|
491 |
+
$delivery_region_count = $wpdb->get_var( $wpdb->prepare( "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('%s')", $_SESSION['wpsc_delivery_country'] ) );
|
492 |
if ( $delivery_region_count < 1 ) {
|
493 |
$_SESSION['wpsc_delivery_region'] = null;
|
494 |
}
|
495 |
|
496 |
+
$selected_region_count = $wpdb->get_var( $wpdb->prepare( "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('%s')", $_SESSION['wpsc_selected_country'] ) );
|
497 |
if ( $selected_region_count < 1 ) {
|
498 |
$_SESSION['wpsc_selected_region'] = null;
|
499 |
}
|
505 |
$wpsc_cart->update_shipping( $wpsc_cart->selected_shipping_method, $wpsc_cart->selected_shipping_option );
|
506 |
}
|
507 |
|
508 |
+
if ( isset( $_GET['ajax'] ) && $_GET['ajax'] == 'true' )
|
509 |
+
exit;
|
|
|
510 |
}
|
511 |
|
512 |
// execute on POST and GET
|
530 |
*/
|
531 |
function wpsc_submit_checkout() {
|
532 |
global $wpdb, $wpsc_cart, $user_ID, $nzshpcrt_gateways, $wpsc_shipping_modules, $wpsc_gateways;
|
533 |
+
|
534 |
$num_items = 0;
|
535 |
$use_shipping = 0;
|
536 |
$disregard_shipping = 0;
|
537 |
+
|
538 |
+
do_action( 'wpsc_before_submit_checkout' );
|
539 |
+
|
540 |
$_SESSION['wpsc_checkout_misc_error_messages'] = array( );
|
541 |
$wpsc_checkout = new wpsc_checkout();
|
542 |
$selected_gateways = get_option( 'custom_gateway_options' );
|
549 |
$_SESSION['wpsc_checkout_misc_error_messages'][] = __( 'Please agree to the terms and conditions, otherwise we cannot process your order.', 'wpsc' );
|
550 |
$is_valid = false;
|
551 |
}
|
552 |
+
$selectedCountry = $wpdb->get_results( $wpdb->prepare( "SELECT id, country FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE isocode = '%s' ", $_SESSION['wpsc_delivery_country'] ), ARRAY_A );
|
553 |
foreach ( $wpsc_cart->cart_items as $cartitem ) {
|
554 |
if( ! empty( $cartitem->meta[0]['no_shipping'] ) ) continue;
|
555 |
$categoriesIDs = $cartitem->category_id_list;
|
663 |
if ( isset( $current_gateway_data['api_version'] ) && $current_gateway_data['api_version'] >= 2.0 ) {
|
664 |
$merchant_instance = new $current_gateway_data['class_name']( $purchase_log_id );
|
665 |
$merchant_instance->construct_value_array();
|
666 |
+
do_action_ref_array( 'wpsc_pre_submit_gateway', array( &$merchant_instance ) );
|
667 |
$merchant_instance->submit();
|
668 |
} elseif ( ($current_gateway_data['internalname'] == $submitted_gateway) && ($current_gateway_data['internalname'] != 'google') ) {
|
669 |
$gateway_used = $current_gateway_data['internalname'];
|
689 |
}
|
690 |
|
691 |
function wpsc_product_rss() {
|
692 |
+
global $wp_query, $wpsc_query;
|
693 |
list($wp_query, $wpsc_query) = array( $wpsc_query, $wp_query ); // swap the wpsc_query object
|
694 |
header( "Content-Type: application/xml; charset=UTF-8" );
|
695 |
header( 'Content-Disposition: inline; filename="E-Commerce_Product_List.rss"' );
|
703 |
}
|
704 |
|
705 |
function wpsc_gateway_notification() {
|
706 |
+
global $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'] ) ) {
|
742 |
|
743 |
$previous_country = $_SESSION['wpsc_selected_country'];
|
744 |
if ( isset( $_POST['billing_country'] ) ) {
|
745 |
+
$wpsc_selected_country = $_POST['billing_country'];
|
746 |
$_SESSION['wpsc_selected_country'] = $wpsc_selected_country;
|
747 |
}
|
748 |
|
751 |
$_SESSION['wpsc_selected_region'] = $wpsc_selected_region;
|
752 |
}
|
753 |
|
754 |
+
$check_country_code = $wpdb->get_var( $wpdb->prepare( "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` = %d LIMIT 1", $_SESSION['wpsc_selected_region'] ) );
|
755 |
|
756 |
if ( $_SESSION['wpsc_selected_country'] != $check_country_code ) {
|
757 |
$wpsc_selected_region = null;
|
758 |
}
|
759 |
|
760 |
if ( isset( $_POST['shipping_country'] ) ) {
|
761 |
+
$wpsc_delivery_country = $_POST['shipping_country'];
|
762 |
$_SESSION['wpsc_delivery_country'] = $wpsc_delivery_country;
|
763 |
}
|
764 |
if ( isset( $_POST['shipping_region'] ) ) {
|
766 |
$_SESSION['wpsc_delivery_region'] = $wpsc_delivery_region;
|
767 |
}
|
768 |
|
769 |
+
$check_country_code = $wpdb->get_var( $wpdb->prepare( "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` = %d LIMIT 1", $wpsc_delivery_region ) );
|
770 |
|
771 |
if ( $wpsc_delivery_country != $check_country_code ) {
|
772 |
$wpsc_delivery_region = null;
|
840 |
}
|
841 |
|
842 |
if ( ($form_selected_country != null) && ($onchange_function != null) ) {
|
843 |
+
$region_list = $wpdb->get_results( $wpdb->prepare( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('%s') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", $form_selected_country ), ARRAY_A );
|
844 |
if ( $region_list != null ) {
|
845 |
$title = (empty($_POST['billing_country']))?'shippingstate':'billingstate';
|
846 |
$output = "<select name='collected_data[" . $form_id . "][1]' class='current_region' onchange='$onchange_function(\"region_country_form_$form_id\", \"$form_id\");' title='" . $title . "'>\n\r";
|
883 |
}
|
884 |
}
|
885 |
|
|
|
|
|
|
|
|
|
886 |
if ( $tax > 0 ) {
|
887 |
echo "jQuery(\"tr.total_tax\").show();\n\r";
|
888 |
} else {
|
918 |
$generate_thumbnail = true;
|
919 |
} else {
|
920 |
if ( isset( $_REQUEST['intermediate_size'] ) )
|
921 |
+
$intermediate_size = esc_attr( $_REQUEST['intermediate_size'] );
|
922 |
$generate_thumbnail = false;
|
923 |
}
|
924 |
|
982 |
// strip out anything that isnt 'a' to 'z' or '0' to '9'
|
983 |
ini_set('max_execution_time',10800);
|
984 |
$downloadid = preg_replace( "/[^a-z0-9]+/i", '', strtolower( $_GET['downloadid'] ) );
|
985 |
+
$download_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `uniqueid` = '%s' AND `downloads` > '0' AND `active`='1' LIMIT 1", $downloadid ), ARRAY_A );
|
986 |
+
|
987 |
+
if ( is_null( $download_data ) && is_numeric( $downloadid ) )
|
988 |
+
$download_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `id` = %d AND `downloads` > '0' AND `active`='1' AND `uniqueid` IS NULL LIMIT 1", $downloadid ), ARRAY_A );
|
989 |
|
|
|
|
|
|
|
990 |
|
991 |
if ( (get_option( 'wpsc_ip_lock_downloads' ) == 1) && ($_SERVER['REMOTE_ADDR'] != null) ) {
|
992 |
$ip_number = $_SERVER['REMOTE_ADDR'];
|
1020 |
$wpdb->update( WPSC_TABLE_DOWNLOAD_STATUS, array(
|
1021 |
'downloads' => $download_count
|
1022 |
), array( 'id' => $download_data['id'] ) );
|
1023 |
+
|
1024 |
+
$cart_contents = $wpdb->get_results( $wpdb->prepare( "SELECT `" . WPSC_TABLE_CART_CONTENTS . "`.*, $wpdb->posts.`guid` FROM `" . WPSC_TABLE_CART_CONTENTS . "` LEFT JOIN $wpdb->posts ON `" . WPSC_TABLE_CART_CONTENTS . "`.`prodid`= $wpdb->posts.`post_parent` WHERE $wpdb->posts.`post_type` = 'wpsc-product-file' AND `purchaseid` = %d", $download_data['purchid'] ), ARRAY_A );
|
1025 |
$dl = 0;
|
1026 |
|
1027 |
foreach ( $cart_contents as $cart_content ) {
|
wpsc-includes/cart.class.php
CHANGED
@@ -201,7 +201,7 @@ function wpsc_cart_has_shipping() {
|
|
201 |
*/
|
202 |
function wpsc_cart_shipping() {
|
203 |
global $wpsc_cart;
|
204 |
-
return wpsc_currency_display($wpsc_cart->calculate_total_shipping());
|
205 |
}
|
206 |
|
207 |
|
@@ -375,9 +375,9 @@ function wpsc_google_checkout(){
|
|
375 |
}
|
376 |
function wpsc_empty_google_logs(){
|
377 |
global $wpdb;
|
378 |
-
$sql="DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid
|
379 |
-
$wpdb->query($sql);
|
380 |
-
unset($_SESSION['wpsc_sessionid']);
|
381 |
|
382 |
}
|
383 |
/**
|
@@ -447,13 +447,13 @@ function wpsc_shipping_quote_name() {
|
|
447 |
* the shipping quote value function, no parameters
|
448 |
* @return string shipping quote value
|
449 |
*/
|
450 |
-
function wpsc_shipping_quote_value($numeric = false) {
|
451 |
global $wpsc_cart;
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
}
|
458 |
|
459 |
/**
|
@@ -723,7 +723,7 @@ class wpsc_cart {
|
|
723 |
}
|
724 |
|
725 |
if(($this->shipping_quotes != null) && (array_search($this->selected_shipping_option, array_keys($this->shipping_quotes)) === false)) {
|
726 |
-
$this->selected_shipping_option = array_pop(array_keys(array_slice($this->shipping_quotes,0,1)));
|
727 |
}
|
728 |
}
|
729 |
|
@@ -800,7 +800,7 @@ class wpsc_cart {
|
|
800 |
|
801 |
if($add_tax == true) {
|
802 |
if(($country_data['has_regions'] == 1)) {
|
803 |
-
$region_data = $wpdb->get_row("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN('
|
804 |
$tax_percentage = $region_data['tax'];
|
805 |
} else {
|
806 |
$tax_percentage = $country_data['tax'];
|
@@ -813,9 +813,7 @@ class wpsc_cart {
|
|
813 |
$this->clear_cache();
|
814 |
$this->tax_percentage = $tax_percentage;
|
815 |
|
816 |
-
|
817 |
-
$this->cart_items[$key]->refresh_item();
|
818 |
-
}
|
819 |
}
|
820 |
}
|
821 |
|
@@ -918,7 +916,7 @@ class wpsc_cart {
|
|
918 |
$priceandstock_id = 0;
|
919 |
|
920 |
if($stock > 0) {
|
921 |
-
$claimed_stock = $wpdb->get_var("SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN(
|
922 |
if(($claimed_stock + $quantity) <= $stock) {
|
923 |
$output = true;
|
924 |
} else {
|
@@ -1067,8 +1065,10 @@ class wpsc_cart {
|
|
1067 |
// Get tax only if it is included
|
1068 |
$tax = ( ! wpsc_tax_isincluded() ) ? $this->calculate_total_tax() : 0.00;
|
1069 |
|
1070 |
-
// Get coupon amount
|
1071 |
-
|
|
|
|
|
1072 |
|
1073 |
// Calculate the total
|
1074 |
$total = ( ( $subtotal + $shipping + $tax ) > $coupons_amount ) ? ( $subtotal + $shipping + $tax - $coupons_amount ) : 0.00;
|
@@ -1120,19 +1120,17 @@ class wpsc_cart {
|
|
1120 |
* @access public
|
1121 |
* @return float returns the price as a floating point value
|
1122 |
*/
|
1123 |
-
function calculate_total_tax()
|
1124 |
-
{
|
1125 |
-
//uses new wpec_taxes functionality
|
1126 |
-
$wpec_taxes_controller = new wpec_taxes_controller();
|
1127 |
-
$taxes_total = $wpec_taxes_controller->wpec_taxes_calculate_total();
|
1128 |
-
$this->total_tax = $taxes_total['total'];
|
1129 |
-
if(isset($taxes_total['rate']))
|
1130 |
-
{
|
1131 |
-
$this->tax_percentage = $taxes_total['rate'];
|
1132 |
-
}// if
|
1133 |
|
1134 |
-
|
1135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1136 |
|
1137 |
|
1138 |
|
@@ -1143,7 +1141,7 @@ class wpsc_cart {
|
|
1143 |
* @param boolean for_shipping = exclude items with no shipping,
|
1144 |
* @return float returns the price as a floating point value
|
1145 |
*/
|
1146 |
-
|
1147 |
global $wpdb;
|
1148 |
$total = '';
|
1149 |
if($for_shipping == true ) {
|
@@ -1201,8 +1199,10 @@ class wpsc_cart {
|
|
1201 |
}else{
|
1202 |
$total = 0;
|
1203 |
}
|
1204 |
-
|
1205 |
-
|
|
|
|
|
1206 |
|
1207 |
/**
|
1208 |
* has_total_shipping_discount method, checks whether the carts subtotal is larger or equal to the shipping discount * value
|
@@ -1475,10 +1475,10 @@ class wpsc_cart {
|
|
1475 |
/**
|
1476 |
* Applying Coupons
|
1477 |
*/
|
1478 |
-
function apply_coupons($
|
1479 |
$this->clear_cache();
|
1480 |
-
$this->coupons_name = $
|
1481 |
-
$this->coupons_amount = $
|
1482 |
$this->calculate_total_price();
|
1483 |
if ( $this->total_price < 0 ) {
|
1484 |
$this->coupons_amount += $this->total_price;
|
@@ -1603,7 +1603,6 @@ function refresh_item() {
|
|
1603 |
$this->stock = get_post_meta( $product_id, '_wpsc_stock', true );
|
1604 |
$this->is_donation = get_post_meta( $product_id, '_wpsc_is_donation', true );
|
1605 |
|
1606 |
-
|
1607 |
if ( isset( $special_price ) && $special_price > 0 && $special_price < $price )
|
1608 |
$price = $special_price;
|
1609 |
$priceandstock_id = 0;
|
@@ -1622,7 +1621,7 @@ function refresh_item() {
|
|
1622 |
}
|
1623 |
}
|
1624 |
|
1625 |
-
$price = apply_filters('wpsc_price', $price, $product_id);
|
1626 |
// create the string containing the product name.
|
1627 |
$product_name = apply_filters( 'wpsc_cart_product_title', $product->post_title, $product_id );
|
1628 |
|
@@ -1708,7 +1707,7 @@ function refresh_item() {
|
|
1708 |
|
1709 |
// update the claimed stock here
|
1710 |
$this->update_claimed_stock();
|
1711 |
-
|
1712 |
do_action_ref_array( 'wpsc_refresh_item', array( &$this ) );
|
1713 |
}
|
1714 |
|
@@ -1833,14 +1832,17 @@ function refresh_item() {
|
|
1833 |
function save_to_db($purchase_log_id) {
|
1834 |
global $wpdb, $wpsc_shipping_modules;
|
1835 |
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
|
|
|
|
|
|
1844 |
|
1845 |
//initialize tax variables
|
1846 |
$tax = 0;
|
@@ -1855,30 +1857,44 @@ function refresh_item() {
|
|
1855 |
$tax = $taxes['tax'];
|
1856 |
}
|
1857 |
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1877 |
|
1878 |
wpsc_update_cartmeta($cart_id, 'sku', $this->sku);
|
1879 |
|
1880 |
-
|
1881 |
-
|
1882 |
$downloads = get_option('max_downloads');
|
1883 |
if($this->is_downloadable == true) {
|
1884 |
|
@@ -1891,19 +1907,32 @@ function refresh_item() {
|
|
1891 |
foreach($product_files as $file){
|
1892 |
// if the file is downloadable, check that the file is real
|
1893 |
$unique_id = sha1(uniqid(mt_rand(), true));
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1907 |
wpsc_update_meta($download_id, '_is_legacy', 'false', 'wpsc_downloads');
|
1908 |
}
|
1909 |
|
@@ -1913,4 +1942,4 @@ function refresh_item() {
|
|
1913 |
}
|
1914 |
|
1915 |
}
|
1916 |
-
?>
|
201 |
*/
|
202 |
function wpsc_cart_shipping() {
|
203 |
global $wpsc_cart;
|
204 |
+
return apply_filters( 'wpsc_cart_shipping', wpsc_currency_display( $wpsc_cart->calculate_total_shipping() ) );
|
205 |
}
|
206 |
|
207 |
|
375 |
}
|
376 |
function wpsc_empty_google_logs(){
|
377 |
global $wpdb;
|
378 |
+
$sql = $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` = '%s'", $_SESSION['wpsc_sessionid'] );
|
379 |
+
$wpdb->query( $sql );
|
380 |
+
unset( $_SESSION['wpsc_sessionid'] );
|
381 |
|
382 |
}
|
383 |
/**
|
447 |
* the shipping quote value function, no parameters
|
448 |
* @return string shipping quote value
|
449 |
*/
|
450 |
+
function wpsc_shipping_quote_value( $numeric = false ) {
|
451 |
global $wpsc_cart;
|
452 |
+
|
453 |
+
$value = apply_filters( 'wpsc_shipping_quote_value', $wpsc_cart->shipping_quote['value'] );
|
454 |
+
|
455 |
+
return ( $numeric ) ? $value : wpsc_currency_display( $value );
|
456 |
+
|
457 |
}
|
458 |
|
459 |
/**
|
723 |
}
|
724 |
|
725 |
if(($this->shipping_quotes != null) && (array_search($this->selected_shipping_option, array_keys($this->shipping_quotes)) === false)) {
|
726 |
+
$this->selected_shipping_option = apply_filters ( 'wpsc_default_shipping_quote', array_pop( array_keys( array_slice ($this->shipping_quotes, 0, 1 ) ) ), $this->shipping_quotes );
|
727 |
}
|
728 |
}
|
729 |
|
800 |
|
801 |
if($add_tax == true) {
|
802 |
if(($country_data['has_regions'] == 1)) {
|
803 |
+
$region_data = $wpdb->get_row( $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN('%s') AND `".WPSC_TABLE_REGION_TAX."`.`id` IN('%s') ", $country_data['id'], $tax_region ), ARRAY_A) ;
|
804 |
$tax_percentage = $region_data['tax'];
|
805 |
} else {
|
806 |
$tax_percentage = $country_data['tax'];
|
813 |
$this->clear_cache();
|
814 |
$this->tax_percentage = $tax_percentage;
|
815 |
|
816 |
+
$this->wpsc_refresh_cart_items();
|
|
|
|
|
817 |
}
|
818 |
}
|
819 |
|
916 |
$priceandstock_id = 0;
|
917 |
|
918 |
if($stock > 0) {
|
919 |
+
$claimed_stock = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(`stock_claimed`) FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `product_id` IN(%d) AND `variation_stock_id` IN('%d')", $product_id, $priceandstock_id ) );
|
920 |
if(($claimed_stock + $quantity) <= $stock) {
|
921 |
$output = true;
|
922 |
} else {
|
1065 |
// Get tax only if it is included
|
1066 |
$tax = ( ! wpsc_tax_isincluded() ) ? $this->calculate_total_tax() : 0.00;
|
1067 |
|
1068 |
+
// Get coupon amount, note that no matter what float precision this
|
1069 |
+
// coupon amount is, it's always saved to the database with rounded
|
1070 |
+
// value anyways
|
1071 |
+
$coupons_amount = round( $this->coupons_amount, 2 );
|
1072 |
|
1073 |
// Calculate the total
|
1074 |
$total = ( ( $subtotal + $shipping + $tax ) > $coupons_amount ) ? ( $subtotal + $shipping + $tax - $coupons_amount ) : 0.00;
|
1120 |
* @access public
|
1121 |
* @return float returns the price as a floating point value
|
1122 |
*/
|
1123 |
+
function calculate_total_tax() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1124 |
|
1125 |
+
$wpec_taxes_controller = new wpec_taxes_controller();
|
1126 |
+
$taxes_total = $wpec_taxes_controller->wpec_taxes_calculate_total();
|
1127 |
+
$this->total_tax = $taxes_total['total'];
|
1128 |
+
|
1129 |
+
if( isset( $taxes_total['rate'] ) )
|
1130 |
+
$this->tax_percentage = $taxes_total['rate'];
|
1131 |
+
|
1132 |
+
return apply_filters( 'wpsc_calculate_total_tax', $this->total_tax );
|
1133 |
+
}
|
1134 |
|
1135 |
|
1136 |
|
1141 |
* @param boolean for_shipping = exclude items with no shipping,
|
1142 |
* @return float returns the price as a floating point value
|
1143 |
*/
|
1144 |
+
function calculate_total_weight($for_shipping = false) {
|
1145 |
global $wpdb;
|
1146 |
$total = '';
|
1147 |
if($for_shipping == true ) {
|
1199 |
}else{
|
1200 |
$total = 0;
|
1201 |
}
|
1202 |
+
|
1203 |
+
return apply_filters( 'wpsc_convert_total_shipping', $total );
|
1204 |
+
|
1205 |
+
}
|
1206 |
|
1207 |
/**
|
1208 |
* has_total_shipping_discount method, checks whether the carts subtotal is larger or equal to the shipping discount * value
|
1475 |
/**
|
1476 |
* Applying Coupons
|
1477 |
*/
|
1478 |
+
function apply_coupons( $coupons_amount = '', $coupon_name = '' ){
|
1479 |
$this->clear_cache();
|
1480 |
+
$this->coupons_name = $coupon_name;
|
1481 |
+
$this->coupons_amount = apply_filters( 'wpsc_coupons_amount', $coupons_amount, $coupon_name );
|
1482 |
$this->calculate_total_price();
|
1483 |
if ( $this->total_price < 0 ) {
|
1484 |
$this->coupons_amount += $this->total_price;
|
1603 |
$this->stock = get_post_meta( $product_id, '_wpsc_stock', true );
|
1604 |
$this->is_donation = get_post_meta( $product_id, '_wpsc_is_donation', true );
|
1605 |
|
|
|
1606 |
if ( isset( $special_price ) && $special_price > 0 && $special_price < $price )
|
1607 |
$price = $special_price;
|
1608 |
$priceandstock_id = 0;
|
1621 |
}
|
1622 |
}
|
1623 |
|
1624 |
+
$price = apply_filters( 'wpsc_price', $price, $product_id );
|
1625 |
// create the string containing the product name.
|
1626 |
$product_name = apply_filters( 'wpsc_cart_product_title', $product->post_title, $product_id );
|
1627 |
|
1707 |
|
1708 |
// update the claimed stock here
|
1709 |
$this->update_claimed_stock();
|
1710 |
+
|
1711 |
do_action_ref_array( 'wpsc_refresh_item', array( &$this ) );
|
1712 |
}
|
1713 |
|
1832 |
function save_to_db($purchase_log_id) {
|
1833 |
global $wpdb, $wpsc_shipping_modules;
|
1834 |
|
1835 |
+
|
1836 |
+
$method = $this->cart->selected_shipping_method;
|
1837 |
+
$shipping = 0;
|
1838 |
+
|
1839 |
+
if( ! empty( $method ) && method_exists( $wpsc_shipping_modules[$method], "get_item_shipping" ) )
|
1840 |
+
$shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping( $this );
|
1841 |
+
|
1842 |
+
if( $this->cart->has_total_shipping_discount() )
|
1843 |
+
$shipping = 0;
|
1844 |
+
|
1845 |
+
$shipping = apply_filters( 'wpsc_item_shipping_amount_db', $shipping, $this );
|
1846 |
|
1847 |
//initialize tax variables
|
1848 |
$tax = 0;
|
1857 |
$tax = $taxes['tax'];
|
1858 |
}
|
1859 |
|
1860 |
+
$wpdb->insert(
|
1861 |
+
WPSC_TABLE_CART_CONTENTS,
|
1862 |
+
array(
|
1863 |
+
'prodid' => $this->product_id,
|
1864 |
+
'name' => $this->product_name,
|
1865 |
+
'purchaseid' => $purchase_log_id,
|
1866 |
+
'price' => $this->unit_price,
|
1867 |
+
'pnp' => $shipping,
|
1868 |
+
'tax_charged' => $tax,
|
1869 |
+
'gst' => $tax_rate,
|
1870 |
+
'quantity' => $this->quantity,
|
1871 |
+
'donation' => $this->is_donation,
|
1872 |
+
'no_shipping' => 0,
|
1873 |
+
'custom_message' => $this->custom_message,
|
1874 |
+
'files' => serialize($this->custom_file),
|
1875 |
+
'meta' => NULL
|
1876 |
+
),
|
1877 |
+
array(
|
1878 |
+
'%d',
|
1879 |
+
'%s',
|
1880 |
+
'%d',
|
1881 |
+
'%f',
|
1882 |
+
'%f',
|
1883 |
+
'%f',
|
1884 |
+
'%f',
|
1885 |
+
'%s',
|
1886 |
+
'%d',
|
1887 |
+
'%d',
|
1888 |
+
'%s',
|
1889 |
+
'%s',
|
1890 |
+
'%s'
|
1891 |
+
)
|
1892 |
+
);
|
1893 |
+
|
1894 |
+
$cart_id = $wpdb->get_var( "SELECT " . $wpdb->insert_id . " AS `id` FROM `".WPSC_TABLE_CART_CONTENTS."` LIMIT 1");
|
1895 |
|
1896 |
wpsc_update_cartmeta($cart_id, 'sku', $this->sku);
|
1897 |
|
|
|
|
|
1898 |
$downloads = get_option('max_downloads');
|
1899 |
if($this->is_downloadable == true) {
|
1900 |
|
1907 |
foreach($product_files as $file){
|
1908 |
// if the file is downloadable, check that the file is real
|
1909 |
$unique_id = sha1(uniqid(mt_rand(), true));
|
1910 |
+
|
1911 |
+
$wpdb->insert(
|
1912 |
+
WPSC_TABLE_DOWNLOAD_STATUS,
|
1913 |
+
array(
|
1914 |
+
'product_id' => $this->product_id,
|
1915 |
+
'fileid' => $file->ID,
|
1916 |
+
'purchid' => $purchase_log_id,
|
1917 |
+
'cartid' => $cart_id,
|
1918 |
+
'uniqueid' => $unique_id,
|
1919 |
+
'downloads' => $downloads,
|
1920 |
+
'active' => 0,
|
1921 |
+
'datetime' => date( 'Y-m-d H:i:s' )
|
1922 |
+
),
|
1923 |
+
array(
|
1924 |
+
'%d',
|
1925 |
+
'%d',
|
1926 |
+
'%d',
|
1927 |
+
'%d',
|
1928 |
+
'%s',
|
1929 |
+
'%s',
|
1930 |
+
'%d',
|
1931 |
+
'%s',
|
1932 |
+
)
|
1933 |
+
);
|
1934 |
+
|
1935 |
+
$download_id = $wpdb->get_var( "SELECT " . $wpdb->insert_id . " AS `id` FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` LIMIT 1");
|
1936 |
wpsc_update_meta($download_id, '_is_legacy', 'false', 'wpsc_downloads');
|
1937 |
}
|
1938 |
|
1942 |
}
|
1943 |
|
1944 |
}
|
1945 |
+
?>
|
wpsc-includes/category.functions.php
CHANGED
@@ -482,15 +482,15 @@ function nzshpcrt_display_categories_groups() {
|
|
482 |
*/
|
483 |
function wpsc_list_subcategories($category_id = null) {
|
484 |
global $wpdb,$category_data;
|
485 |
-
|
486 |
-
$category_list = $wpdb->get_col("SELECT `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `category_parent` =
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
$category_list = array_merge((array)$category_list, (array)wpsc_list_subcategories($subcategory_id));
|
491 |
}
|
492 |
}
|
493 |
-
|
494 |
}
|
495 |
|
496 |
|
@@ -539,4 +539,43 @@ function wpsc_get_terms_category_sort_filter($terms){
|
|
539 |
return array_values( $new_terms );
|
540 |
}
|
541 |
add_filter('get_terms','wpsc_get_terms_category_sort_filter');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
?>
|
482 |
*/
|
483 |
function wpsc_list_subcategories($category_id = null) {
|
484 |
global $wpdb,$category_data;
|
485 |
+
|
486 |
+
$category_list = $wpdb->get_col( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `category_parent` = %d", $category_id ) );
|
487 |
+
|
488 |
+
if($category_list != null) {
|
489 |
+
foreach($category_list as $subcategory_id) {
|
490 |
$category_list = array_merge((array)$category_list, (array)wpsc_list_subcategories($subcategory_id));
|
491 |
}
|
492 |
}
|
493 |
+
return $category_list;
|
494 |
}
|
495 |
|
496 |
|
539 |
return array_values( $new_terms );
|
540 |
}
|
541 |
add_filter('get_terms','wpsc_get_terms_category_sort_filter');
|
542 |
+
|
543 |
+
|
544 |
+
function wpsc_get_terms_variation_sort_filter($terms){
|
545 |
+
$new_terms = array();
|
546 |
+
$unsorted = array();
|
547 |
+
|
548 |
+
foreach ( $terms as $term ) {
|
549 |
+
if ( ! is_object( $term ) )
|
550 |
+
return $terms;
|
551 |
+
|
552 |
+
$term_order = ( $term->taxonomy == 'wpsc-variation' ) ? wpsc_get_meta( $term->term_id, 'sort_order', 'wpsc_variation' ) : null;
|
553 |
+
$term_order = (int) $term_order;
|
554 |
+
|
555 |
+
// unsorted categories should go to the top of the list
|
556 |
+
if ( $term_order == 0 ) {
|
557 |
+
$term->sort_order = $term_order;
|
558 |
+
$unsorted[] = $term;
|
559 |
+
continue;
|
560 |
+
}
|
561 |
+
|
562 |
+
while ( isset( $new_terms[$term_order] ) ) {
|
563 |
+
$term_order ++;
|
564 |
+
}
|
565 |
+
|
566 |
+
$term->sort_order = $term_order;
|
567 |
+
$new_terms[$term_order] = $term;
|
568 |
+
}
|
569 |
+
|
570 |
+
if ( ! empty( $new_terms ) )
|
571 |
+
ksort( $new_terms );
|
572 |
+
|
573 |
+
for ( $i = count( $unsorted ) - 1; $i >= 0; $i-- ) {
|
574 |
+
array_unshift( $new_terms, $unsorted[$i] );
|
575 |
+
}
|
576 |
+
|
577 |
+
return array_values( $new_terms );
|
578 |
+
}
|
579 |
+
add_filter('get_terms','wpsc_get_terms_variation_sort_filter');
|
580 |
+
|
581 |
?>
|
wpsc-includes/checkout.class.php
CHANGED
@@ -9,42 +9,6 @@
|
|
9 |
* @package wp-e-commerce
|
10 |
* @subpackage wpsc-checkout-classes
|
11 |
*/
|
12 |
-
function wpsc_kill_xss( $string ) {
|
13 |
-
if ( get_magic_quotes_gpc ( ) ) {
|
14 |
-
$string = stripslashes( $string );
|
15 |
-
}
|
16 |
-
$string = str_replace( array( "&", "<", ">" ), array( "&amp;", "&lt;", "&gt;" ), $string );
|
17 |
-
// fix &entitiy\n;
|
18 |
-
$string = preg_replace( '#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $string );
|
19 |
-
$string = preg_replace( '#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $string );
|
20 |
-
$string = html_entity_decode( $string, ENT_COMPAT, "UTF-8" );
|
21 |
-
|
22 |
-
// remove any attribute starting with "on" or xmlns
|
23 |
-
$string = preg_replace( '#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $string );
|
24 |
-
|
25 |
-
// remove javascript: and vbscript: protocol
|
26 |
-
$string = preg_replace( '#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $string );
|
27 |
-
$string = preg_replace( '#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $string );
|
28 |
-
$string = preg_replace( '#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*-moz-binding[\x00-\x20]*:#Uu', '$1=$2nomozbinding...', $string );
|
29 |
-
$string = preg_replace( '#([a-z]*)[\x00-\x20\/]*=[\x00-\x20\/]*([\`\'\"]*)[\x00-\x20\/]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $string );
|
30 |
-
|
31 |
-
//remove any style attributes, IE allows too much stupid things in them, eg.
|
32 |
-
//<span style="width: expression(alert('Ping!'));"></span>
|
33 |
-
// and in general you really don't want style declarations in your UGC
|
34 |
-
|
35 |
-
$string = preg_replace( '#(<[^>]+[\x00-\x20\"\'\/])style[^>]*>#iUu', "$1>", $string );
|
36 |
-
|
37 |
-
//remove namespaced elements (we do not need them...)
|
38 |
-
$string = preg_replace( '#</*\w+:\w[^>]*>#i', "", $string );
|
39 |
-
//remove really unwanted tags
|
40 |
-
|
41 |
-
do {
|
42 |
-
$oldstring = $string;
|
43 |
-
$string = preg_replace( '#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $string );
|
44 |
-
} while ( $oldstring != $string );
|
45 |
-
|
46 |
-
return $string;
|
47 |
-
}
|
48 |
|
49 |
/**
|
50 |
* wpsc has regions checks to see whether a country has regions or not
|
@@ -56,7 +20,7 @@ function wpsc_kill_xss( $string ) {
|
|
56 |
*/
|
57 |
function wpsc_has_regions($country){
|
58 |
global $wpdb;
|
59 |
-
$country_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN(
|
60 |
if ($country_data['has_regions'] == 1)
|
61 |
return true;
|
62 |
else
|
@@ -93,7 +57,7 @@ function wpsc_check_purchase_processed($processed){
|
|
93 |
function wpsc_get_buyers_email($purchase_id){
|
94 |
global $wpdb;
|
95 |
$email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1", ARRAY_A );
|
96 |
-
$email = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id
|
97 |
return $email;
|
98 |
|
99 |
}
|
@@ -107,7 +71,7 @@ function wpsc_get_buyers_email($purchase_id){
|
|
107 |
function wpsc_google_checkout_submit() {
|
108 |
global $wpdb, $wpsc_cart, $current_user;
|
109 |
$wpsc_checkout = new wpsc_checkout();
|
110 |
-
$purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN(
|
111 |
get_currentuserinfo();
|
112 |
if ( $current_user->display_name != '' ) {
|
113 |
foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
|
@@ -402,7 +366,7 @@ function wpsc_checkout_form_field() {
|
|
402 |
function wpsc_shipping_region_list( $selected_country, $selected_region, $shippingdetails = false ) {
|
403 |
global $wpdb;
|
404 |
$output = '';
|
405 |
-
$region_data = $wpdb->get_results( "SELECT `regions`.* 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(
|
406 |
$js = '';
|
407 |
if ( !$shippingdetails ) {
|
408 |
$js = "onchange='submit_change_country();'";
|
@@ -521,7 +485,7 @@ class wpsc_checkout {
|
|
521 |
*/
|
522 |
function wpsc_checkout( $checkout_set = 0 ) {
|
523 |
global $wpdb;
|
524 |
-
$this->checkout_items = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`=
|
525 |
|
526 |
$category_list = wpsc_cart_item_categories( true );
|
527 |
$additional_form_list = array( );
|
@@ -584,7 +548,7 @@ class wpsc_checkout {
|
|
584 |
*/
|
585 |
function get_checkout_options( $id ) {
|
586 |
global $wpdb;
|
587 |
-
$sql = 'SELECT `options` FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE `id
|
588 |
$options = $wpdb->get_var( $sql );
|
589 |
$options = unserialize( $options );
|
590 |
return $options;
|
@@ -642,7 +606,7 @@ class wpsc_checkout {
|
|
642 |
|
643 |
case "delivery_country":
|
644 |
if ( wpsc_uses_shipping ( ) ) {
|
645 |
-
$country_name = $wpdb->get_var( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`=
|
646 |
$output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_country' name='collected_data[{$this->checkout_item->id}]' value='" . esc_attr( $_SESSION['wpsc_delivery_country'] ) . "' size='4' /><span class='shipping_country_name'>" . $country_name . "</span> ";
|
647 |
} else {
|
648 |
$checkoutfields = true;
|
@@ -653,7 +617,7 @@ class wpsc_checkout {
|
|
653 |
$options = $this->get_checkout_options( $this->checkout_item->id );
|
654 |
if ( $options != '' ) {
|
655 |
$output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>";
|
656 |
-
$output .= "<option value='-1'>" .
|
657 |
foreach ( (array)$options as $label => $value ) {
|
658 |
$value = esc_attr(str_replace( ' ', '', $value ) );
|
659 |
$output .="<option " . selected( $value, $saved_form_data, false ) . " value='" . esc_attr( $value ) . "'>" . esc_html( $label ) . "</option>\n\r";
|
@@ -883,22 +847,82 @@ class wpsc_checkout {
|
|
883 |
$shipping_state = $value[1];
|
884 |
|
885 |
$value = $value[0];
|
886 |
-
$prepared_query = $wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
} else {
|
888 |
foreach ( (array)$value as $v ) {
|
889 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
890 |
}
|
891 |
}
|
892 |
} else {
|
893 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
894 |
}
|
895 |
-
$wpdb->query( $prepared_query );
|
896 |
}
|
897 |
|
898 |
// update the states
|
899 |
-
$wpdb->
|
900 |
-
|
901 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
|
903 |
/**
|
904 |
* Function that checks how many checkout fields are stored in checkout form fields table
|
9 |
* @package wp-e-commerce
|
10 |
* @subpackage wpsc-checkout-classes
|
11 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* wpsc has regions checks to see whether a country has regions or not
|
20 |
*/
|
21 |
function wpsc_has_regions($country){
|
22 |
global $wpdb;
|
23 |
+
$country_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN(%s) LIMIT 1", $country ), ARRAY_A );
|
24 |
if ($country_data['has_regions'] == 1)
|
25 |
return true;
|
26 |
else
|
57 |
function wpsc_get_buyers_email($purchase_id){
|
58 |
global $wpdb;
|
59 |
$email_form_field = $wpdb->get_results( "SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `checkout_order` ASC LIMIT 1", ARRAY_A );
|
60 |
+
$email = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1", $purchase_id ) );
|
61 |
return $email;
|
62 |
|
63 |
}
|
71 |
function wpsc_google_checkout_submit() {
|
72 |
global $wpdb, $wpsc_cart, $current_user;
|
73 |
$wpsc_checkout = new wpsc_checkout();
|
74 |
+
$purchase_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` IN(%s) LIMIT 1", $_SESSION['wpsc_sessionid'] );
|
75 |
get_currentuserinfo();
|
76 |
if ( $current_user->display_name != '' ) {
|
77 |
foreach ( $wpsc_checkout->checkout_items as $checkoutfield ) {
|
366 |
function wpsc_shipping_region_list( $selected_country, $selected_region, $shippingdetails = false ) {
|
367 |
global $wpdb;
|
368 |
$output = '';
|
369 |
+
$region_data = $wpdb->get_results( $wpdb->prepare( "SELECT `regions`.* 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(%s)", $selected_country ), ARRAY_A );
|
370 |
$js = '';
|
371 |
if ( !$shippingdetails ) {
|
372 |
$js = "onchange='submit_change_country();'";
|
485 |
*/
|
486 |
function wpsc_checkout( $checkout_set = 0 ) {
|
487 |
global $wpdb;
|
488 |
+
$this->checkout_items = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`= %s ORDER BY `checkout_order`;", $checkout_set ) );
|
489 |
|
490 |
$category_list = wpsc_cart_item_categories( true );
|
491 |
$additional_form_list = array( );
|
548 |
*/
|
549 |
function get_checkout_options( $id ) {
|
550 |
global $wpdb;
|
551 |
+
$sql = $wpdb->prepare( 'SELECT `options` FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE `id` = %d', $id );
|
552 |
$options = $wpdb->get_var( $sql );
|
553 |
$options = unserialize( $options );
|
554 |
return $options;
|
606 |
|
607 |
case "delivery_country":
|
608 |
if ( wpsc_uses_shipping ( ) ) {
|
609 |
+
$country_name = $wpdb->get_var( $wpdb->prepare( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode`= %s LIMIT 1", $_SESSION['wpsc_delivery_country'] ) );
|
610 |
$output = "<input title='" . $this->checkout_item->unique_name . "' type='hidden' id='" . $this->form_element_id() . "' class='shipping_country' name='collected_data[{$this->checkout_item->id}]' value='" . esc_attr( $_SESSION['wpsc_delivery_country'] ) . "' size='4' /><span class='shipping_country_name'>" . $country_name . "</span> ";
|
611 |
} else {
|
612 |
$checkoutfields = true;
|
617 |
$options = $this->get_checkout_options( $this->checkout_item->id );
|
618 |
if ( $options != '' ) {
|
619 |
$output = "<select name='collected_data[{$this->checkout_item->id}]" . $an_array . "'>";
|
620 |
+
$output .= "<option value='-1'>" . _x( 'Select an Option', 'Dropdown default when called within checkout class' , 'wpsc' ) . "</option>";
|
621 |
foreach ( (array)$options as $label => $value ) {
|
622 |
$value = esc_attr(str_replace( ' ', '', $value ) );
|
623 |
$output .="<option " . selected( $value, $saved_form_data, false ) . " value='" . esc_attr( $value ) . "'>" . esc_html( $label ) . "</option>\n\r";
|
847 |
$shipping_state = $value[1];
|
848 |
|
849 |
$value = $value[0];
|
850 |
+
$prepared_query = $wpdb->insert(
|
851 |
+
WPSC_TABLE_SUBMITED_FORM_DATA,
|
852 |
+
array(
|
853 |
+
'log_id' => $purchase_id,
|
854 |
+
'form_id' => $form_data->id,
|
855 |
+
'value' => $value
|
856 |
+
),
|
857 |
+
array(
|
858 |
+
'%d',
|
859 |
+
'%d',
|
860 |
+
'%s'
|
861 |
+
)
|
862 |
+
);
|
863 |
} else {
|
864 |
foreach ( (array)$value as $v ) {
|
865 |
+
$prepared_query = $wpdb->insert(
|
866 |
+
WPSC_TABLE_SUBMITED_FORM_DATA,
|
867 |
+
array(
|
868 |
+
'log_id' => $purchase_id,
|
869 |
+
'form_id' => $form_data->id,
|
870 |
+
'value' => $v
|
871 |
+
),
|
872 |
+
array(
|
873 |
+
'%d',
|
874 |
+
'%d',
|
875 |
+
'%s'
|
876 |
+
)
|
877 |
+
);
|
878 |
}
|
879 |
}
|
880 |
} else {
|
881 |
+
$prepared_query = $wpdb->insert(
|
882 |
+
WPSC_TABLE_SUBMITED_FORM_DATA,
|
883 |
+
array(
|
884 |
+
'log_id' => $purchase_id,
|
885 |
+
'form_id' => $form_data->id,
|
886 |
+
'value' => $value
|
887 |
+
),
|
888 |
+
array(
|
889 |
+
'%d',
|
890 |
+
'%d',
|
891 |
+
'%s'
|
892 |
+
)
|
893 |
+
);
|
894 |
}
|
|
|
895 |
}
|
896 |
|
897 |
// update the states
|
898 |
+
$wpdb->insert(
|
899 |
+
WPSC_TABLE_SUBMITED_FORM_DATA,
|
900 |
+
array(
|
901 |
+
'log_id' => $purchase_id,
|
902 |
+
'form_id' => $shipping_state_id,
|
903 |
+
'value' => $shipping_state
|
904 |
+
),
|
905 |
+
array(
|
906 |
+
'%d',
|
907 |
+
'%d',
|
908 |
+
'%s'
|
909 |
+
)
|
910 |
+
);
|
911 |
+
$wpdb->insert(
|
912 |
+
WPSC_TABLE_SUBMITED_FORM_DATA,
|
913 |
+
array(
|
914 |
+
'log_id' => $purchase_id,
|
915 |
+
'form_id' => $billing_state_id,
|
916 |
+
'value' => $billing_state
|
917 |
+
),
|
918 |
+
array(
|
919 |
+
'%d',
|
920 |
+
'%d',
|
921 |
+
'%s'
|
922 |
+
)
|
923 |
+
);
|
924 |
+
|
925 |
+
}
|
926 |
|
927 |
/**
|
928 |
* Function that checks how many checkout fields are stored in checkout form fields table
|
wpsc-includes/coupons.class.php
CHANGED
@@ -6,12 +6,13 @@
|
|
6 |
*/
|
7 |
function wpsc_uses_coupons() {
|
8 |
global $wpsc_coupons;
|
9 |
-
|
|
|
10 |
$wpsc_coupons = new wpsc_coupons();
|
11 |
-
|
12 |
-
if(is_object($wpsc_coupons))
|
13 |
return $wpsc_coupons->uses_coupons();
|
14 |
-
|
15 |
return false;
|
16 |
}
|
17 |
function wpsc_coupons_error(){
|
@@ -56,47 +57,48 @@ class wpsc_coupons {
|
|
56 |
* @return bool True if coupon code exists, False otherwise.
|
57 |
*/
|
58 |
function wpsc_coupons($code = ''){
|
59 |
-
|
60 |
|
61 |
-
if ($code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
return false;
|
63 |
} else {
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'active' => '',
|
78 |
-
'use-once' => '',
|
79 |
-
'use-x-times' => '',
|
80 |
-
'free-shipping' => '',
|
81 |
-
'start' => '',
|
82 |
-
'expiry' => '',
|
83 |
-
'every_product' => '',
|
84 |
-
), $coupon_data );
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
}
|
|
|
100 |
}
|
101 |
|
102 |
/**
|
@@ -332,7 +334,7 @@ class wpsc_coupons {
|
|
332 |
return false;
|
333 |
}
|
334 |
} else if ($c['property'] == 'total_quantity'){
|
335 |
-
$total_quantity =
|
336 |
switch($c['logic']) {
|
337 |
case 'equal'://Checks if the quantity of products in the cart equals condition value
|
338 |
if ($total_quantity == $c['value'])
|
6 |
*/
|
7 |
function wpsc_uses_coupons() {
|
8 |
global $wpsc_coupons;
|
9 |
+
|
10 |
+
if( empty( $wpsc_coupons ) )
|
11 |
$wpsc_coupons = new wpsc_coupons();
|
12 |
+
|
13 |
+
if( is_object( $wpsc_coupons ) )
|
14 |
return $wpsc_coupons->uses_coupons();
|
15 |
+
|
16 |
return false;
|
17 |
}
|
18 |
function wpsc_coupons_error(){
|
57 |
* @return bool True if coupon code exists, False otherwise.
|
58 |
*/
|
59 |
function wpsc_coupons($code = ''){
|
60 |
+
global $wpdb;
|
61 |
|
62 |
+
if ( empty( $code ) )
|
63 |
+
return false;
|
64 |
+
|
65 |
+
$this->code = $code;
|
66 |
+
|
67 |
+
$coupon_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_COUPON_CODES."` WHERE coupon_code = %s LIMIT 1", $code ) , ARRAY_A );
|
68 |
+
|
69 |
+
if ( ( $coupon_data == '' ) || ( $coupon_data == null ) || ( strtotime( $coupon_data['expiry'] ) < time() ) ) {
|
70 |
+
$this->errormsg = false;
|
71 |
return false;
|
72 |
} else {
|
73 |
+
$coupon_data = array_merge( array(
|
74 |
+
'value' => '',
|
75 |
+
'is-percentage' => '',
|
76 |
+
'condition' => '',
|
77 |
+
'is-used' => '',
|
78 |
+
'active' => '',
|
79 |
+
'use-once' => '',
|
80 |
+
'use-x-times' => '',
|
81 |
+
'free-shipping' => '',
|
82 |
+
'start' => '',
|
83 |
+
'expiry' => '',
|
84 |
+
'every_product' => ''
|
85 |
+
), $coupon_data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
+
$this->value = $coupon_data['value'];
|
88 |
+
$this->is_percentage = $coupon_data['is-percentage'];
|
89 |
+
$this->conditions = unserialize($coupon_data['condition']);
|
90 |
+
$this->is_used = $coupon_data['is-used'];
|
91 |
+
$this->active = $coupon_data['active'];
|
92 |
+
$this->use_once = $coupon_data['use-once'];
|
93 |
+
$this->start_date = $coupon_data['start'];
|
94 |
+
$this->end_date = $coupon_data['expiry'];
|
95 |
+
$this->every_product = $coupon_data['every_product'];
|
96 |
+
$this->errormsg = true;
|
97 |
+
$valid = $this->validate_coupon();
|
98 |
+
|
99 |
+
return $valid;
|
100 |
}
|
101 |
+
|
102 |
}
|
103 |
|
104 |
/**
|
334 |
return false;
|
335 |
}
|
336 |
} else if ($c['property'] == 'total_quantity'){
|
337 |
+
$total_quantity = wpsc_cart_item_count();
|
338 |
switch($c['logic']) {
|
339 |
case 'equal'://Checks if the quantity of products in the cart equals condition value
|
340 |
if ($total_quantity == $c['value'])
|
wpsc-includes/display.functions.php
CHANGED
@@ -79,7 +79,7 @@ function wpsc_also_bought( $product_id ) {
|
|
79 |
$image_display_width = 96;
|
80 |
|
81 |
$output = '';
|
82 |
-
$also_bought = $wpdb->get_results( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`=
|
83 |
if ( count( $also_bought ) > 0 ) {
|
84 |
$output .= "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
|
85 |
$output .= "<div class='wpsc_also_bought'>";
|
@@ -313,13 +313,13 @@ function wpsc_obtain_the_title() {
|
|
313 |
$full_product_name = $wpsc_title_data['product'][$product_name];
|
314 |
} else if ( $product_name != '' ) {
|
315 |
$product_id = $wp_query->post->ID;
|
316 |
-
$full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`=
|
317 |
$wpsc_title_data['product'][$product_name] = $full_product_name;
|
318 |
} else {
|
319 |
if(isset($_REQUEST['product_id'])){
|
320 |
$product_id = absint( $_REQUEST['product_id'] );
|
321 |
-
$product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`=
|
322 |
-
$full_product_name = $wpdb->get_var( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`=
|
323 |
$wpsc_title_data['product'][$product_name] = $full_product_name;
|
324 |
}else{
|
325 |
//This has to exist, otherwise we would have bailed earlier.
|
@@ -355,7 +355,7 @@ function wpsc_obtain_the_description() {
|
|
355 |
|
356 |
if ( is_numeric( $_GET['product_id'] ) ) {
|
357 |
$product_id = absint( $_GET['product_id'] );
|
358 |
-
$output = $wpdb->get_var( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id
|
359 |
}
|
360 |
return $output;
|
361 |
}
|
79 |
$image_display_width = 96;
|
80 |
|
81 |
$output = '';
|
82 |
+
$also_bought = $wpdb->get_results( $wpdb->prepare( "SELECT `" . $wpdb->posts . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . $wpdb->posts . "` WHERE `selected_product`= %d AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . $wpdb->posts . "`.`id` AND `" . $wpdb->posts . "`.`post_status` IN('publish','protected') ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT $also_bought_limit", $product_id ), ARRAY_A );
|
83 |
if ( count( $also_bought ) > 0 ) {
|
84 |
$output .= "<h2 class='prodtitles wpsc_also_bought' >" . __( 'People who bought this item also bought', 'wpsc' ) . "</h2>";
|
85 |
$output .= "<div class='wpsc_also_bought'>";
|
313 |
$full_product_name = $wpsc_title_data['product'][$product_name];
|
314 |
} else if ( $product_name != '' ) {
|
315 |
$product_id = $wp_query->post->ID;
|
316 |
+
$full_product_name = $wpdb->get_var( $wpdb->prepare( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`= %d LIMIT 1", $product_id ) );
|
317 |
$wpsc_title_data['product'][$product_name] = $full_product_name;
|
318 |
} else {
|
319 |
if(isset($_REQUEST['product_id'])){
|
320 |
$product_id = absint( $_REQUEST['product_id'] );
|
321 |
+
$product_name = $wpdb->get_var( $wpdb->prepare( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`= %d LIMIT 1", $product_id ) );
|
322 |
+
$full_product_name = $wpdb->get_var( $wpdb->prepare( "SELECT `post_title` FROM `$wpdb->posts` WHERE `ID`= %d LIMIT 1", $product_id ) );
|
323 |
$wpsc_title_data['product'][$product_name] = $full_product_name;
|
324 |
}else{
|
325 |
//This has to exist, otherwise we would have bailed earlier.
|
355 |
|
356 |
if ( is_numeric( $_GET['product_id'] ) ) {
|
357 |
$product_id = absint( $_GET['product_id'] );
|
358 |
+
$output = $wpdb->get_var( $wpdb->prepare( "SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id` = %d LIMIT 1", $product_id ) );
|
359 |
}
|
360 |
return $output;
|
361 |
}
|
wpsc-includes/form-display.functions.php
CHANGED
@@ -28,7 +28,7 @@ function nzshpcrt_region_list( $selected_country = null, $selected_region = null
|
|
28 |
$selected_region = get_option( 'base_region' );
|
29 |
|
30 |
$output = "";
|
31 |
-
$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(
|
32 |
|
33 |
if ( $region_list != null ) {
|
34 |
$output .= "<option value=''>None</option>";
|
@@ -169,8 +169,8 @@ function wpsc_select_product_file( $product_id = null ) {
|
|
169 |
);
|
170 |
|
171 |
$attached_files = (array)get_posts( $args );
|
172 |
-
|
173 |
-
$output
|
174 |
$output .= "<div class='ui-widget-content multiple-select select_product_file'>";
|
175 |
$num = 0;
|
176 |
|
28 |
$selected_region = get_option( 'base_region' );
|
29 |
|
30 |
$output = "";
|
31 |
+
$region_list = $wpdb->get_results( $wpdb->prepare( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN(%s) AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", $selected_country ), ARRAY_A );
|
32 |
|
33 |
if ( $region_list != null ) {
|
34 |
$output .= "<option value=''>None</option>";
|
169 |
);
|
170 |
|
171 |
$attached_files = (array)get_posts( $args );
|
172 |
+
$output = "<a name='wpsc_downloads'></a>";
|
173 |
+
$output .= "<span class='admin_product_notes select_product_note '>" . __( 'File(s) attached: ', 'wpsc' ) . "</span><br>";
|
174 |
$output .= "<div class='ui-widget-content multiple-select select_product_file'>";
|
175 |
$num = 0;
|
176 |
|
wpsc-includes/image_processing.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
function image_processing($image_input, $image_output, $width = null, $height = null,$imagefield='') {
|
3 |
-
|
4 |
/*
|
5 |
* this handles all resizing of images that results in a file being saved, if no width and height is supplied, then it just copies the image
|
6 |
*/
|
@@ -24,7 +24,7 @@ global $wpdb;
|
|
24 |
|
25 |
default:
|
26 |
move_uploaded_file($image_input, ($imagedir.basename($_FILES[$imagefield]['name'])));
|
27 |
-
$image =
|
28 |
return true;
|
29 |
exit();
|
30 |
break;
|
@@ -128,7 +128,7 @@ global $wpdb;
|
|
128 |
}
|
129 |
} else {
|
130 |
copy($image_input, $image_output);
|
131 |
-
$image =
|
132 |
return $image;
|
133 |
}
|
134 |
return false;
|
1 |
<?php
|
2 |
function image_processing($image_input, $image_output, $width = null, $height = null,$imagefield='') {
|
3 |
+
|
4 |
/*
|
5 |
* this handles all resizing of images that results in a file being saved, if no width and height is supplied, then it just copies the image
|
6 |
*/
|
24 |
|
25 |
default:
|
26 |
move_uploaded_file($image_input, ($imagedir.basename($_FILES[$imagefield]['name'])));
|
27 |
+
$image = esc_attr(basename($_FILES[$imagefield]['name']));
|
28 |
return true;
|
29 |
exit();
|
30 |
break;
|
128 |
}
|
129 |
} else {
|
130 |
copy($image_input, $image_output);
|
131 |
+
$image = esc_attr(basename($_FILES[$imagefield]['name']));
|
132 |
return $image;
|
133 |
}
|
134 |
return false;
|
wpsc-includes/merchant.class.php
CHANGED
@@ -112,9 +112,9 @@ class wpsc_merchant {
|
|
112 |
// Get purchase data, regardless of being fed the ID or the sessionid
|
113 |
if ( $this->purchase_id > 0 ) {
|
114 |
$purchase_id = & $this->purchase_id;
|
115 |
-
$purchase_logs = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` =
|
116 |
} else if ( $this->session_id != null ) {
|
117 |
-
$purchase_logs = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` =
|
118 |
$this->purchase_id = $purchase_logs['id'];
|
119 |
$purchase_id = & $this->purchase_id;
|
120 |
}
|
@@ -304,9 +304,19 @@ class wpsc_merchant {
|
|
304 |
*/
|
305 |
function set_purchase_processed_by_purchid( $status=1 ) {
|
306 |
global $wpdb;
|
307 |
-
|
308 |
-
$wpdb->
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
/**
|
312 |
* set_purchase_processed_by_sessionid, this helps change the purchase log status
|
@@ -315,7 +325,17 @@ class wpsc_merchant {
|
|
315 |
function set_purchase_processed_by_sessionid( $status=1 ) {
|
316 |
global $wpdb;
|
317 |
|
318 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
}
|
320 |
|
321 |
/**
|
@@ -324,8 +344,21 @@ class wpsc_merchant {
|
|
324 |
function set_transaction_details( $transaction_id, $status = 1 ) {
|
325 |
global $wpdb;
|
326 |
|
327 |
-
$
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
/**
|
112 |
// Get purchase data, regardless of being fed the ID or the sessionid
|
113 |
if ( $this->purchase_id > 0 ) {
|
114 |
$purchase_id = & $this->purchase_id;
|
115 |
+
$purchase_logs = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = %d LIMIT 1", $purchase_id ), ARRAY_A );
|
116 |
} else if ( $this->session_id != null ) {
|
117 |
+
$purchase_logs = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s LIMIT 1", $this->session_id ), ARRAY_A );
|
118 |
$this->purchase_id = $purchase_logs['id'];
|
119 |
$purchase_id = & $this->purchase_id;
|
120 |
}
|
304 |
*/
|
305 |
function set_purchase_processed_by_purchid( $status=1 ) {
|
306 |
global $wpdb;
|
307 |
+
|
308 |
+
$wpdb->update(
|
309 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
310 |
+
array(
|
311 |
+
'processed' => $status
|
312 |
+
),
|
313 |
+
array(
|
314 |
+
'id' => $this->purchase_id
|
315 |
+
),
|
316 |
+
'%d',
|
317 |
+
'%d'
|
318 |
+
);
|
319 |
+
}
|
320 |
|
321 |
/**
|
322 |
* set_purchase_processed_by_sessionid, this helps change the purchase log status
|
325 |
function set_purchase_processed_by_sessionid( $status=1 ) {
|
326 |
global $wpdb;
|
327 |
|
328 |
+
$wpdb->update(
|
329 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
330 |
+
array(
|
331 |
+
'processed' => $status
|
332 |
+
),
|
333 |
+
array(
|
334 |
+
'sessionid' => $this->session_id
|
335 |
+
),
|
336 |
+
'%d',
|
337 |
+
'%d'
|
338 |
+
);
|
339 |
}
|
340 |
|
341 |
/**
|
344 |
function set_transaction_details( $transaction_id, $status = 1 ) {
|
345 |
global $wpdb;
|
346 |
|
347 |
+
$wpdb->update(
|
348 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
349 |
+
array(
|
350 |
+
'processed' => $status,
|
351 |
+
'transactid' => $transaction_id
|
352 |
+
),
|
353 |
+
array(
|
354 |
+
'id' => $this->purchase_id
|
355 |
+
),
|
356 |
+
array(
|
357 |
+
'%d',
|
358 |
+
'%s'
|
359 |
+
),
|
360 |
+
'%d'
|
361 |
+
);
|
362 |
}
|
363 |
|
364 |
/**
|
wpsc-includes/misc.functions.php
CHANGED
@@ -35,14 +35,14 @@ function wpsc_find_purchlog_status_name( $purchlog_status ) {
|
|
35 |
*/
|
36 |
function wpsc_get_state_by_id( $id, $return_value ) {
|
37 |
global $wpdb;
|
38 |
-
$sql = "SELECT
|
39 |
$value = $wpdb->get_var( $sql );
|
40 |
return $value;
|
41 |
}
|
42 |
|
43 |
function wpsc_country_has_state($country_code){
|
44 |
global $wpdb;
|
45 |
-
$country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`=
|
46 |
return $country_data;
|
47 |
}
|
48 |
|
@@ -104,6 +104,7 @@ function wpsc_add_new_user( $user_login, $user_pass, $user_email ) {
|
|
104 |
* @return bool true or false
|
105 |
*/
|
106 |
function wpsc_product_has_variations( $product_id ) {
|
|
|
107 |
global $wpdb;
|
108 |
if ( $product_id > 0 ) {
|
109 |
$variation_count = $wpdb->get_var( "SELECT COUNT(`id`) FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN('product') AND `associated_id` IN('{$product_id}')" );
|
@@ -230,25 +231,36 @@ function wpsc_populate_also_bought_list() {
|
|
230 |
$insert_statement_parts = array( );
|
231 |
foreach ( $new_also_bought_data as $new_also_bought_id => $new_also_bought_row ) {
|
232 |
$new_other_ids = array_keys( $new_also_bought_row );
|
233 |
-
$also_bought_data = $wpdb->get_results( "SELECT `id`, `associated_product`, `quantity` FROM `" . WPSC_TABLE_ALSO_BOUGHT . "` WHERE `selected_product` IN(
|
234 |
$altered_new_also_bought_row = $new_also_bought_row;
|
235 |
|
236 |
foreach ( (array)$also_bought_data as $also_bought_row ) {
|
237 |
$quantity = $new_also_bought_row[$also_bought_row['associated_product']] + $also_bought_row['quantity'];
|
238 |
|
239 |
unset( $altered_new_also_bought_row[$also_bought_row['associated_product']] );
|
240 |
-
$wpdb->
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
|
244 |
if ( count( $altered_new_also_bought_row ) > 0 ) {
|
245 |
foreach ( $altered_new_also_bought_row as $associated_product => $quantity ) {
|
246 |
-
$insert_statement_parts[] = "(" . absint( $new_also_bought_id ) . "," . absint( $associated_product ) . "," . absint( $quantity ) . ")";
|
247 |
}
|
248 |
}
|
249 |
}
|
250 |
|
251 |
if ( count( $insert_statement_parts ) > 0 ) {
|
|
|
252 |
$insert_statement = "INSERT INTO `" . WPSC_TABLE_ALSO_BOUGHT . "` (`selected_product`, `associated_product`, `quantity`) VALUES " . implode( ",\n ", $insert_statement_parts );
|
253 |
$wpdb->query( $insert_statement );
|
254 |
}
|
@@ -256,20 +268,20 @@ function wpsc_populate_also_bought_list() {
|
|
256 |
|
257 |
function wpsc_get_country_form_id_by_type($type){
|
258 |
global $wpdb;
|
259 |
-
$sql = 'SELECT `id`
|
260 |
$id = $wpdb->get_var($sql);
|
261 |
return $id;
|
262 |
}
|
263 |
|
264 |
function wpsc_get_country( $country_code ) {
|
265 |
global $wpdb;
|
266 |
-
$country = $wpdb->get_var( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN (
|
267 |
return $country;
|
268 |
}
|
269 |
|
270 |
-
function wpsc_get_region( $
|
271 |
global $wpdb;
|
272 |
-
$region = $wpdb->get_var( "SELECT `name` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` IN(
|
273 |
return $region;
|
274 |
}
|
275 |
|
@@ -287,7 +299,7 @@ function nzshpcrt_display_preview_image() {
|
|
287 |
$imagepath = WPSC_USER_UPLOADS_DIR . $image;
|
288 |
} else if ( $_GET['category_id'] ) {
|
289 |
$category_id = absint( $_GET['category_id'] );
|
290 |
-
$image = $wpdb->get_var( "SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` =
|
291 |
if ( $image != '' ) {
|
292 |
$imagepath = WPSC_CATEGORY_DIR . $image;
|
293 |
}
|
35 |
*/
|
36 |
function wpsc_get_state_by_id( $id, $return_value ) {
|
37 |
global $wpdb;
|
38 |
+
$sql = $wpdb->prepare( "SELECT " . esc_sql( $return_value ) . " FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id`= %d", $id );
|
39 |
$value = $wpdb->get_var( $sql );
|
40 |
return $value;
|
41 |
}
|
42 |
|
43 |
function wpsc_country_has_state($country_code){
|
44 |
global $wpdb;
|
45 |
+
$country_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode`= %s LIMIT 1", $country_code ), ARRAY_A );
|
46 |
return $country_data;
|
47 |
}
|
48 |
|
104 |
* @return bool true or false
|
105 |
*/
|
106 |
function wpsc_product_has_variations( $product_id ) {
|
107 |
+
_deprecated_function( __FUNCTION__, '3.8', 'wpsc_have_variations()' );
|
108 |
global $wpdb;
|
109 |
if ( $product_id > 0 ) {
|
110 |
$variation_count = $wpdb->get_var( "SELECT COUNT(`id`) FROM `" . WPSC_TABLE_VARIATION_ASSOC . "` WHERE `type` IN('product') AND `associated_id` IN('{$product_id}')" );
|
231 |
$insert_statement_parts = array( );
|
232 |
foreach ( $new_also_bought_data as $new_also_bought_id => $new_also_bought_row ) {
|
233 |
$new_other_ids = array_keys( $new_also_bought_row );
|
234 |
+
$also_bought_data = $wpdb->get_results( $wpdb->prepare( "SELECT `id`, `associated_product`, `quantity` FROM `" . WPSC_TABLE_ALSO_BOUGHT . "` WHERE `selected_product` IN(%d) AND `associated_product` IN(" . implode( "','", $new_other_ids ) . ")", $new_also_bought_id ), ARRAY_A );
|
235 |
$altered_new_also_bought_row = $new_also_bought_row;
|
236 |
|
237 |
foreach ( (array)$also_bought_data as $also_bought_row ) {
|
238 |
$quantity = $new_also_bought_row[$also_bought_row['associated_product']] + $also_bought_row['quantity'];
|
239 |
|
240 |
unset( $altered_new_also_bought_row[$also_bought_row['associated_product']] );
|
241 |
+
$wpdb->update(
|
242 |
+
WPSC_TABLE_ALSO_BOUGHT,
|
243 |
+
array(
|
244 |
+
'quantity' => $quantity
|
245 |
+
),
|
246 |
+
array(
|
247 |
+
'id' => $also_bought_row['id']
|
248 |
+
),
|
249 |
+
'%d',
|
250 |
+
'%d'
|
251 |
+
);
|
252 |
+
}
|
253 |
|
254 |
|
255 |
if ( count( $altered_new_also_bought_row ) > 0 ) {
|
256 |
foreach ( $altered_new_also_bought_row as $associated_product => $quantity ) {
|
257 |
+
$insert_statement_parts[] = "(" . absint( esc_sql( $new_also_bought_id ) ) . "," . absint( esc_sql( $associated_product ) ) . "," . absint( esc_sql( $quantity ) ) . ")";
|
258 |
}
|
259 |
}
|
260 |
}
|
261 |
|
262 |
if ( count( $insert_statement_parts ) > 0 ) {
|
263 |
+
|
264 |
$insert_statement = "INSERT INTO `" . WPSC_TABLE_ALSO_BOUGHT . "` (`selected_product`, `associated_product`, `quantity`) VALUES " . implode( ",\n ", $insert_statement_parts );
|
265 |
$wpdb->query( $insert_statement );
|
266 |
}
|
268 |
|
269 |
function wpsc_get_country_form_id_by_type($type){
|
270 |
global $wpdb;
|
271 |
+
$sql = $wpdb->prepare( 'SELECT `id` FROM `'.WPSC_TABLE_CHECKOUT_FORMS.'` WHERE `type`= %s LIMIT 1', $type );
|
272 |
$id = $wpdb->get_var($sql);
|
273 |
return $id;
|
274 |
}
|
275 |
|
276 |
function wpsc_get_country( $country_code ) {
|
277 |
global $wpdb;
|
278 |
+
$country = $wpdb->get_var( $wpdb->prepare( "SELECT `country` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` IN (%s) LIMIT 1", $country_code ) );
|
279 |
return $country;
|
280 |
}
|
281 |
|
282 |
+
function wpsc_get_region( $region_id ) {
|
283 |
global $wpdb;
|
284 |
+
$region = $wpdb->get_var( $wpdb->prepare( "SELECT `name` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` IN(%d)", $region_id ) );
|
285 |
return $region;
|
286 |
}
|
287 |
|
299 |
$imagepath = WPSC_USER_UPLOADS_DIR . $image;
|
300 |
} else if ( $_GET['category_id'] ) {
|
301 |
$category_id = absint( $_GET['category_id'] );
|
302 |
+
$image = $wpdb->get_var( $wpdb->prepare( "SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` = %d LIMIT 1", $category_id ) );
|
303 |
if ( $image != '' ) {
|
304 |
$imagepath = WPSC_CATEGORY_DIR . $image;
|
305 |
}
|
wpsc-includes/processing.functions.php
CHANGED
@@ -45,11 +45,11 @@ function wpsc_currency_display( $price_in, $args = null ) {
|
|
45 |
$currency_type = get_option( 'currency_type' );
|
46 |
|
47 |
if ( ! $wpsc_currency_data = wp_cache_get( $currency_type, 'wpsc_currency_id' ) ) {
|
48 |
-
$wpsc_currency_data = $wpdb->get_row( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` =
|
49 |
wp_cache_set( $currency_type, $wpsc_currency_data, 'wpsc_currency_id' );
|
50 |
}
|
51 |
} elseif ( ! $wpsc_currency_data = wp_cache_get( $query['isocode'], 'wpsc_currency_isocode' ) ) {
|
52 |
-
$wpsc_currency_data = $wpdb->get_row( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` =
|
53 |
wp_cache_set( $query['isocode'], $wpsc_currency_data, 'wpsc_currency_isocode' );
|
54 |
}
|
55 |
|
@@ -116,7 +116,7 @@ function wpsc_decrement_claimed_stock($purchase_log_id) {
|
|
116 |
global $wpdb;
|
117 |
|
118 |
//processed
|
119 |
-
$all_claimed_stock = $wpdb->get_results($wpdb->prepare("SELECT `cs`.`product_id`, `cs`.`stock_claimed`, `pl`.`id`, `pl`.`processed` FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` `cs` JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` `pl` ON `cs`.`cart_id` = `pl`.`id` WHERE `cs`.`cart_id` = '%s'", $purchase_log_id));
|
120 |
|
121 |
if( !empty( $all_claimed_stock ) ){
|
122 |
switch($all_claimed_stock[0]->processed){
|
@@ -131,11 +131,11 @@ function wpsc_decrement_claimed_stock($purchase_log_id) {
|
|
131 |
$product_meta = get_product_meta($product->ID,'product_metadata',true);
|
132 |
if( $remaining_stock < 1 && $product_meta["unpublish_when_none_left"] == 1){
|
133 |
wp_mail(get_option('admin_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), sprintf(__('Remaining stock of %s is 0. Product was unpublished.', 'wpsc'), $product->post_title) );
|
134 |
-
$wpdb->
|
135 |
}
|
136 |
}
|
137 |
case 6:
|
138 |
-
$wpdb->query($wpdb->prepare("DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN (
|
139 |
break;
|
140 |
}
|
141 |
}
|
@@ -149,8 +149,8 @@ function wpsc_decrement_claimed_stock($purchase_log_id) {
|
|
149 |
function wpsc_get_currency_symbol(){
|
150 |
global $wpdb;
|
151 |
$currency_type = get_option('currency_type');
|
152 |
-
$wpsc_currency_data = $wpdb->get_var("SELECT `symbol` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id
|
153 |
-
return
|
154 |
}
|
155 |
|
156 |
/**
|
@@ -160,12 +160,13 @@ function wpsc_get_currency_symbol(){
|
|
160 |
|
161 |
function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
|
162 |
global $wpdb;
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
169 |
return $total;
|
170 |
}
|
171 |
|
45 |
$currency_type = get_option( 'currency_type' );
|
46 |
|
47 |
if ( ! $wpsc_currency_data = wp_cache_get( $currency_type, 'wpsc_currency_id' ) ) {
|
48 |
+
$wpsc_currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ), ARRAY_A );
|
49 |
wp_cache_set( $currency_type, $wpsc_currency_data, 'wpsc_currency_id' );
|
50 |
}
|
51 |
} elseif ( ! $wpsc_currency_data = wp_cache_get( $query['isocode'], 'wpsc_currency_isocode' ) ) {
|
52 |
+
$wpsc_currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `symbol`, `symbol_html`, `code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `isocode` = %s LIMIT 1", $query['isocode'] ), ARRAY_A );
|
53 |
wp_cache_set( $query['isocode'], $wpsc_currency_data, 'wpsc_currency_isocode' );
|
54 |
}
|
55 |
|
116 |
global $wpdb;
|
117 |
|
118 |
//processed
|
119 |
+
$all_claimed_stock = $wpdb->get_results( $wpdb->prepare( "SELECT `cs`.`product_id`, `cs`.`stock_claimed`, `pl`.`id`, `pl`.`processed` FROM `" . WPSC_TABLE_CLAIMED_STOCK . "` `cs` JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` `pl` ON `cs`.`cart_id` = `pl`.`id` WHERE `cs`.`cart_id` = '%s'", $purchase_log_id ) );
|
120 |
|
121 |
if( !empty( $all_claimed_stock ) ){
|
122 |
switch($all_claimed_stock[0]->processed){
|
131 |
$product_meta = get_product_meta($product->ID,'product_metadata',true);
|
132 |
if( $remaining_stock < 1 && $product_meta["unpublish_when_none_left"] == 1){
|
133 |
wp_mail(get_option('admin_email'), sprintf(__('%s is out of stock', 'wpsc'), $product->post_title), sprintf(__('Remaining stock of %s is 0. Product was unpublished.', 'wpsc'), $product->post_title) );
|
134 |
+
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft' ), array( 'ID' => $product->ID ), '%s', '%d' );
|
135 |
}
|
136 |
}
|
137 |
case 6:
|
138 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_CLAIMED_STOCK."` WHERE `cart_id` IN (%s)", $purchase_log_id ) );
|
139 |
break;
|
140 |
}
|
141 |
}
|
149 |
function wpsc_get_currency_symbol(){
|
150 |
global $wpdb;
|
151 |
$currency_type = get_option('currency_type');
|
152 |
+
$wpsc_currency_data = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` = %d LIMIT 1", $currency_type ) );
|
153 |
+
return $wpsc_currency_data;
|
154 |
}
|
155 |
|
156 |
/**
|
160 |
|
161 |
function admin_display_total_price($start_timestamp = '', $end_timestamp = '') {
|
162 |
global $wpdb;
|
163 |
+
|
164 |
+
if( ( $start_timestamp != '' ) && ( $end_timestamp != '' ) )
|
165 |
+
$sql = $wpdb->prepare( "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` BETWEEN %s AND %s", $start_timestamp, $end_timestamp );
|
166 |
+
else
|
167 |
+
$sql = "SELECT SUM(`totalprice`) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN (2,3,4) AND `date` != ''";
|
168 |
+
|
169 |
+
$total = $wpdb->get_var($sql);
|
170 |
return $total;
|
171 |
}
|
172 |
|
wpsc-includes/product-template.php
CHANGED
@@ -380,7 +380,7 @@ function wpsc_product_variation_price_available( $product_id, $from_text = false
|
|
380 |
}
|
381 |
|
382 |
sort( $prices );
|
383 |
-
$price = apply_filters( 'wpsc_do_convert_price', $prices[0] );
|
384 |
$price = wpsc_currency_display( $price, array( 'display_as_html' => false ) );
|
385 |
|
386 |
if ( $prices[0] == $prices[count( $prices ) - 1] )
|
@@ -424,7 +424,7 @@ function wpsc_the_product_price( $no_decimals = false, $only_normal_price = fals
|
|
424 |
if ( $no_decimals == true )
|
425 |
$price = array_shift( explode( ".", $price ) );
|
426 |
|
427 |
-
$price = apply_filters( 'wpsc_do_convert_price', $price );
|
428 |
$args = array(
|
429 |
'display_as_html' => false,
|
430 |
'display_decimal_point' => ! $no_decimals
|
@@ -1049,10 +1049,11 @@ function wpsc_product_postage_and_packaging() {
|
|
1049 |
|
1050 |
$product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
|
1051 |
if ( isset( $product_meta['shipping'] ) && is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
|
1052 |
-
return wpsc_currency_display( $product_meta['shipping']['local'] );
|
1053 |
else
|
1054 |
return wpsc_currency_display( 0 );
|
1055 |
-
|
|
|
1056 |
}
|
1057 |
|
1058 |
/**
|
@@ -1517,7 +1518,7 @@ function wpsc_product_rater() {
|
|
1517 |
|
1518 |
function wpsc_product_existing_rating( $product_id ) {
|
1519 |
global $wpdb;
|
1520 |
-
$get_average = $wpdb->get_results( "SELECT AVG(`rated`) AS `average`, COUNT(*) AS `count` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `productid`=
|
1521 |
$average = floor( $get_average[0]['average'] );
|
1522 |
$count = $get_average[0]['count'];
|
1523 |
$output = " <span class='votetext'>";
|
@@ -1574,7 +1575,8 @@ function wpsc_currency_sign() {
|
|
1574 |
global $wpdb;
|
1575 |
$currency_sign_location = get_option( 'currency_sign_location' );
|
1576 |
$currency_type = get_option( 'currency_type' );
|
1577 |
-
$currency_symbol = $wpdb->get_var( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id
|
|
|
1578 |
return $currency_symbol;
|
1579 |
}
|
1580 |
|
380 |
}
|
381 |
|
382 |
sort( $prices );
|
383 |
+
$price = apply_filters( 'wpsc_do_convert_price', $prices[0], $product_id );
|
384 |
$price = wpsc_currency_display( $price, array( 'display_as_html' => false ) );
|
385 |
|
386 |
if ( $prices[0] == $prices[count( $prices ) - 1] )
|
424 |
if ( $no_decimals == true )
|
425 |
$price = array_shift( explode( ".", $price ) );
|
426 |
|
427 |
+
$price = apply_filters( 'wpsc_do_convert_price', $price, $product_id );
|
428 |
$args = array(
|
429 |
'display_as_html' => false,
|
430 |
'display_decimal_point' => ! $no_decimals
|
1049 |
|
1050 |
$product_meta = get_post_meta( $id, '_wpsc_product_metadata', true );
|
1051 |
if ( isset( $product_meta['shipping'] ) && is_array( $product_meta['shipping'] ) && 1 != $product_meta['no_shipping'])
|
1052 |
+
return wpsc_currency_display( apply_filters( 'wpsc_product_postage_and_packaging', $product_meta['shipping']['local'] ) );
|
1053 |
else
|
1054 |
return wpsc_currency_display( 0 );
|
1055 |
+
|
1056 |
+
|
1057 |
}
|
1058 |
|
1059 |
/**
|
1518 |
|
1519 |
function wpsc_product_existing_rating( $product_id ) {
|
1520 |
global $wpdb;
|
1521 |
+
$get_average = $wpdb->get_results( $wpdb->prepare( "SELECT AVG(`rated`) AS `average`, COUNT(*) AS `count` FROM `" . WPSC_TABLE_PRODUCT_RATING . "` WHERE `productid`= %d ", $product_id ), ARRAY_A );
|
1522 |
$average = floor( $get_average[0]['average'] );
|
1523 |
$count = $get_average[0]['count'];
|
1524 |
$output = " <span class='votetext'>";
|
1575 |
global $wpdb;
|
1576 |
$currency_sign_location = get_option( 'currency_sign_location' );
|
1577 |
$currency_type = get_option( 'currency_type' );
|
1578 |
+
$currency_symbol = $wpdb->get_var( $wpdb->prepare( "SELECT `symbol_html` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id` = %d LIMIT 1", $currency_type ) );
|
1579 |
+
|
1580 |
return $currency_symbol;
|
1581 |
}
|
1582 |
|
wpsc-includes/productfeed.php
CHANGED
@@ -91,7 +91,7 @@ function wpsc_generate_product_feed() {
|
|
91 |
}
|
92 |
$output .= " <title><![CDATA[".get_the_title()."]]></title>\n\r";
|
93 |
$output .= " <link>$purchase_link</link>\n\r";
|
94 |
-
$output .= " <description><![CDATA[".get_the_content()."]]></description>\n\r";
|
95 |
$output .= " <pubDate>".$post->post_modified_gmt."</pubDate>\n\r";
|
96 |
$output .= " <guid>$purchase_link</guid>\n\r";
|
97 |
|
91 |
}
|
92 |
$output .= " <title><![CDATA[".get_the_title()."]]></title>\n\r";
|
93 |
$output .= " <link>$purchase_link</link>\n\r";
|
94 |
+
$output .= " <description><![CDATA[".apply_filters ('the_content', get_the_content())."]]></description>\n\r";
|
95 |
$output .= " <pubDate>".$post->post_modified_gmt."</pubDate>\n\r";
|
96 |
$output .= " <guid>$purchase_link</guid>\n\r";
|
97 |
|
wpsc-includes/purchaselogs.class.php
CHANGED
@@ -107,7 +107,7 @@ function wpsc_purchlogs_has_customfields( $id = '' ) {
|
|
107 |
|
108 |
function wpsc_trackingid_value() {
|
109 |
global $purchlogs;
|
110 |
-
return
|
111 |
}
|
112 |
|
113 |
function wpsc_purchlogs_custommessages() {
|
@@ -433,6 +433,17 @@ function wpec_display_purchlog_taxes( $numeric = false ) {
|
|
433 |
return wpsc_display_purchlog_taxes( $numeric );
|
434 |
}
|
435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
function wpsc_display_purchlog_taxes( $numeric = false ) {
|
437 |
global $purchlogitem;
|
438 |
return ($numeric) ? $purchlogitem->extrainfo->wpec_taxes_total : wpsc_currency_display( $purchlogitem->extrainfo->wpec_taxes_total,array( 'display_as_html' => false ) );
|
@@ -446,12 +457,17 @@ function wpsc_display_purchlog_totalprice() {
|
|
446 |
|
447 |
function wpsc_display_purchlog_buyers_name() {
|
448 |
global $purchlogitem;
|
449 |
-
return
|
|
|
|
|
|
|
|
|
|
|
450 |
}
|
451 |
|
452 |
function wpsc_display_purchlog_buyers_email() {
|
453 |
global $purchlogitem;
|
454 |
-
return
|
455 |
}
|
456 |
|
457 |
function wpsc_display_purchlog_buyers_address() {
|
@@ -459,32 +475,45 @@ function wpsc_display_purchlog_buyers_address() {
|
|
459 |
|
460 |
if(is_numeric($purchlogitem->extrainfo->billing_region))
|
461 |
$state = wpsc_get_region($purchlogitem->extrainfo->billing_region);
|
462 |
-
else
|
463 |
$state = $purchlogitem->userinfo['billingstate']['value'];
|
464 |
|
465 |
-
return nl2br( esc_html(
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
}
|
469 |
|
470 |
function wpsc_display_purchlog_buyers_phone() {
|
471 |
global $purchlogitem;
|
472 |
-
return
|
473 |
}
|
474 |
|
475 |
function wpsc_display_purchlog_shipping_name() {
|
476 |
global $purchlogitem;
|
477 |
-
return esc_html(
|
478 |
}
|
479 |
|
480 |
function wpsc_display_purchlog_shipping_address() {
|
481 |
global $purchlogitem;
|
482 |
-
return nl2br( esc_html(
|
483 |
}
|
484 |
|
485 |
function wpsc_display_purchlog_shipping_city() {
|
486 |
global $purchlogitem;
|
487 |
-
return
|
488 |
}
|
489 |
|
490 |
function wpsc_display_purchlog_shipping_state_and_postcode() {
|
@@ -494,21 +523,20 @@ function wpsc_display_purchlog_shipping_state_and_postcode() {
|
|
494 |
$state = esc_html( wpsc_get_region($purchlogitem->extrainfo->shipping_region) );
|
495 |
else
|
496 |
$state = esc_html( $purchlogitem->shippinginfo['shippingstate']['value'] );
|
497 |
-
|
498 |
if ( !empty( $purchlogitem->shippinginfo['shippingpostcode']['value'] ) ){
|
499 |
if( empty( $state ) )
|
500 |
$state = esc_html( $purchlogitem->shippinginfo['shippingpostcode']['value'] );
|
501 |
else
|
502 |
$state .= ', ' . esc_html( $purchlogitem->shippinginfo['shippingpostcode']['value'] );
|
503 |
}
|
504 |
-
|
505 |
|
506 |
-
return $state;
|
507 |
}
|
508 |
|
509 |
function wpsc_display_purchlog_shipping_country() {
|
510 |
global $purchlogitem;
|
511 |
-
return
|
512 |
}
|
513 |
|
514 |
function wpsc_display_purchlog_shipping_method() {
|
@@ -516,15 +544,15 @@ function wpsc_display_purchlog_shipping_method() {
|
|
516 |
|
517 |
if ( ! empty ( $wpsc_shipping_modules[$purchlogitem->extrainfo->shipping_method] ) ) {
|
518 |
$shipping_class = &$wpsc_shipping_modules[$purchlogitem->extrainfo->shipping_method];
|
519 |
-
return $shipping_class->name;
|
520 |
} else {
|
521 |
-
return $purchlogitem->extrainfo->shipping_method;
|
522 |
}
|
523 |
}
|
524 |
|
525 |
function wpsc_display_purchlog_shipping_option() {
|
526 |
global $purchlogitem;
|
527 |
-
return $purchlogitem->extrainfo->shipping_option;
|
528 |
}
|
529 |
|
530 |
function wpsc_display_purchlog_paymentmethod() {
|
@@ -538,9 +566,9 @@ function wpsc_display_purchlog_paymentmethod() {
|
|
538 |
$gateway_name = $gateway['name'];
|
539 |
}
|
540 |
if( !empty($gateway_name) )
|
541 |
-
return $gateway_name;
|
542 |
else
|
543 |
-
return $purchlogitem->extrainfo->gateway;
|
544 |
|
545 |
}
|
546 |
|
@@ -674,11 +702,12 @@ class wpsc_purchaselogs {
|
|
674 |
|
675 |
function get_purchlogs( $dates, $status='' ) {
|
676 |
global $wpdb;
|
677 |
-
|
|
|
678 |
if ( $status == '' || $status == '-1' ) {
|
679 |
foreach ( (array)$dates as $date_pair ) {
|
680 |
if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
|
681 |
-
$sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] .
|
682 |
$purchase_logs = $wpdb->get_results( $sql );
|
683 |
array_push( $purchlog2, $purchase_logs );
|
684 |
}
|
@@ -686,13 +715,12 @@ class wpsc_purchaselogs {
|
|
686 |
} else {
|
687 |
foreach ( (array)$dates as $date_pair ) {
|
688 |
if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
|
689 |
-
$sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] . "' AND `processed`='" . $status .
|
690 |
$purchase_logs = $wpdb->get_results( $sql );
|
691 |
array_push( $purchlog2, $purchase_logs );
|
692 |
}
|
693 |
}
|
694 |
}
|
695 |
-
|
696 |
$newarray = array( );
|
697 |
foreach ( $purchlog2 as $purch ) {
|
698 |
if ( is_array( $purch ) ) {
|
@@ -879,7 +907,7 @@ class wpsc_purchaselogs {
|
|
879 |
|
880 |
function search_purchlog_view( $searchterm ) {
|
881 |
global $wpdb;
|
882 |
-
$sql = "SELECT DISTINCT `" . WPSC_TABLE_PURCHASE_LOGS . "` . * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` LEFT JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`value` LIKE '%" .
|
883 |
$newlogs = $wpdb->get_results( $sql );
|
884 |
$_SESSION['newlogs'] = $newlogs;
|
885 |
return $newlogs;
|
107 |
|
108 |
function wpsc_trackingid_value() {
|
109 |
global $purchlogs;
|
110 |
+
return $purchlogs->purchitem->track_id;
|
111 |
}
|
112 |
|
113 |
function wpsc_purchlogs_custommessages() {
|
433 |
return wpsc_display_purchlog_taxes( $numeric );
|
434 |
}
|
435 |
|
436 |
+
/**
|
437 |
+
* @description: determines whether or not to display the product tax or not
|
438 |
+
* @return: boolean
|
439 |
+
**/
|
440 |
+
function wpec_display_product_tax()
|
441 |
+
{
|
442 |
+
global $purchlogitem;
|
443 |
+
return ($purchlogitem->extrainfo->wpec_taxes_total == 0.00) ? true : false;
|
444 |
+
}// wpec_display_product_tax
|
445 |
+
|
446 |
+
|
447 |
function wpsc_display_purchlog_taxes( $numeric = false ) {
|
448 |
global $purchlogitem;
|
449 |
return ($numeric) ? $purchlogitem->extrainfo->wpec_taxes_total : wpsc_currency_display( $purchlogitem->extrainfo->wpec_taxes_total,array( 'display_as_html' => false ) );
|
457 |
|
458 |
function wpsc_display_purchlog_buyers_name() {
|
459 |
global $purchlogitem;
|
460 |
+
return esc_html( $purchlogitem->userinfo['billingfirstname']['value'] ) . ' ' . esc_html( $purchlogitem->userinfo['billinglastname']['value'] );
|
461 |
+
}
|
462 |
+
|
463 |
+
function wpsc_display_purchlog_buyers_city() {
|
464 |
+
global $purchlogitem;
|
465 |
+
return esc_html( $purchlogitem->userinfo['billingcity']['value'] );
|
466 |
}
|
467 |
|
468 |
function wpsc_display_purchlog_buyers_email() {
|
469 |
global $purchlogitem;
|
470 |
+
return esc_html( $purchlogitem->userinfo['billingemail']['value'] );
|
471 |
}
|
472 |
|
473 |
function wpsc_display_purchlog_buyers_address() {
|
475 |
|
476 |
if(is_numeric($purchlogitem->extrainfo->billing_region))
|
477 |
$state = wpsc_get_region($purchlogitem->extrainfo->billing_region);
|
478 |
+
else
|
479 |
$state = $purchlogitem->userinfo['billingstate']['value'];
|
480 |
|
481 |
+
return nl2br( esc_html( $purchlogitem->userinfo['billingaddress']['value'] ) );
|
482 |
+
}
|
483 |
+
|
484 |
+
function wpsc_display_purchlog_buyers_state_and_postcode() {
|
485 |
+
global $purchlogitem;
|
486 |
+
if( is_numeric($purchlogitem->extrainfo->billing_region ) )
|
487 |
+
$state = wpsc_get_region($purchlogitem->extrainfo->billing_region);
|
488 |
+
else
|
489 |
+
$state = $purchlogitem->userinfo['billingstate']['value'];
|
490 |
+
|
491 |
+
return esc_html( $state ) . ', ' . esc_html( $purchlogitem->userinfo['billingpostcode']['value'] );
|
492 |
+
}
|
493 |
+
|
494 |
+
function wpsc_display_purchlog_buyers_country() {
|
495 |
+
global $purchlogitem;
|
496 |
+
return esc_html( $purchlogitem->extrainfo->billing_country );
|
497 |
}
|
498 |
|
499 |
function wpsc_display_purchlog_buyers_phone() {
|
500 |
global $purchlogitem;
|
501 |
+
return esc_html( $purchlogitem->userinfo['billingphone']['value'] );
|
502 |
}
|
503 |
|
504 |
function wpsc_display_purchlog_shipping_name() {
|
505 |
global $purchlogitem;
|
506 |
+
return esc_html( $purchlogitem->shippinginfo['shippingfirstname']['value'] ) . ' ' . esc_html( $purchlogitem->shippinginfo['shippinglastname']['value'] );
|
507 |
}
|
508 |
|
509 |
function wpsc_display_purchlog_shipping_address() {
|
510 |
global $purchlogitem;
|
511 |
+
return nl2br( esc_html( $purchlogitem->shippinginfo['shippingaddress']['value'] ) );
|
512 |
}
|
513 |
|
514 |
function wpsc_display_purchlog_shipping_city() {
|
515 |
global $purchlogitem;
|
516 |
+
return esc_html( $purchlogitem->shippinginfo['shippingcity']['value'] );
|
517 |
}
|
518 |
|
519 |
function wpsc_display_purchlog_shipping_state_and_postcode() {
|
523 |
$state = esc_html( wpsc_get_region($purchlogitem->extrainfo->shipping_region) );
|
524 |
else
|
525 |
$state = esc_html( $purchlogitem->shippinginfo['shippingstate']['value'] );
|
526 |
+
|
527 |
if ( !empty( $purchlogitem->shippinginfo['shippingpostcode']['value'] ) ){
|
528 |
if( empty( $state ) )
|
529 |
$state = esc_html( $purchlogitem->shippinginfo['shippingpostcode']['value'] );
|
530 |
else
|
531 |
$state .= ', ' . esc_html( $purchlogitem->shippinginfo['shippingpostcode']['value'] );
|
532 |
}
|
|
|
533 |
|
534 |
+
return $state;
|
535 |
}
|
536 |
|
537 |
function wpsc_display_purchlog_shipping_country() {
|
538 |
global $purchlogitem;
|
539 |
+
return esc_html( $purchlogitem->shippinginfo['shippingcountry']['value'] );
|
540 |
}
|
541 |
|
542 |
function wpsc_display_purchlog_shipping_method() {
|
544 |
|
545 |
if ( ! empty ( $wpsc_shipping_modules[$purchlogitem->extrainfo->shipping_method] ) ) {
|
546 |
$shipping_class = &$wpsc_shipping_modules[$purchlogitem->extrainfo->shipping_method];
|
547 |
+
return esc_html( $shipping_class->name );
|
548 |
} else {
|
549 |
+
return esc_html( $purchlogitem->extrainfo->shipping_method );
|
550 |
}
|
551 |
}
|
552 |
|
553 |
function wpsc_display_purchlog_shipping_option() {
|
554 |
global $purchlogitem;
|
555 |
+
return esc_html( $purchlogitem->extrainfo->shipping_option );
|
556 |
}
|
557 |
|
558 |
function wpsc_display_purchlog_paymentmethod() {
|
566 |
$gateway_name = $gateway['name'];
|
567 |
}
|
568 |
if( !empty($gateway_name) )
|
569 |
+
return esc_html( $gateway_name );
|
570 |
else
|
571 |
+
return esc_html( $purchlogitem->extrainfo->gateway );
|
572 |
|
573 |
}
|
574 |
|
702 |
|
703 |
function get_purchlogs( $dates, $status='' ) {
|
704 |
global $wpdb;
|
705 |
+
$purchlog2 = array();
|
706 |
+
$orderby = apply_filters( 'wpsc_purchase_logs_orderby', "' ORDER BY `date` DESC" );
|
707 |
if ( $status == '' || $status == '-1' ) {
|
708 |
foreach ( (array)$dates as $date_pair ) {
|
709 |
if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
|
710 |
+
$sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] . $orderby;
|
711 |
$purchase_logs = $wpdb->get_results( $sql );
|
712 |
array_push( $purchlog2, $purchase_logs );
|
713 |
}
|
715 |
} else {
|
716 |
foreach ( (array)$dates as $date_pair ) {
|
717 |
if ( ($date_pair['end'] >= $this->earliest_timestamp) && ($date_pair['start'] <= $this->current_timestamp) ) {
|
718 |
+
$sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '" . $date_pair['start'] . "' AND '" . $date_pair['end'] . "' AND `processed`='" . $status . $orderby;
|
719 |
$purchase_logs = $wpdb->get_results( $sql );
|
720 |
array_push( $purchlog2, $purchase_logs );
|
721 |
}
|
722 |
}
|
723 |
}
|
|
|
724 |
$newarray = array( );
|
725 |
foreach ( $purchlog2 as $purch ) {
|
726 |
if ( is_array( $purch ) ) {
|
907 |
|
908 |
function search_purchlog_view( $searchterm ) {
|
909 |
global $wpdb;
|
910 |
+
$sql = $wpdb->prepare( "SELECT DISTINCT `" . WPSC_TABLE_PURCHASE_LOGS . "` . * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` LEFT JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` ON `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`log_id` = `" . WPSC_TABLE_PURCHASE_LOGS . "`.`id` WHERE `" . WPSC_TABLE_SUBMITED_FORM_DATA . "`.`value` LIKE '%" . like_escape( $searchterm ) . "%' OR `" . WPSC_TABLE_PURCHASE_LOGS . "`.`transactid` = %s OR `" . WPSC_TABLE_PURCHASE_LOGS . "`.`track_id` LIKE '%" . like_escape( $searchterm )."%'", $searchterm );
|
911 |
$newlogs = $wpdb->get_results( $sql );
|
912 |
$_SESSION['newlogs'] = $newlogs;
|
913 |
return $newlogs;
|
wpsc-includes/shipping.helper.php
CHANGED
@@ -180,9 +180,9 @@ class ASHTools{
|
|
180 |
if (!isset($wpdb)){
|
181 |
return $short_country;
|
182 |
}
|
183 |
-
|
184 |
FROM ".WPSC_TABLE_CURRENCY_LIST."
|
185 |
-
WHERE isocode=
|
186 |
return $full_name;
|
187 |
}
|
188 |
|
@@ -193,15 +193,18 @@ class ASHTools{
|
|
193 |
* @param int $state_code
|
194 |
* @return string|int will be int if wordpress database & wpec are not available
|
195 |
*/
|
196 |
-
function get_state($state_code){
|
197 |
global $wpdb;
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
205 |
}
|
206 |
|
207 |
/**
|
180 |
if (!isset($wpdb)){
|
181 |
return $short_country;
|
182 |
}
|
183 |
+
$full_name = $wpdb->get_var( $wpdb->prepare( "SELECT country
|
184 |
FROM ".WPSC_TABLE_CURRENCY_LIST."
|
185 |
+
WHERE isocode = %s", $short_country ) );
|
186 |
return $full_name;
|
187 |
}
|
188 |
|
193 |
* @param int $state_code
|
194 |
* @return string|int will be int if wordpress database & wpec are not available
|
195 |
*/
|
196 |
+
function get_state( $state_code ){
|
197 |
global $wpdb;
|
198 |
+
|
199 |
+
if ( ! defined ( "WPSC_TABLE_REGION_TAX") )
|
200 |
+
return $state_code;
|
201 |
+
|
202 |
+
$sql = $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
|
203 |
+
WHERE `".WPSC_TABLE_REGION_TAX."`.`id` = %d", $_POST['region'] );
|
204 |
+
|
205 |
+
$dest_region_data = $wpdb->get_results( $sql, ARRAY_A );
|
206 |
+
|
207 |
+
return ( is_array( $dest_region_data ) ) ? $dest_region_data[0]['code'] : "";
|
208 |
}
|
209 |
|
210 |
/**
|
wpsc-includes/shopping_cart_functions.php
CHANGED
@@ -135,7 +135,7 @@ function wpsc_country_region_list( $form_id = null, $ajax = false, $selected_cou
|
|
135 |
$output .= "</select>\n\r";
|
136 |
|
137 |
|
138 |
-
$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(
|
139 |
$sql = "SELECT `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `unique_name` = 'shippingstate' ";
|
140 |
$region_form_id = $wpdb->get_var( $sql );
|
141 |
|
135 |
$output .= "</select>\n\r";
|
136 |
|
137 |
|
138 |
+
$region_list = $wpdb->get_results( $wpdb->prepare( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN(%s) AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", $selected_country ), ARRAY_A );
|
139 |
$sql = "SELECT `" . WPSC_TABLE_CHECKOUT_FORMS . "`.`id` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `unique_name` = 'shippingstate' ";
|
140 |
$region_form_id = $wpdb->get_var( $sql );
|
141 |
|
wpsc-includes/theme.functions.php
CHANGED
@@ -280,16 +280,13 @@ function wpsc_get_template_file_url( $file = '' ) {
|
|
280 |
}
|
281 |
}
|
282 |
|
|
|
|
|
283 |
// Save the transient and update it every 12 hours
|
284 |
if ( !empty( $file_url ) )
|
285 |
set_transient( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url, 60 * 60 * 12 );
|
286 |
-
}else{
|
287 |
-
delete_transient(WPEC_TRANSIENT_THEME_URL_PREFIX . $file);
|
288 |
-
wpsc_get_template_file_url($file);
|
289 |
}
|
290 |
|
291 |
-
if( is_ssl() && !strstr( $file_url, 'https' ) ) $file_url = str_replace('http', 'https', $file_url);
|
292 |
-
|
293 |
// Return filtered result
|
294 |
return apply_filters( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url );
|
295 |
}
|
@@ -604,7 +601,7 @@ function wpsc_enqueue_user_script_and_css() {
|
|
604 |
function wpsc_legacy_add_mp3_preview( $product_id, &$product_data ) {
|
605 |
global $wpdb;
|
606 |
if ( function_exists( 'listen_button' ) ) {
|
607 |
-
$file_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id
|
608 |
if ( $file_data != null ) {
|
609 |
echo listen_button( $file_data['idhash'], $file_data['id'] );
|
610 |
}
|
@@ -1065,6 +1062,11 @@ function wpsc_all_products_on_page(){
|
|
1065 |
array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php' );
|
1066 |
}
|
1067 |
|
|
|
|
|
|
|
|
|
|
|
1068 |
array_push( $templates, 'page.php', 'single.php' );
|
1069 |
|
1070 |
if ( is_single() )
|
@@ -1163,7 +1165,7 @@ function wpsc_show_categories( $content ) {
|
|
1163 |
add_shortcode('showcategories', 'wpsc_show_categories');
|
1164 |
function wpec_get_the_post_id_by_shortcode($shortcode){
|
1165 |
global $wpdb;
|
1166 |
-
$sql = "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '
|
1167 |
$page_id = $wpdb->get_var($sql);
|
1168 |
return apply_filters( 'wpec_get_the_post_id_by_shortcode', $page_id );
|
1169 |
}
|
280 |
}
|
281 |
}
|
282 |
|
283 |
+
if( is_ssl() && !strstr( $file_url, 'https' ) ) $file_url = str_replace('http', 'https', $file_url);
|
284 |
+
|
285 |
// Save the transient and update it every 12 hours
|
286 |
if ( !empty( $file_url ) )
|
287 |
set_transient( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url, 60 * 60 * 12 );
|
|
|
|
|
|
|
288 |
}
|
289 |
|
|
|
|
|
290 |
// Return filtered result
|
291 |
return apply_filters( WPEC_TRANSIENT_THEME_URL_PREFIX . $file, $file_url );
|
292 |
}
|
601 |
function wpsc_legacy_add_mp3_preview( $product_id, &$product_data ) {
|
602 |
global $wpdb;
|
603 |
if ( function_exists( 'listen_button' ) ) {
|
604 |
+
$file_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PRODUCT_FILES . "` WHERE `id` = %d LIMIT 1", $product_data['file'] ), ARRAY_A );
|
605 |
if ( $file_data != null ) {
|
606 |
echo listen_button( $file_data['idhash'], $file_data['id'] );
|
607 |
}
|
1062 |
array_push( $templates, "taxonomy-product_tag-{$tax_term}.php", 'taxonomy-product_tag.php' );
|
1063 |
}
|
1064 |
|
1065 |
+
|
1066 |
+
// Attempt to use the [productspage]'s custom page template as a higher priority than the normal page.php template
|
1067 |
+
if ( false !== $productspage_page_template = get_post_meta($products_page_id, '_wp_page_template', true) )
|
1068 |
+
array_push( $templates, $productspage_page_template );
|
1069 |
+
|
1070 |
array_push( $templates, 'page.php', 'single.php' );
|
1071 |
|
1072 |
if ( is_single() )
|
1165 |
add_shortcode('showcategories', 'wpsc_show_categories');
|
1166 |
function wpec_get_the_post_id_by_shortcode($shortcode){
|
1167 |
global $wpdb;
|
1168 |
+
$sql = "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN('page','post') AND `post_content` LIKE '%" . like_escape( $shortcode ) . "%' LIMIT 1";
|
1169 |
$page_id = $wpdb->get_var($sql);
|
1170 |
return apply_filters( 'wpec_get_the_post_id_by_shortcode', $page_id );
|
1171 |
}
|
wpsc-includes/variations.class.php
CHANGED
@@ -12,50 +12,65 @@ class wpsc_variations {
|
|
12 |
var $variation_group_count = 0;
|
13 |
var $current_variation_group = -1;
|
14 |
var $variation_group;
|
15 |
-
|
16 |
// for getting the product price
|
17 |
var $first_variations;
|
18 |
-
|
19 |
//variations inside variation groups: i.e. (red, green, blue) or (S, M, L, XL)
|
20 |
var $variations;
|
21 |
var $variation_count = 0;
|
22 |
var $current_variation = -1;
|
23 |
var $variation;
|
24 |
-
|
25 |
|
26 |
function wpsc_variations($product_id) {
|
27 |
global $wpdb;
|
28 |
-
|
29 |
$product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
|
30 |
$this->variation_groups = array();
|
31 |
$this->first_variations = array();
|
32 |
$this->all_associated_variations = array();
|
33 |
-
|
34 |
foreach($product_terms as $product_term) {
|
35 |
-
if($product_term->parent > 0)
|
36 |
-
|
37 |
-
|
38 |
-
$this->all_associated_variations[$product_term->parent][0]->term_id = 0;
|
39 |
-
$this->all_associated_variations[$product_term->parent][0]->name = '-- Please Select --';
|
40 |
-
}
|
41 |
-
$this->all_associated_variations[$product_term->parent][] = $product_term;
|
42 |
-
} else {
|
43 |
$this->variation_groups[] = $product_term;
|
44 |
-
}
|
45 |
}
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
// Filters to hook into variations to sort etc.
|
48 |
$this->variation_groups = apply_filters( 'wpsc_variation_groups', $this->variation_groups, $product_id );
|
49 |
$this->all_associated_variations = apply_filters( 'wpsc_all_associated_variations', $this->all_associated_variations, $this->variation_groups, $product_id );
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
foreach((array)$this->variation_groups as $variation_group) {
|
52 |
$variation_id = $variation_group->term_id;
|
53 |
$this->first_variations[] = $this->all_associated_variations[$variation_id][0]->term_id;
|
54 |
}
|
55 |
-
|
56 |
$this->variation_group_count = count($this->variation_groups);
|
57 |
}
|
58 |
-
|
|
|
59 |
|
60 |
/*
|
61 |
* (Variation Group and Variation) Loop Code Starts here
|
@@ -65,15 +80,15 @@ class wpsc_variations {
|
|
65 |
$this->variation_group_count = count($this->variation_groups);
|
66 |
$this->get_first_variations();
|
67 |
}
|
68 |
-
|
69 |
-
|
70 |
function next_variation_group() {
|
71 |
$this->current_variation_group++;
|
72 |
$this->variation_group = $this->variation_groups[$this->current_variation_group];
|
73 |
return $this->variation_group;
|
74 |
}
|
75 |
|
76 |
-
|
77 |
function the_variation_group() {
|
78 |
$this->variation_group = $this->next_variation_group();
|
79 |
$this->get_variations();
|
@@ -94,7 +109,7 @@ class wpsc_variations {
|
|
94 |
$this->variation_group = $this->variation_groups[0];
|
95 |
}
|
96 |
}
|
97 |
-
|
98 |
function get_first_variations() {
|
99 |
global $wpdb;
|
100 |
return null;
|
@@ -106,15 +121,15 @@ class wpsc_variations {
|
|
106 |
$this->variations = $this->all_associated_variations[$this->variation_group->term_id];
|
107 |
$this->variation_count = count($this->variations);
|
108 |
}
|
109 |
-
|
110 |
-
|
111 |
function next_variation() {
|
112 |
$this->current_variation++;
|
113 |
$this->variation = $this->variations[$this->current_variation];
|
114 |
return $this->variation;
|
115 |
}
|
116 |
|
117 |
-
|
118 |
function the_variation() {
|
119 |
$this->variation = $this->next_variation();
|
120 |
}
|
@@ -134,28 +149,28 @@ class wpsc_variations {
|
|
134 |
if ($this->variation_count > 0) {
|
135 |
$this->variation = $this->variations[0];
|
136 |
}
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
}
|
143 |
function wpsc_get_child_object_in_select_terms($parent_id, $terms, $taxonomy){
|
144 |
global $wpdb;
|
145 |
-
$sql = "SELECT tr.`object_id`
|
146 |
FROM `".$wpdb->term_relationships."` AS tr
|
147 |
LEFT JOIN `".$wpdb->posts."` AS posts
|
148 |
-
ON posts.`ID` = tr.`object_id`
|
149 |
-
WHERE tr.`term_taxonomy_id` IN (".implode(','
|
150 |
$products = $wpdb->get_col($sql);
|
151 |
return $products;
|
152 |
-
|
153 |
}
|
154 |
|
155 |
/**
|
156 |
* wpsc_get_child_objects_in_term function.
|
157 |
-
* gets the
|
158 |
-
*
|
159 |
* @access public
|
160 |
* @param mixed $parent_id
|
161 |
* @param mixed $terms
|
@@ -182,7 +197,7 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
|
|
182 |
if ( !taxonomy_exists($taxonomy) )
|
183 |
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy', 'wpsc'));
|
184 |
}
|
185 |
-
|
186 |
}
|
187 |
|
188 |
$defaults = array('order' => 'ASC');
|
@@ -192,13 +207,13 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
|
|
192 |
$order = ( 'desc' == strtolower($order) ) ? 'DESC' : 'ASC';
|
193 |
|
194 |
$terms = array_map('intval', $terms);
|
195 |
-
|
196 |
$taxonomy_count = count($taxonomies);
|
197 |
$term_count = count($terms);
|
198 |
|
199 |
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
|
200 |
$terms = "'" . implode("', '", $terms) . "'";
|
201 |
-
|
202 |
// This SQL statement finds the item associated with all variations in the selected combination that is a child of the target product
|
203 |
$object_sql = "SELECT tr.object_id, COUNT(tr.object_id) AS `count`
|
204 |
FROM {$wpdb->term_relationships} AS tr
|
@@ -210,8 +225,8 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
|
|
210 |
AND tt.taxonomy IN ({$taxonomies})
|
211 |
AND tt.term_id IN ({$terms})
|
212 |
AND tt.parent > 0
|
213 |
-
AND (
|
214 |
-
SELECT COUNT(DISTINCT tt2.parent) FROM
|
215 |
{$wpdb->term_relationships} AS tr2
|
216 |
INNER JOIN {$wpdb->term_taxonomy} AS tt2
|
217 |
ON tr2.term_taxonomy_id = tt2.term_taxonomy_id
|
@@ -225,7 +240,7 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
|
|
225 |
if (count($object_ids) > 0) {
|
226 |
return $object_ids['object_id'];
|
227 |
} else {
|
228 |
-
|
229 |
return false;
|
230 |
}
|
231 |
}
|
@@ -233,8 +248,8 @@ function wpsc_get_child_object_in_terms($parent_id, $terms, $taxonomies, $args =
|
|
233 |
|
234 |
/**
|
235 |
* wpsc_get_child_objects_in_term function.
|
236 |
-
* gets the
|
237 |
-
*
|
238 |
* @access public
|
239 |
* @param mixed $parent_id
|
240 |
* @param mixed $terms
|
@@ -261,7 +276,7 @@ function wpsc_get_child_object_in_terms_var($parent_id, $terms, $taxonomies, $ar
|
|
261 |
if ( !taxonomy_exists($taxonomy) )
|
262 |
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy', 'wpsc'));
|
263 |
}
|
264 |
-
|
265 |
}
|
266 |
|
267 |
$defaults = array('order' => 'ASC');
|
@@ -274,7 +289,7 @@ function wpsc_get_child_object_in_terms_var($parent_id, $terms, $taxonomies, $ar
|
|
274 |
|
275 |
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
|
276 |
$terms = "'" . implode("', '", $terms) . "'";
|
277 |
-
|
278 |
// This SQL statement finds the item associated with all variations in the selected combination that is a child of the target product
|
279 |
$object_sql = "SELECT tr.object_id
|
280 |
FROM {$wpdb->term_relationships} AS tr
|
12 |
var $variation_group_count = 0;
|
13 |
var $current_variation_group = -1;
|
14 |
var $variation_group;
|
15 |
+
|
16 |
// for getting the product price
|
17 |
var $first_variations;
|
18 |
+
|
19 |
//variations inside variation groups: i.e. (red, green, blue) or (S, M, L, XL)
|
20 |
var $variations;
|
21 |
var $variation_count = 0;
|
22 |
var $current_variation = -1;
|
23 |
var $variation;
|
24 |
+
|
25 |
|
26 |
function wpsc_variations($product_id) {
|
27 |
global $wpdb;
|
28 |
+
|
29 |
$product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
|
30 |
$this->variation_groups = array();
|
31 |
$this->first_variations = array();
|
32 |
$this->all_associated_variations = array();
|
33 |
+
|
34 |
foreach($product_terms as $product_term) {
|
35 |
+
if ($product_term->parent > 0)
|
36 |
+
$this->all_associated_variations[$product_term->parent][] = $product_term;
|
37 |
+
else
|
|
|
|
|
|
|
|
|
|
|
38 |
$this->variation_groups[] = $product_term;
|
|
|
39 |
}
|
40 |
+
|
41 |
+
// Sort variation orders
|
42 |
+
foreach ( $this->all_associated_variations as $variation_set => &$terms ) {
|
43 |
+
$terms = wpsc_get_terms_variation_sort_filter( $terms );
|
44 |
+
|
45 |
+
array_unshift( $this->all_associated_variations[$variation_set], (object) array(
|
46 |
+
'term_id' => 0,
|
47 |
+
'name' => __('-- Please Select --', 'wpsc'),
|
48 |
+
) );
|
49 |
+
}
|
50 |
+
|
51 |
// Filters to hook into variations to sort etc.
|
52 |
$this->variation_groups = apply_filters( 'wpsc_variation_groups', $this->variation_groups, $product_id );
|
53 |
$this->all_associated_variations = apply_filters( 'wpsc_all_associated_variations', $this->all_associated_variations, $this->variation_groups, $product_id );
|
54 |
+
|
55 |
+
//the parent_id is the variation group id we need to use this to alter the object (variants)
|
56 |
+
// inside each of these arrays
|
57 |
+
$parent_ids = array_keys($this->all_associated_variations);
|
58 |
+
foreach( (array)$parent_ids as $parent_id ){
|
59 |
+
//sort the variants by their term_order which is the array key
|
60 |
+
ksort($this->all_associated_variations[$parent_id]);
|
61 |
+
//once sorted renumber the array keys back from 0
|
62 |
+
$this->all_associated_variations[$parent_id] = array_values($this->all_associated_variations[$parent_id]);
|
63 |
+
}
|
64 |
+
|
65 |
foreach((array)$this->variation_groups as $variation_group) {
|
66 |
$variation_id = $variation_group->term_id;
|
67 |
$this->first_variations[] = $this->all_associated_variations[$variation_id][0]->term_id;
|
68 |
}
|
69 |
+
|
70 |
$this->variation_group_count = count($this->variation_groups);
|
71 |
}
|
72 |
+
|
73 |
+
|
74 |
|
75 |
/*
|
76 |
* (Variation Group and Variation) Loop Code Starts here
|
80 |
$this->variation_group_count = count($this->variation_groups);
|
81 |
$this->get_first_variations();
|
82 |
}
|
83 |
+
|
84 |
+
|
85 |
function next_variation_group() {
|
86 |
$this->current_variation_group++;
|
87 |
$this->variation_group = $this->variation_groups[$this->current_variation_group];
|
88 |
return $this->variation_group;
|
89 |
}
|
90 |
|
91 |
+
|
92 |
function the_variation_group() {
|
93 |
$this->variation_group = $this->next_variation_group();
|
94 |
$this->get_variations();
|
109 |
$this->variation_group = $this->variation_groups[0];
|
110 |
}
|
111 |
}
|
112 |
+
|
113 |
function get_first_variations() {
|
114 |
global $wpdb;
|
115 |
return null;
|
121 |
$this->variations = $this->all_associated_variations[$this->variation_group->term_id];
|
122 |
$this->variation_count = count($this->variations);
|
123 |
}
|
124 |
+
|
125 |
+
|
126 |
function next_variation() {
|
127 |
$this->current_variation++;
|
128 |
$this->variation = $this->variations[$this->current_variation];
|
129 |
return $this->variation;
|
130 |
}
|
131 |
|
132 |
+
|
133 |
function the_variation() {
|
134 |
$this->variation = $this->next_variation();
|
135 |
}
|
149 |
if ($this->variation_count > 0) {
|
150 |
$this->variation = $this->variations[0];
|
151 |
}
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
}
|
158 |
function wpsc_get_child_object_in_select_terms($parent_id, $terms, $taxonomy){
|
159 |
global $wpdb;
|
160 |
+
$sql = $wpdb->prepare( "SELECT tr.`object_id`
|
161 |
FROM `".$wpdb->term_relationships."` AS tr
|
162 |
LEFT JOIN `".$wpdb->posts."` AS posts
|
163 |
+
ON posts.`ID` = tr.`object_id`
|
164 |
+
WHERE tr.`term_taxonomy_id` IN (".implode(',', esc_sql( $terms ) ).") and posts.`post_parent` = %d", $parent_id );
|
165 |
$products = $wpdb->get_col($sql);
|
166 |
return $products;
|
167 |
+
|
168 |
}
|
169 |
|
170 |
/**
|
171 |
* wpsc_get_child_objects_in_term function.
|
172 |
+
* gets the
|
173 |
+
*
|
174 |
* @access public
|
175 |
* @param mixed $parent_id
|
176 |
* @param mixed $terms
|
197 |
if ( !taxonomy_exists($taxonomy) )
|
198 |
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy', 'wpsc'));
|
199 |
}
|
200 |
+
|
201 |
}
|
202 |
|
203 |
$defaults = array('order' => 'ASC');
|
207 |
$order = ( 'desc' == strtolower($order) ) ? 'DESC' : 'ASC';
|
208 |
|
209 |
$terms = array_map('intval', $terms);
|
210 |
+
|
211 |
$taxonomy_count = count($taxonomies);
|
212 |
$term_count = count($terms);
|
213 |
|
214 |
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
|
215 |
$terms = "'" . implode("', '", $terms) . "'";
|
216 |
+
|
217 |
// This SQL statement finds the item associated with all variations in the selected combination that is a child of the target product
|
218 |
$object_sql = "SELECT tr.object_id, COUNT(tr.object_id) AS `count`
|
219 |
FROM {$wpdb->term_relationships} AS tr
|
225 |
AND tt.taxonomy IN ({$taxonomies})
|
226 |
AND tt.term_id IN ({$terms})
|
227 |
AND tt.parent > 0
|
228 |
+
AND (
|
229 |
+
SELECT COUNT(DISTINCT tt2.parent) FROM
|
230 |
{$wpdb->term_relationships} AS tr2
|
231 |
INNER JOIN {$wpdb->term_taxonomy} AS tt2
|
232 |
ON tr2.term_taxonomy_id = tt2.term_taxonomy_id
|
240 |
if (count($object_ids) > 0) {
|
241 |
return $object_ids['object_id'];
|
242 |
} else {
|
243 |
+
|
244 |
return false;
|
245 |
}
|
246 |
}
|
248 |
|
249 |
/**
|
250 |
* wpsc_get_child_objects_in_term function.
|
251 |
+
* gets the
|
252 |
+
*
|
253 |
* @access public
|
254 |
* @param mixed $parent_id
|
255 |
* @param mixed $terms
|
276 |
if ( !taxonomy_exists($taxonomy) )
|
277 |
return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy', 'wpsc'));
|
278 |
}
|
279 |
+
|
280 |
}
|
281 |
|
282 |
$defaults = array('order' => 'ASC');
|
289 |
|
290 |
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
|
291 |
$terms = "'" . implode("', '", $terms) . "'";
|
292 |
+
|
293 |
// This SQL statement finds the item associated with all variations in the selected combination that is a child of the target product
|
294 |
$object_sql = "SELECT tr.object_id
|
295 |
FROM {$wpdb->term_relationships} AS tr
|
wpsc-merchants/GoogleCheckout-XML.php
CHANGED
@@ -43,24 +43,93 @@ function gateway_google($fromcheckout = false){
|
|
43 |
$tax = $wpsc_cart->calculate_total_tax();
|
44 |
$total = $wpsc_cart->calculate_total_price();
|
45 |
if($total > 0 ){
|
46 |
-
$
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
$purchase_log_id = $wpdb->get_var($sql);
|
50 |
if( !empty($purchase_log_id) ){
|
51 |
-
$sql = "DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE purchaseid = "
|
52 |
$wpdb->query($sql);
|
53 |
}
|
54 |
-
if(! $update){
|
55 |
-
$
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
}
|
61 |
-
|
|
|
62 |
|
63 |
-
if(get_option('permalink_structure') != '') {
|
64 |
$separator = "?";
|
65 |
} else {
|
66 |
$separator = "&";
|
@@ -72,10 +141,10 @@ function gateway_google($fromcheckout = false){
|
|
72 |
function Usecase($separator, $sessionid, $fromcheckout) {
|
73 |
global $wpdb, $wpsc_cart ;
|
74 |
|
75 |
-
$purchase_log_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid
|
76 |
-
$purchase_log = $wpdb->get_results($purchase_log_sql,ARRAY_A) ;
|
77 |
|
78 |
-
$cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid
|
79 |
$wp_cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
|
80 |
|
81 |
$merchant_id = get_option('google_id');
|
@@ -423,56 +492,105 @@ function nzsc_googleResponse() {
|
|
423 |
}
|
424 |
$Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
|
425 |
$result = $Grequest->SendProcessOrder($google_order_number);
|
426 |
-
$region_number = $wpdb->get_var("SELECT id FROM ".WPSC_TABLE_REGION_TAX."` WHERE code =
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
|
429 |
-
$wpdb->query($sql) ;
|
430 |
-
$log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('".$sessionid."') LIMIT 1") ;
|
431 |
-
$sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET firstname='".$shipping_firstname."', lastname='".$shipping_lastname."', email='".$billing_email."', phone='".$billing_phone."' WHERE id='".$log_id."'";
|
432 |
-
$wpdb->query($sql) ;
|
433 |
if (array_key_exists(0,$cart_items['item'])) {
|
434 |
$cart_items = $cart_items['item'];
|
435 |
}
|
436 |
//logging to submited_form_data
|
437 |
$billing_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='first_name' LIMIT 1") ;
|
438 |
-
$sql = "INSERT INTO `".WPSC_TABLE_SUBMITED_FORM_DATA."` (log_id, form_id, value) VALUES ('".$log_id."','".$billing_fname_id."','"
|
439 |
$billing_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='last_name' LIMIT 1") ;
|
440 |
-
$sql .= ", ('".$log_id."','".$billing_lname_id."','"
|
441 |
$billing_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='address' LIMIT 1") ;
|
442 |
-
$sql .= ", ('".$log_id."','".$billing_address_id."','"
|
443 |
$billing_city_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='city' LIMIT 1") ;
|
444 |
-
$sql .= ", ('".$log_id."','".$billing_city_id."','"
|
445 |
$billing_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='country' LIMIT 1") ;
|
446 |
-
$sql .= ", ('".$log_id."','".$billing_country_id."','"
|
447 |
$billing_state_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='state' LIMIT 1") ;
|
448 |
-
$sql .= ", ('".$log_id."','".$billing_state_id."','"
|
449 |
$shipping_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_first_name' LIMIT 1") ;
|
450 |
-
$sql .= ", ('".$log_id."','".$shipping_fname_id."','"
|
451 |
$shipping_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_last_name' LIMIT 1") ;
|
452 |
-
$sql .= ", ('".$log_id."','".$shipping_lname_id."','"
|
453 |
$shipping_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_address' LIMIT 1") ;
|
454 |
-
$sql .= ", ('".$log_id."','".$shipping_address_id."','"
|
455 |
$shipping_city_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_city' LIMIT 1") ;
|
456 |
-
$sql .= ", ('".$log_id."','".$shipping_city_id."','"
|
457 |
$shipping_state_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_state' LIMIT 1") ;
|
458 |
-
$sql .= ", ('".$log_id."','".$shipping_state_id."','"
|
459 |
$shipping_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_country' LIMIT 1") ;
|
460 |
-
$sql .= ", ('".$log_id."','".$shipping_country_id."','"
|
461 |
-
|
|
|
|
|
462 |
foreach($cart_items as $cart_item) {
|
463 |
$product_id = $cart_item['merchant-item-id']['VALUE'];
|
464 |
$item_name = $cart_item['item-name']['VALUE'];
|
465 |
$item_desc = $cart_item['item-description']['VALUE'];
|
466 |
$item_unit_price = $cart_item['unit-price']['VALUE'];
|
467 |
$item_quantity = $cart_item['quantity']['VALUE'];
|
468 |
-
$product_info = $wpdb->get_results("SELECT * FROM `" . $wpdb->posts . "` WHERE id=
|
469 |
$product_info = $product_info[0];
|
470 |
if($product_info['notax'] != 1) {
|
471 |
if(get_option('base_country') == $billing_country) {
|
472 |
-
$country_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(
|
473 |
if(($country_data['has_regions'] == 1)) {
|
474 |
if(get_option('base_region') == $region_number) {
|
475 |
-
$region_data = $wpdb->get_row("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN(
|
476 |
}
|
477 |
$gst = $region_data['tax'];
|
478 |
} else {
|
@@ -495,15 +613,35 @@ function nzsc_googleResponse() {
|
|
495 |
$pnp=0;
|
496 |
}
|
497 |
|
498 |
-
$
|
499 |
-
|
500 |
-
|
501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
}
|
503 |
|
504 |
if ($root == "order-state-change-notification") {
|
505 |
$google_order_number = $data['order-state-change-notification']['google-order-number']['VALUE'];
|
506 |
-
$google_status=$wpdb->get_var("SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number=
|
507 |
$google_status = unserialize($google_status);
|
508 |
|
509 |
if (($google_status[0]!='Partially Charged') && ($google_status[0]!='Partially Refunded')) {
|
@@ -511,8 +649,16 @@ function nzsc_googleResponse() {
|
|
511 |
$google_status[1]=$data['order-state-change-notification']['new-fulfillment-order-state']['VALUE'];
|
512 |
}
|
513 |
$google_status = serialize($google_status);
|
514 |
-
|
515 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
|
517 |
if (($data['order-state-change-notification']['new-financial-order-state']['VALUE'] == 'CHARGEABLE') && (get_option('google_auto_charge') == '1')) {
|
518 |
$Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
|
@@ -520,54 +666,86 @@ function nzsc_googleResponse() {
|
|
520 |
|
521 |
$_SESSION['nzshpcrt_cart'] = '';
|
522 |
unset($_SESSION['coupon_num'], $_SESSION['google_session']);
|
523 |
-
|
524 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
526 |
}
|
527 |
|
528 |
if ($root == "charge-amount-notification") {
|
529 |
$google_order_number = $data['charge-amount-notification']['google-order-number']['VALUE'];
|
530 |
-
$google_status
|
531 |
$google_status = unserialize($google_status);
|
532 |
$total_charged = $data['charge-amount-notification']['total-charge-amount']['VALUE'];
|
533 |
$google_status['partial_charge_amount'] = $total_charged;
|
534 |
-
$totalprice
|
535 |
if ($totalprice>$total_charged) {
|
536 |
$google_status[0] = 'Partially Charged';
|
537 |
} else if ($totalprice=$total_charged) {
|
538 |
$google_status[0] = 'CHARGED';
|
539 |
}
|
540 |
$google_status = serialize($google_status);
|
541 |
-
|
542 |
-
$wpdb->
|
543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
|
545 |
if ($root == "refund-amount-notification") {
|
546 |
$google_order_number = $data['refund-amount-notification']['google-order-number']['VALUE'];
|
547 |
-
$google_status=$wpdb->get_var("SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number=
|
548 |
$google_status = unserialize($google_status);
|
549 |
$total_charged = $data['refund-amount-notification']['total-refund-amount']['VALUE'];
|
550 |
$google_status['partial_refund_amount'] = $total_charged;
|
551 |
-
$totalprice=$wpdb->get_var("SELECT totalprice FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number=
|
552 |
if ($totalprice>$total_charged) {
|
553 |
$google_status[0] = 'Partially refunded';
|
554 |
} else if ($totalprice=$total_charged) {
|
555 |
$google_status[0] = 'REFUNDED';
|
556 |
}
|
557 |
$google_status = serialize($google_status);
|
558 |
-
|
559 |
-
$wpdb->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
}
|
561 |
|
562 |
if ($root == "risk-information-notification") {
|
563 |
$google_order_number = $data['risk-information-notification']['google-order-number']['VALUE'];
|
564 |
-
$google_status=$wpdb->get_var("SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number=
|
565 |
$google_status = unserialize($google_status);
|
566 |
$google_status['cvn']=$data['risk-information-notification']['risk-information']['cvn-response']['VALUE'];
|
567 |
$google_status['avs']=$data['risk-information-notification']['risk-information']['avs-response']['VALUE'];
|
568 |
$google_status['protection']=$data['risk-information-notification']['risk-information']['eligible-for-protection']['VALUE'];
|
569 |
$google_status = serialize($google_status);
|
570 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
if ($data['risk-information-notification']['risk-information']['cvn-response']['VALUE'] == 'E') {
|
572 |
$google_risk='cvn';
|
573 |
}
|
@@ -579,23 +757,41 @@ function nzsc_googleResponse() {
|
|
579 |
}
|
580 |
}
|
581 |
if (isset($google_risk)) {
|
582 |
-
|
583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
}
|
585 |
}
|
586 |
|
587 |
if ($root == "order-state-change-notification") {
|
588 |
$google_order_number = $data['order-state-change-notification']['google-order-number']['VALUE'];
|
589 |
if ($data['order-state-change-notification']['new-financial-order-state']['VALUE'] == "CANCELLED_BY_GOOGLE") {
|
590 |
-
$google_status = $wpdb->get_var("SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number=
|
591 |
$google_status = unserialize($google_status);
|
592 |
$google_status[0] = "CANCELLED_BY_GOOGLE";
|
593 |
-
|
594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
}
|
596 |
exit();
|
597 |
}
|
598 |
}
|
599 |
|
600 |
add_action('init', 'nzsc_googleResponse');
|
|
|
601 |
?>
|
43 |
$tax = $wpsc_cart->calculate_total_tax();
|
44 |
$total = $wpsc_cart->calculate_total_price();
|
45 |
if($total > 0 ){
|
46 |
+
$update = $wpdb->update(
|
47 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
48 |
+
array(
|
49 |
+
'totalprice' => $total,
|
50 |
+
'statusno' => 0,
|
51 |
+
'user_ID' => $user_ID,
|
52 |
+
'date' => time(),
|
53 |
+
'gateway' => 'google',
|
54 |
+
'billing_country' => $wpsc_cart->delivery_country,
|
55 |
+
'shipping_country' => $wpsc_cart->selected_country,
|
56 |
+
'base_shipping' => $base_shipping,
|
57 |
+
'shipping_method' => $wpsc_cart->selected_shipping_method,
|
58 |
+
'shipping_option' => $wpsc_cart->selected_shipping_option,
|
59 |
+
'plugin_version' => WPSC_VERSION,
|
60 |
+
'discount_value' => $wpsc_cart->coupons_amount,
|
61 |
+
'discount_data' => $wpsc_cart->coupons_name
|
62 |
+
),
|
63 |
+
array(
|
64 |
+
'sessionid' => $_SESSION['wpsc_sessionid']
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'%f',
|
68 |
+
'%d',
|
69 |
+
'%d',
|
70 |
+
'%s',
|
71 |
+
'%s',
|
72 |
+
'%s',
|
73 |
+
'%s',
|
74 |
+
'%f',
|
75 |
+
'%s',
|
76 |
+
'%s',
|
77 |
+
'%s',
|
78 |
+
'%f',
|
79 |
+
'%s',
|
80 |
+
),
|
81 |
+
'%s'
|
82 |
+
);
|
83 |
+
$sql = $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE sessionid = %s", $_SESSION['wpsc_sessionid'] );
|
84 |
$purchase_log_id = $wpdb->get_var($sql);
|
85 |
if( !empty($purchase_log_id) ){
|
86 |
+
$sql = $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE purchaseid = %d", $purchase_log_id );
|
87 |
$wpdb->query($sql);
|
88 |
}
|
89 |
+
if( ! $update ){
|
90 |
+
$wpdb->insert(
|
91 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
92 |
+
array(
|
93 |
+
'totalprice' => $total,
|
94 |
+
'statusno' => 0,
|
95 |
+
'sessionind' => $_SESSION['wpsc_sessionid'],
|
96 |
+
'user_ID' => $user_ID,
|
97 |
+
'date' => time(),
|
98 |
+
'gateway' => 'google',
|
99 |
+
'billing_country' => $wpsc_cart->delivery_country,
|
100 |
+
'shipping_country' => $wpsc_cart->selected_country,
|
101 |
+
'base_shipping' => $base_shipping,
|
102 |
+
'shipping_method' => $wpsc_cart->selected_shipping_method,
|
103 |
+
'shipping_option' => $wpsc_cart->selected_shipping_option,
|
104 |
+
'plugin_version' => WPSC_VERSION,
|
105 |
+
'discount_value' => $wpsc_cart->coupons_amount,
|
106 |
+
'discount_data' => $wpsc_cart->coupons_name
|
107 |
+
),
|
108 |
+
array(
|
109 |
+
'%f',
|
110 |
+
'%d',
|
111 |
+
'%s',
|
112 |
+
'%d',
|
113 |
+
'%s',
|
114 |
+
'%s',
|
115 |
+
'%s',
|
116 |
+
'%f',
|
117 |
+
'%s',
|
118 |
+
'%s',
|
119 |
+
'%s',
|
120 |
+
'%s',
|
121 |
+
'%f',
|
122 |
+
'%s',
|
123 |
+
),
|
124 |
+
'%s'
|
125 |
+
);
|
126 |
+
$purchase_log_id = $wpdb->insert_id;
|
127 |
|
128 |
}
|
129 |
+
|
130 |
+
$wpsc_cart->save_to_db( $purchase_log_id );
|
131 |
|
132 |
+
if( get_option( 'permalink_structure' ) != '' ) {
|
133 |
$separator = "?";
|
134 |
} else {
|
135 |
$separator = "&";
|
141 |
function Usecase($separator, $sessionid, $fromcheckout) {
|
142 |
global $wpdb, $wpsc_cart ;
|
143 |
|
144 |
+
$purchase_log_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` = %s LIMIT 1", $sessionid );
|
145 |
+
$purchase_log = $wpdb->get_results( $purchase_log_sql, ARRAY_A ) ;
|
146 |
|
147 |
+
$cart_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid` = %d", $purchase_log[0]['id'] );
|
148 |
$wp_cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
|
149 |
|
150 |
$merchant_id = get_option('google_id');
|
492 |
}
|
493 |
$Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
|
494 |
$result = $Grequest->SendProcessOrder($google_order_number);
|
495 |
+
$region_number = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM ".WPSC_TABLE_REGION_TAX."` WHERE code = %s", $billing_region ) );
|
496 |
+
|
497 |
+
$wpdb->insert(
|
498 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
499 |
+
array(
|
500 |
+
'totalprice' => $total_price,
|
501 |
+
'sessionid' => $sessionid,
|
502 |
+
'date' => time(),
|
503 |
+
'billing_country' => $billing_country,
|
504 |
+
'shipping_country' => $shipping_country,
|
505 |
+
'base_shipping' => $pnp,
|
506 |
+
'shipping_region' => $region_number,
|
507 |
+
'user_ID' => $user_ID,
|
508 |
+
'discount_value' => $_SESSION['wpsc_discount'],
|
509 |
+
'gateway' => get_option('payment_gateway'),
|
510 |
+
'google_order_number' => $google_order_number,
|
511 |
+
'google_user_marketing_preference' => $user_marketing_preference,
|
512 |
+
'affiliate_id' => $affiliate_id
|
513 |
+
),
|
514 |
+
array(
|
515 |
+
'%f',
|
516 |
+
'%s',
|
517 |
+
'%s',
|
518 |
+
'%s',
|
519 |
+
'%s',
|
520 |
+
'%f',
|
521 |
+
'%s',
|
522 |
+
'%d',
|
523 |
+
'%f',
|
524 |
+
'%s',
|
525 |
+
'%s',
|
526 |
+
'%s',
|
527 |
+
'%s'
|
528 |
+
)
|
529 |
+
);
|
530 |
+
|
531 |
+
$log_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN(%s) LIMIT 1", $sessionid ) ) ;
|
532 |
+
|
533 |
+
$wpdb->update(
|
534 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
535 |
+
array(
|
536 |
+
'firstname' => $shipping_firstname,
|
537 |
+
'lastname' => $shipping_lastname,
|
538 |
+
'email' => $billing_email,
|
539 |
+
'phone' => $billing_phone,
|
540 |
+
|
541 |
+
),
|
542 |
+
array(
|
543 |
+
'id' => $log_id
|
544 |
+
),
|
545 |
+
'%s',
|
546 |
+
'%d'
|
547 |
+
);
|
548 |
|
|
|
|
|
|
|
|
|
549 |
if (array_key_exists(0,$cart_items['item'])) {
|
550 |
$cart_items = $cart_items['item'];
|
551 |
}
|
552 |
//logging to submited_form_data
|
553 |
$billing_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='first_name' LIMIT 1") ;
|
554 |
+
$sql = "INSERT INTO `".WPSC_TABLE_SUBMITED_FORM_DATA."` (log_id, form_id, value) VALUES ('".$log_id."','".$billing_fname_id."','". esc_sql( $billing_firstname ) ."')";
|
555 |
$billing_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='last_name' LIMIT 1") ;
|
556 |
+
$sql .= ", ('".$log_id."','".$billing_lname_id."','" . esc_sql( $billing_lastname ) . "')";
|
557 |
$billing_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='address' LIMIT 1") ;
|
558 |
+
$sql .= ", ('".$log_id."','".$billing_address_id."','" . esc_sql( $billing_address ) . "')";
|
559 |
$billing_city_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='city' LIMIT 1") ;
|
560 |
+
$sql .= ", ('".$log_id."','".$billing_city_id."','" . esc_sql( $billing_city ) . "')";
|
561 |
$billing_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='country' LIMIT 1") ;
|
562 |
+
$sql .= ", ('".$log_id."','".$billing_country_id."','" . esc_sql( $billing_country ) . "')";
|
563 |
$billing_state_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='state' LIMIT 1") ;
|
564 |
+
$sql .= ", ('".$log_id."','".$billing_state_id."','" . esc_sql( $billing_region ) . "')";
|
565 |
$shipping_fname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_first_name' LIMIT 1") ;
|
566 |
+
$sql .= ", ('".$log_id."','".$shipping_fname_id."','" . esc_sql( $shipping_firstname ) . "')";
|
567 |
$shipping_lname_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_last_name' LIMIT 1") ;
|
568 |
+
$sql .= ", ('".$log_id."','".$shipping_lname_id."','" . esc_sql( $shipping_lastname ) . "')";
|
569 |
$shipping_address_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_address' LIMIT 1") ;
|
570 |
+
$sql .= ", ('".$log_id."','".$shipping_address_id."','" . esc_sql( $shipping_address1 ) . " " . esc_sql( $shipping_address2 ) . "')";
|
571 |
$shipping_city_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_city' LIMIT 1") ;
|
572 |
+
$sql .= ", ('".$log_id."','".$shipping_city_id."','" . esc_sql( $shipping_city ) . "')";
|
573 |
$shipping_state_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_state' LIMIT 1") ;
|
574 |
+
$sql .= ", ('".$log_id."','".$shipping_state_id."','" . esc_sql( $shipping_region ) . "')";
|
575 |
$shipping_country_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type`='delivery_country' LIMIT 1") ;
|
576 |
+
$sql .= ", ('".$log_id."','".$shipping_country_id."','" . esc_sql( $shipping_country ) . "')";
|
577 |
+
|
578 |
+
$wpdb->query( $sql ) ;
|
579 |
+
|
580 |
foreach($cart_items as $cart_item) {
|
581 |
$product_id = $cart_item['merchant-item-id']['VALUE'];
|
582 |
$item_name = $cart_item['item-name']['VALUE'];
|
583 |
$item_desc = $cart_item['item-description']['VALUE'];
|
584 |
$item_unit_price = $cart_item['unit-price']['VALUE'];
|
585 |
$item_quantity = $cart_item['quantity']['VALUE'];
|
586 |
+
$product_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . $wpdb->posts . "` WHERE id= %d LIMIT 1", $product_id ), ARRAY_A) ;
|
587 |
$product_info = $product_info[0];
|
588 |
if($product_info['notax'] != 1) {
|
589 |
if(get_option('base_country') == $billing_country) {
|
590 |
+
$country_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(%s) LIMIT 1", get_option( 'base_country' ) ),ARRAY_A);
|
591 |
if(($country_data['has_regions'] == 1)) {
|
592 |
if(get_option('base_region') == $region_number) {
|
593 |
+
$region_data = $wpdb->get_row( $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."` WHERE `".WPSC_TABLE_REGION_TAX."`.`country_id` IN(%d) AND `".WPSC_TABLE_REGION_TAX."`.`id` IN(%d)", $country_data['id'], get_option( 'base_region' ) ), ARRAY_A ) ;
|
594 |
}
|
595 |
$gst = $region_data['tax'];
|
596 |
} else {
|
613 |
$pnp=0;
|
614 |
}
|
615 |
|
616 |
+
$wpdb->insert(
|
617 |
+
WPSC_TABLE_CART_CONTENTS,
|
618 |
+
array(
|
619 |
+
'prodid' => $product_id,
|
620 |
+
'purchaseid' => $log_id,
|
621 |
+
'price' => $item_unit_price,
|
622 |
+
'pnp' => $pnp,
|
623 |
+
'gst' => $gst,
|
624 |
+
'quantity' => $item_quantity,
|
625 |
+
'donation' => $product_info['donation'],
|
626 |
+
'no_shipping' => $product_info['no_shipping']
|
627 |
+
),
|
628 |
+
array(
|
629 |
+
'%d',
|
630 |
+
'%d',
|
631 |
+
'%s',
|
632 |
+
'%f',
|
633 |
+
'%f',
|
634 |
+
'%d',
|
635 |
+
'%s',
|
636 |
+
'%s',
|
637 |
+
)
|
638 |
+
);
|
639 |
+
}
|
640 |
}
|
641 |
|
642 |
if ($root == "order-state-change-notification") {
|
643 |
$google_order_number = $data['order-state-change-notification']['google-order-number']['VALUE'];
|
644 |
+
$google_status=$wpdb->get_var( $wpdb->prepare( "SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
645 |
$google_status = unserialize($google_status);
|
646 |
|
647 |
if (($google_status[0]!='Partially Charged') && ($google_status[0]!='Partially Refunded')) {
|
649 |
$google_status[1]=$data['order-state-change-notification']['new-fulfillment-order-state']['VALUE'];
|
650 |
}
|
651 |
$google_status = serialize($google_status);
|
652 |
+
|
653 |
+
$wpdb->update(
|
654 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
655 |
+
array(
|
656 |
+
'google_status' => $google_status
|
657 |
+
),
|
658 |
+
array(
|
659 |
+
'google_order_number' => $google_order_number
|
660 |
+
)
|
661 |
+
);
|
662 |
|
663 |
if (($data['order-state-change-notification']['new-financial-order-state']['VALUE'] == 'CHARGEABLE') && (get_option('google_auto_charge') == '1')) {
|
664 |
$Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency);
|
666 |
|
667 |
$_SESSION['nzshpcrt_cart'] = '';
|
668 |
unset($_SESSION['coupon_num'], $_SESSION['google_session']);
|
669 |
+
|
670 |
+
$wpdb->update(
|
671 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
672 |
+
array(
|
673 |
+
'processed' => '3'
|
674 |
+
),
|
675 |
+
array(
|
676 |
+
'google_order_number' => $google_order_number
|
677 |
+
)
|
678 |
+
);
|
679 |
}
|
680 |
}
|
681 |
|
682 |
if ($root == "charge-amount-notification") {
|
683 |
$google_order_number = $data['charge-amount-notification']['google-order-number']['VALUE'];
|
684 |
+
$google_status = $wpdb->get_var( $wpdb->prepare( "SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
685 |
$google_status = unserialize($google_status);
|
686 |
$total_charged = $data['charge-amount-notification']['total-charge-amount']['VALUE'];
|
687 |
$google_status['partial_charge_amount'] = $total_charged;
|
688 |
+
$totalprice = $wpdb->get_var( $wpdb->prepare( "SELECT totalprice FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
689 |
if ($totalprice>$total_charged) {
|
690 |
$google_status[0] = 'Partially Charged';
|
691 |
} else if ($totalprice=$total_charged) {
|
692 |
$google_status[0] = 'CHARGED';
|
693 |
}
|
694 |
$google_status = serialize($google_status);
|
695 |
+
|
696 |
+
$wpdb->update(
|
697 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
698 |
+
array(
|
699 |
+
'google_status' => $google_status,
|
700 |
+
),
|
701 |
+
array(
|
702 |
+
'google_order_number' => $google_order_number
|
703 |
+
)
|
704 |
+
);
|
705 |
+
}
|
706 |
|
707 |
if ($root == "refund-amount-notification") {
|
708 |
$google_order_number = $data['refund-amount-notification']['google-order-number']['VALUE'];
|
709 |
+
$google_status=$wpdb->get_var( $wpdb->prepare( "SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number= %s", $google_order_number ) );
|
710 |
$google_status = unserialize($google_status);
|
711 |
$total_charged = $data['refund-amount-notification']['total-refund-amount']['VALUE'];
|
712 |
$google_status['partial_refund_amount'] = $total_charged;
|
713 |
+
$totalprice=$wpdb->get_var( $wpdb->prepare( "SELECT totalprice FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
714 |
if ($totalprice>$total_charged) {
|
715 |
$google_status[0] = 'Partially refunded';
|
716 |
} else if ($totalprice=$total_charged) {
|
717 |
$google_status[0] = 'REFUNDED';
|
718 |
}
|
719 |
$google_status = serialize($google_status);
|
720 |
+
|
721 |
+
$wpdb->update(
|
722 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
723 |
+
array(
|
724 |
+
'google_status' => $google_status
|
725 |
+
),
|
726 |
+
array(
|
727 |
+
'google_order_number' => $google_order_number
|
728 |
+
)
|
729 |
+
);
|
730 |
}
|
731 |
|
732 |
if ($root == "risk-information-notification") {
|
733 |
$google_order_number = $data['risk-information-notification']['google-order-number']['VALUE'];
|
734 |
+
$google_status=$wpdb->get_var( $wpdb->prepare( "SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
735 |
$google_status = unserialize($google_status);
|
736 |
$google_status['cvn']=$data['risk-information-notification']['risk-information']['cvn-response']['VALUE'];
|
737 |
$google_status['avs']=$data['risk-information-notification']['risk-information']['avs-response']['VALUE'];
|
738 |
$google_status['protection']=$data['risk-information-notification']['risk-information']['eligible-for-protection']['VALUE'];
|
739 |
$google_status = serialize($google_status);
|
740 |
+
$wpdb->update(
|
741 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
742 |
+
array(
|
743 |
+
'google_status' => $google_status
|
744 |
+
),
|
745 |
+
array(
|
746 |
+
'google_order_number' => $google_order_number
|
747 |
+
)
|
748 |
+
);
|
749 |
if ($data['risk-information-notification']['risk-information']['cvn-response']['VALUE'] == 'E') {
|
750 |
$google_risk='cvn';
|
751 |
}
|
757 |
}
|
758 |
}
|
759 |
if (isset($google_risk)) {
|
760 |
+
$wpdb->update(
|
761 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
762 |
+
array(
|
763 |
+
'google_risk' => $google_risk
|
764 |
+
),
|
765 |
+
array(
|
766 |
+
'google_order_number' => $google_order_number
|
767 |
+
)
|
768 |
+
);
|
769 |
}
|
770 |
}
|
771 |
|
772 |
if ($root == "order-state-change-notification") {
|
773 |
$google_order_number = $data['order-state-change-notification']['google-order-number']['VALUE'];
|
774 |
if ($data['order-state-change-notification']['new-financial-order-state']['VALUE'] == "CANCELLED_BY_GOOGLE") {
|
775 |
+
$google_status = $wpdb->get_var( $wpdb->prepare( "SELECT google_status FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE google_order_number = %s", $google_order_number ) );
|
776 |
$google_status = unserialize($google_status);
|
777 |
$google_status[0] = "CANCELLED_BY_GOOGLE";
|
778 |
+
|
779 |
+
$wpdb->update(
|
780 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
781 |
+
array(
|
782 |
+
'google_status' => serialize( $google_status )
|
783 |
+
),
|
784 |
+
array(
|
785 |
+
'google_order_number' => $google_order_number
|
786 |
+
)
|
787 |
+
);
|
788 |
+
|
789 |
+
}
|
790 |
}
|
791 |
exit();
|
792 |
}
|
793 |
}
|
794 |
|
795 |
add_action('init', 'nzsc_googleResponse');
|
796 |
+
|
797 |
?>
|
wpsc-merchants/chronopay.php
CHANGED
@@ -11,7 +11,7 @@ $nzshpcrt_gateways[$num]['image'] = WPSC_URL . '/images/cc.gif';
|
|
11 |
function gateway_chronopay($separator, $sessionid)
|
12 |
{
|
13 |
global $wpdb;
|
14 |
-
$purchase_log_sql = "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`=
|
15 |
$purchase_log = $wpdb->get_results($purchase_log_sql,ARRAY_A) ;
|
16 |
|
17 |
$cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log[0]['id']."'";
|
@@ -84,18 +84,20 @@ function gateway_chronopay($separator, $sessionid)
|
|
84 |
|
85 |
foreach($cart as $item)
|
86 |
{
|
87 |
-
$product_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->posts . "` WHERE `id`=
|
88 |
$product_data = $product_data[0];
|
89 |
$variation_count = count($product_variations);
|
90 |
-
|
91 |
-
|
92 |
-
$
|
|
|
93 |
$variation_count = count($variation_data);
|
94 |
|
95 |
if($variation_count >= 1)
|
96 |
{
|
97 |
$variation_list = " (";
|
98 |
$j = 0;
|
|
|
99 |
foreach($variation_data as $variation)
|
100 |
{
|
101 |
if($j > 0)
|
@@ -103,7 +105,7 @@ function gateway_chronopay($separator, $sessionid)
|
|
103 |
$variation_list .= ", ";
|
104 |
}
|
105 |
$value_id = $variation['venue_id'];
|
106 |
-
$value_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id`=
|
107 |
$variation_list .= $value_data[0]['name'];
|
108 |
$j++;
|
109 |
}
|
11 |
function gateway_chronopay($separator, $sessionid)
|
12 |
{
|
13 |
global $wpdb;
|
14 |
+
$purchase_log_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= %s LIMIT 1", $sessionid );
|
15 |
$purchase_log = $wpdb->get_results($purchase_log_sql,ARRAY_A) ;
|
16 |
|
17 |
$cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log[0]['id']."'";
|
84 |
|
85 |
foreach($cart as $item)
|
86 |
{
|
87 |
+
$product_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . $wpdb->posts . "` WHERE `id`= %d LIMIT 1", $item['prodid'] ), ARRAY_A );
|
88 |
$product_data = $product_data[0];
|
89 |
$variation_count = count($product_variations);
|
90 |
+
|
91 |
+
//Does this even still work in 3.8? We're not using this table.
|
92 |
+
$variation_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CART_ITEM_VARIATIONS."` WHERE `cart_id` = %d", $item['id'] );
|
93 |
+
$variation_data = $wpdb->get_results( $variation_sql, ARRAY_A );
|
94 |
$variation_count = count($variation_data);
|
95 |
|
96 |
if($variation_count >= 1)
|
97 |
{
|
98 |
$variation_list = " (";
|
99 |
$j = 0;
|
100 |
+
|
101 |
foreach($variation_data as $variation)
|
102 |
{
|
103 |
if($j > 0)
|
105 |
$variation_list .= ", ";
|
106 |
}
|
107 |
$value_id = $variation['venue_id'];
|
108 |
+
$value_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id`= %d LIMIT 1", $value_id ), ARRAY_A);
|
109 |
$variation_list .= $value_data[0]['name'];
|
110 |
$j++;
|
111 |
}
|
wpsc-merchants/paypal-express.merchant.php
CHANGED
@@ -280,7 +280,8 @@ class wpsc_merchant_paypal_express extends wpsc_merchant {
|
|
280 |
}
|
281 |
|
282 |
// adjust total amount in case we had to round up after converting currency
|
283 |
-
|
|
|
284 |
$paymentAmount = $total;
|
285 |
|
286 |
$data["PAYMENTREQUEST_0_AMT"] = $paymentAmount;
|
@@ -331,7 +332,7 @@ class wpsc_merchant_paypal_express extends wpsc_merchant {
|
|
331 |
function get_local_currency_code() {
|
332 |
if ( empty( $this->local_currency_code ) ) {
|
333 |
global $wpdb;
|
334 |
-
$this->local_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=
|
335 |
}
|
336 |
|
337 |
return $this->local_currency_code;
|
@@ -513,7 +514,7 @@ function form_paypal_express() {
|
|
513 |
$current_currency = $store_currency_code;
|
514 |
}
|
515 |
if($current_currency != $store_currency_code) {
|
516 |
-
$output .= "<tr> <td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td> </tr>
|
517 |
<tr>
|
518 |
<td colspan='2'>".__('Your website is using 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 convert the currency and send the order through to PayPal using the currency you choose below.', 'wpsc')."</td>
|
519 |
</tr>\n";
|
@@ -524,7 +525,7 @@ function form_paypal_express() {
|
|
524 |
if (!isset($wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list']))
|
525 |
$wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] = array();
|
526 |
|
527 |
-
$paypal_currency_list = $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'];
|
528 |
|
529 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
530 |
foreach($currency_list as $currency_item) {
|
@@ -550,7 +551,7 @@ function form_paypal_express() {
|
|
550 |
|
551 |
function wpsc_get_paypal_currency_code() {
|
552 |
global $wpdb, $wpsc_gateways;
|
553 |
-
$paypal_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=
|
554 |
if ( ! in_array( $paypal_currency_code, $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] ) )
|
555 |
$paypal_currency_code = get_option( 'paypal_curcode', 'USD' );
|
556 |
|
@@ -662,7 +663,7 @@ function paypal_processingfunctions(){
|
|
662 |
}
|
663 |
|
664 |
// Horrible code that I had to write to hot fix the issue with missing item detail in email receipts. arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh!!!!! @#@$%@#%@##$#$
|
665 |
-
$purchase_log = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` =
|
666 |
$cart_data = $original_cart_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = {$purchase_log['id']}", ARRAY_A );
|
667 |
$i = 0;
|
668 |
$item_total = 0;
|
@@ -723,17 +724,42 @@ function paypal_processingfunctions(){
|
|
723 |
if($ack!="SUCCESS"){
|
724 |
$location = get_option('transact_url')."&act=error";
|
725 |
}else{
|
726 |
-
$transaction_id = $
|
727 |
switch($resArray['PAYMENTINFO_0_PAYMENTSTATUS']) {
|
728 |
case 'Processed': // I think this is mostly equivalent to Completed
|
729 |
case 'Completed':
|
730 |
-
$wpdb->
|
731 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
732 |
break;
|
733 |
|
734 |
case 'Pending': // need to wait for "Completed" before processing
|
735 |
-
$wpdb->
|
736 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
737 |
}
|
738 |
$location = add_query_arg('sessionid', $sessionid, get_option('transact_url'));
|
739 |
|
280 |
}
|
281 |
|
282 |
// adjust total amount in case we had to round up after converting currency
|
283 |
+
// or discount calculation
|
284 |
+
if ( $total != $paymentAmount )
|
285 |
$paymentAmount = $total;
|
286 |
|
287 |
$data["PAYMENTREQUEST_0_AMT"] = $paymentAmount;
|
332 |
function get_local_currency_code() {
|
333 |
if ( empty( $this->local_currency_code ) ) {
|
334 |
global $wpdb;
|
335 |
+
$this->local_currency_code = $wpdb->get_var( $wpdb->prepare( "SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d LIMIT 1", get_option('currency_type') ) );
|
336 |
}
|
337 |
|
338 |
return $this->local_currency_code;
|
514 |
$current_currency = $store_currency_code;
|
515 |
}
|
516 |
if($current_currency != $store_currency_code) {
|
517 |
+
$output .= "<tr> <td colspan='2'><strong class='form_group'>" . __( 'Currency Converter', 'wpsc' ) . "</td> </tr>
|
518 |
<tr>
|
519 |
<td colspan='2'>".__('Your website is using 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 convert the currency and send the order through to PayPal using the currency you choose below.', 'wpsc')."</td>
|
520 |
</tr>\n";
|
525 |
if (!isset($wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list']))
|
526 |
$wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] = array();
|
527 |
|
528 |
+
$paypal_currency_list = array_map( 'esc_sql', $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] );
|
529 |
|
530 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
531 |
foreach($currency_list as $currency_item) {
|
551 |
|
552 |
function wpsc_get_paypal_currency_code() {
|
553 |
global $wpdb, $wpsc_gateways;
|
554 |
+
$paypal_currency_code = $wpdb->get_var( $wpdb->prepare( "SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d LIMIT 1", get_option( 'currency_type' ) ) );
|
555 |
if ( ! in_array( $paypal_currency_code, $wpsc_gateways['wpsc_merchant_paypal_express']['supported_currencies']['currency_list'] ) )
|
556 |
$paypal_currency_code = get_option( 'paypal_curcode', 'USD' );
|
557 |
|
663 |
}
|
664 |
|
665 |
// Horrible code that I had to write to hot fix the issue with missing item detail in email receipts. arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh!!!!! @#@$%@#%@##$#$
|
666 |
+
$purchase_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid` = %s", $sessionid ), ARRAY_A );
|
667 |
$cart_data = $original_cart_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = {$purchase_log['id']}", ARRAY_A );
|
668 |
$i = 0;
|
669 |
$item_total = 0;
|
724 |
if($ack!="SUCCESS"){
|
725 |
$location = get_option('transact_url')."&act=error";
|
726 |
}else{
|
727 |
+
$transaction_id = $resArray['PAYMENTINFO_0_TRANSACTIONID'];
|
728 |
switch($resArray['PAYMENTINFO_0_PAYMENTSTATUS']) {
|
729 |
case 'Processed': // I think this is mostly equivalent to Completed
|
730 |
case 'Completed':
|
731 |
+
$wpdb->update(
|
732 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
733 |
+
array(
|
734 |
+
'processed' => 3,
|
735 |
+
),
|
736 |
+
array(
|
737 |
+
'sessionid' => $sessionid
|
738 |
+
),
|
739 |
+
'%d',
|
740 |
+
'%s'
|
741 |
+
);
|
742 |
+
transaction_results( $sessionid, false );
|
743 |
break;
|
744 |
|
745 |
case 'Pending': // need to wait for "Completed" before processing
|
746 |
+
$wpdb->update(
|
747 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
748 |
+
array(
|
749 |
+
'processed' => 2,
|
750 |
+
'date' => time(),
|
751 |
+
'transactid' => $transaction_id
|
752 |
+
),
|
753 |
+
array(
|
754 |
+
'sessionid' => $sessionid
|
755 |
+
),
|
756 |
+
array(
|
757 |
+
'%d',
|
758 |
+
'%s',
|
759 |
+
'%s',
|
760 |
+
),
|
761 |
+
'%s'
|
762 |
+
); break;
|
763 |
}
|
764 |
$location = add_query_arg('sessionid', $sessionid, get_option('transact_url'));
|
765 |
|
wpsc-merchants/paypal-pro.merchant.php
CHANGED
@@ -42,7 +42,7 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
|
|
42 |
function get_local_currency_code() {
|
43 |
if ( empty( $this->local_currency_code ) ) {
|
44 |
global $wpdb;
|
45 |
-
$this->local_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`=
|
46 |
}
|
47 |
|
48 |
return $this->local_currency_code;
|
@@ -160,7 +160,7 @@ class wpsc_merchant_paypal_pro extends wpsc_merchant {
|
|
160 |
$data['SHIPPINGAMT'] = $this->format_price( $shipping_total );
|
161 |
$data['TAXAMT'] = $this->convert( $tax_total );
|
162 |
$data['AMT'] = $data['ITEMAMT'] + $data['SHIPPINGAMT'] + $data['TAXAMT'];
|
163 |
-
$this->collected_gateway_data = $data;
|
164 |
}
|
165 |
|
166 |
/**
|
@@ -435,7 +435,7 @@ function form_paypal_pro() {
|
|
435 |
</td>
|
436 |
</tr>';
|
437 |
|
438 |
-
$store_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN (
|
439 |
$current_currency = get_option('paypal_curcode');
|
440 |
|
441 |
if(($current_currency == '') && in_array($store_currency_code, $wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'])) {
|
@@ -443,7 +443,7 @@ function form_paypal_pro() {
|
|
443 |
$current_currency = $store_currency_code;
|
444 |
}
|
445 |
if($current_currency != $store_currency_code) {
|
446 |
-
$output .= "<tr> <td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td> </tr>
|
447 |
<tr>
|
448 |
<td colspan='2'>".__('Your website is using 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 convert the currency and send the order through to PayPal using the currency you choose below.', 'wpsc')."</td>
|
449 |
</tr>\n";
|
@@ -454,7 +454,7 @@ function form_paypal_pro() {
|
|
454 |
if (!isset($wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list']))
|
455 |
$wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'] = array();
|
456 |
|
457 |
-
$paypal_currency_list = $wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'];
|
458 |
|
459 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
460 |
foreach($currency_list as $currency_item) {
|
42 |
function get_local_currency_code() {
|
43 |
if ( empty( $this->local_currency_code ) ) {
|
44 |
global $wpdb;
|
45 |
+
$this->local_currency_code = $wpdb->get_var( $wpdb->prepare( "SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d LIMIT 1", get_option( 'currency_type' ) ) );
|
46 |
}
|
47 |
|
48 |
return $this->local_currency_code;
|
160 |
$data['SHIPPINGAMT'] = $this->format_price( $shipping_total );
|
161 |
$data['TAXAMT'] = $this->convert( $tax_total );
|
162 |
$data['AMT'] = $data['ITEMAMT'] + $data['SHIPPINGAMT'] + $data['TAXAMT'];
|
163 |
+
$this->collected_gateway_data = apply_filters( 'wpsc_paypal_pro_gateway_data_array', $data, $this->cart_items );
|
164 |
}
|
165 |
|
166 |
/**
|
435 |
</td>
|
436 |
</tr>';
|
437 |
|
438 |
+
$store_currency_code = $wpdb->get_var( $wpdb->prepare( "SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN (%d)", get_option( 'currency_type' ) ) );
|
439 |
$current_currency = get_option('paypal_curcode');
|
440 |
|
441 |
if(($current_currency == '') && in_array($store_currency_code, $wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'])) {
|
443 |
$current_currency = $store_currency_code;
|
444 |
}
|
445 |
if($current_currency != $store_currency_code) {
|
446 |
+
$output .= "<tr> <td colspan='2'><strong class='form_group'>" . __( 'Currency Converter', 'wpsc' ) . "</td> </tr>
|
447 |
<tr>
|
448 |
<td colspan='2'>".__('Your website is using 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 convert the currency and send the order through to PayPal using the currency you choose below.', 'wpsc')."</td>
|
449 |
</tr>\n";
|
454 |
if (!isset($wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list']))
|
455 |
$wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'] = array();
|
456 |
|
457 |
+
$paypal_currency_list = array_map( 'esc_sql', $wpsc_gateways['wpsc_merchant_paypal_pro']['supported_currencies']['currency_list'] );
|
458 |
|
459 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
460 |
foreach($currency_list as $currency_item) {
|
wpsc-merchants/paypal-standard.merchant.php
CHANGED
@@ -75,7 +75,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
|
|
75 |
function get_local_currency_code() {
|
76 |
if ( empty( $this->local_currency_code ) ) {
|
77 |
global $wpdb;
|
78 |
-
$this->local_currency_code = $wpdb->get_var("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id
|
79 |
}
|
80 |
|
81 |
return $this->local_currency_code;
|
@@ -291,7 +291,7 @@ class wpsc_merchant_paypal_standard extends wpsc_merchant {
|
|
291 |
|
292 |
$paypal_vars['tax_cart'] = $this->convert( $tax_total );
|
293 |
}
|
294 |
-
return $paypal_vars;
|
295 |
}
|
296 |
|
297 |
/**
|
@@ -621,7 +621,7 @@ function form_paypal_multiple() {
|
|
621 |
|
622 |
|
623 |
|
624 |
-
$store_currency_data = $wpdb->get_row("SELECT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN (
|
625 |
$current_currency = get_option('paypal_curcode');
|
626 |
if(($current_currency == '') && in_array($store_currency_data['code'], $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'])) {
|
627 |
update_option('paypal_curcode', $store_currency_data['code']);
|
@@ -631,7 +631,7 @@ function form_paypal_multiple() {
|
|
631 |
if($current_currency != $store_currency_data['code']) {
|
632 |
$output .= "
|
633 |
<tr>
|
634 |
-
<td colspan='2'><strong class='form_group'>".__('Currency Converter')."</td>
|
635 |
</tr>
|
636 |
<tr>
|
637 |
<td colspan='2'>".sprintf(__('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.', 'wpsc'), $store_currency_data['currency'])."</td>
|
@@ -645,7 +645,7 @@ function form_paypal_multiple() {
|
|
645 |
$output .= " <td>\n";
|
646 |
$output .= " <select name='paypal_curcode'>\n";
|
647 |
|
648 |
-
$paypal_currency_list = $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'];
|
649 |
|
650 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
651 |
|
75 |
function get_local_currency_code() {
|
76 |
if ( empty( $this->local_currency_code ) ) {
|
77 |
global $wpdb;
|
78 |
+
$this->local_currency_code = $wpdb->get_var( $wpdb->prepare( "SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` = %d LIMIT 1", get_option( 'currency_type' ) ) );
|
79 |
}
|
80 |
|
81 |
return $this->local_currency_code;
|
291 |
|
292 |
$paypal_vars['tax_cart'] = $this->convert( $tax_total );
|
293 |
}
|
294 |
+
return apply_filters( 'wpsc_paypal_standard_post_data', $paypal_vars );
|
295 |
}
|
296 |
|
297 |
/**
|
621 |
|
622 |
|
623 |
|
624 |
+
$store_currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id` IN (%d)", get_option( 'currency_type' ) ), ARRAY_A);
|
625 |
$current_currency = get_option('paypal_curcode');
|
626 |
if(($current_currency == '') && in_array($store_currency_data['code'], $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'])) {
|
627 |
update_option('paypal_curcode', $store_currency_data['code']);
|
631 |
if($current_currency != $store_currency_data['code']) {
|
632 |
$output .= "
|
633 |
<tr>
|
634 |
+
<td colspan='2'><strong class='form_group'>" . __( 'Currency Converter', 'wpsc' ) . "</td>
|
635 |
</tr>
|
636 |
<tr>
|
637 |
<td colspan='2'>".sprintf(__('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.', 'wpsc'), $store_currency_data['currency'])."</td>
|
645 |
$output .= " <td>\n";
|
646 |
$output .= " <select name='paypal_curcode'>\n";
|
647 |
|
648 |
+
$paypal_currency_list = array_map( 'esc_sql', $wpsc_gateways['wpsc_merchant_paypal_standard']['supported_currencies']['currency_list'] );
|
649 |
|
650 |
$currency_list = $wpdb->get_results("SELECT DISTINCT `code`, `currency` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `code` IN ('".implode("','",$paypal_currency_list)."')", ARRAY_A);
|
651 |
|
wpsc-shipping/library/shipwire_functions.php
CHANGED
@@ -35,7 +35,7 @@ function shipwire_build_xml($log_id) {
|
|
35 |
}
|
36 |
}
|
37 |
|
38 |
-
$user_infos = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_SUBMITED_FORM_DATA." WHERE log_id=
|
39 |
foreach ($user_infos as $user_info) {
|
40 |
if ($user_info['form_id'] == $address_key) {
|
41 |
$address = $user_info['value'];
|
@@ -57,12 +57,12 @@ function shipwire_build_xml($log_id) {
|
|
57 |
}
|
58 |
}
|
59 |
if (($first_name_key == '') || ($last_name_key == '')) {
|
60 |
-
$log_info = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE id=
|
61 |
$first_name = $log_info[0]['firstname'];
|
62 |
$last_name = $log_info[0]['lastname'];
|
63 |
}
|
64 |
$full_name = $first_name." ".$last_name;
|
65 |
-
$products = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_CART_CONTENTS." WHERE purchaseid=
|
66 |
$xml = "<?xml version='1.0' encoding='utf-8'?>";
|
67 |
$xml .= "<OrderList>";
|
68 |
$xml .= "<EmailAddress>$email</EmailAddress>";
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
$user_infos = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".WPSC_TABLE_SUBMITED_FORM_DATA." WHERE log_id = %d", $log_id ), ARRAY_A);
|
39 |
foreach ($user_infos as $user_info) {
|
40 |
if ($user_info['form_id'] == $address_key) {
|
41 |
$address = $user_info['value'];
|
57 |
}
|
58 |
}
|
59 |
if (($first_name_key == '') || ($last_name_key == '')) {
|
60 |
+
$log_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".WPSC_TABLE_PURCHASE_LOGS." WHERE id= %d", $log_id ) );
|
61 |
$first_name = $log_info[0]['firstname'];
|
62 |
$last_name = $log_info[0]['lastname'];
|
63 |
}
|
64 |
$full_name = $first_name." ".$last_name;
|
65 |
+
$products = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".WPSC_TABLE_CART_CONTENTS." WHERE purchaseid = %d", $log_id ),ARRAY_A);
|
66 |
$xml = "<?xml version='1.0' encoding='utf-8'?>";
|
67 |
$xml .= "<OrderList>";
|
68 |
$xml .= "<EmailAddress>$email</EmailAddress>";
|
wpsc-shipping/tablerate.php
CHANGED
@@ -40,37 +40,67 @@ class tablerate {
|
|
40 |
return $this->internal_name;
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
/**
|
44 |
*
|
45 |
*
|
46 |
* @return unknown
|
47 |
*/
|
48 |
function getForm() {
|
49 |
-
$
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
/**
|
@@ -79,29 +109,23 @@ class tablerate {
|
|
79 |
* @return unknown
|
80 |
*/
|
81 |
function submit_form() {
|
82 |
-
if (!isset($_POST['
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
$new_layer = array();
|
86 |
if ($shippings != '') {
|
87 |
foreach ($shippings as $key => $price) {
|
88 |
-
if ( empty( $price ) )
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
$new_layer[$layers[$key]] = $price;
|
93 |
-
}
|
94 |
}
|
95 |
}
|
96 |
// Sort the data before it goes into the database. Makes the UI make more sense
|
97 |
-
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
if (!isset($_POST['checkpage'])) $_POST['checkpage'] = '';
|
102 |
-
if ($_POST['checkpage'] == 'table') {
|
103 |
-
update_option('table_rate_layers', $new_layer);
|
104 |
-
}
|
105 |
return true;
|
106 |
}
|
107 |
|
40 |
return $this->internal_name;
|
41 |
}
|
42 |
|
43 |
+
private function output_row( $key = '', $shipping = '' ) {
|
44 |
+
$currency = wpsc_get_currency_symbol();
|
45 |
+
$class = ( $this->alt ) ? ' class="alternate"' : '';
|
46 |
+
$this->alt = ! $this->alt;
|
47 |
+
?>
|
48 |
+
<tr>
|
49 |
+
<td<?php echo $class; ?>>
|
50 |
+
<div class="cell-wrapper">
|
51 |
+
<small><?php echo esc_html( $currency ); ?></small>
|
52 |
+
<input type="text" name="wpsc_shipping_tablerate_layer[]" value="<?php echo esc_attr( $key ); ?>" size="4" />
|
53 |
+
<small><?php _e( ' and above', 'wpsc' ); ?></small>
|
54 |
+
</div>
|
55 |
+
</td>
|
56 |
+
<td<?php echo $class; ?>>
|
57 |
+
<div class="cell-wrapper">
|
58 |
+
<small><?php echo esc_html( $currency ); ?></small>
|
59 |
+
<input type="text" name="wpsc_shipping_tablerate_shipping[]" value="<?php echo esc_attr( $shipping ); ?>" size="4" />
|
60 |
+
<div class="actions">
|
61 |
+
<a tabindex="-1" title="<?php _e( 'Add Layer', 'wpsc' ); ?>" class="action add" href="#">Add</a>
|
62 |
+
<a tabindex="-1" title="<?php _e( 'Delete Layer', 'wpsc' ); ?>" class="action delete" href="#">Delete</a>
|
63 |
+
</div>
|
64 |
+
</div>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
|
70 |
/**
|
71 |
*
|
72 |
*
|
73 |
* @return unknown
|
74 |
*/
|
75 |
function getForm() {
|
76 |
+
$layers = get_option( 'table_rate_layers', array() );
|
77 |
+
$this->alt = false;
|
78 |
+
ob_start();
|
79 |
+
?>
|
80 |
+
<thead>
|
81 |
+
<tr>
|
82 |
+
<th class="total"><?php _e('Total Price', 'wpsc' ); ?></th>
|
83 |
+
<th class="shipping"><?php _e( 'Shipping Price', 'wpsc' ); ?></th>
|
84 |
+
</tr>
|
85 |
+
</thead>
|
86 |
+
<tbody class="table-rate">
|
87 |
+
<tr class="js-warning">
|
88 |
+
<td colspan="2">
|
89 |
+
<small><?php echo sprintf( __( 'To remove a rate layer, simply leave the values on that row blank. By the way, <a href="%s">enable JavaScript</a> for a better user experience.'), 'http://www.google.com/support/bin/answer.py?answer=23852' ); ?></small>
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
<?php if ( ! empty( $layers ) ): ?>
|
93 |
+
<?php
|
94 |
+
foreach( $layers as $key => $shipping ){
|
95 |
+
$this->output_row( $key, $shipping );
|
96 |
+
}
|
97 |
+
?>
|
98 |
+
<?php else: ?>
|
99 |
+
<?php $this->output_row(); ?>
|
100 |
+
<?php endif ?>
|
101 |
+
</tbody>
|
102 |
+
<?php
|
103 |
+
return ob_get_clean();
|
104 |
}
|
105 |
|
106 |
/**
|
109 |
* @return unknown
|
110 |
*/
|
111 |
function submit_form() {
|
112 |
+
if ( ! isset( $_POST['wpsc_shipping_tablerate_layer'] ) || ! isset( $_POST['wpsc_shipping_tablerate_shipping'] ) )
|
113 |
+
return false;
|
114 |
+
|
115 |
+
$layers = (array) $_POST['wpsc_shipping_tablerate_layer'];
|
116 |
+
$shippings = (array) $_POST['wpsc_shipping_tablerate_shipping'];
|
117 |
$new_layer = array();
|
118 |
if ($shippings != '') {
|
119 |
foreach ($shippings as $key => $price) {
|
120 |
+
if ( empty( $price ) || empty( $layers[$key] ) )
|
121 |
+
continue;
|
122 |
+
|
123 |
+
$new_layer[$layers[$key]] = $price;
|
|
|
|
|
124 |
}
|
125 |
}
|
126 |
// Sort the data before it goes into the database. Makes the UI make more sense
|
127 |
+
krsort( $new_layer );
|
128 |
+
update_option('table_rate_layers', $new_layer);
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
return true;
|
130 |
}
|
131 |
|
wpsc-shipping/ups_20.php
CHANGED
@@ -145,7 +145,7 @@ class ash_ups {
|
|
145 |
}
|
146 |
</script>");
|
147 |
$output .= " <select id='drop_type' name='wpsc_ups_settings[DropoffType]' onChange='checkDropValue()' >\n\r";
|
148 |
-
|
149 |
$sel2_drop = "";
|
150 |
if (empty($wpsc_ups_settings['DropoffType'])){
|
151 |
$sel2_drop = "01";
|
@@ -169,7 +169,7 @@ class ash_ups {
|
|
169 |
$output .= " <td>".__('Customer Type', 'wpsc')."</td>\n\r";
|
170 |
$output .= " <td>\n\r";
|
171 |
$output .= " <select id='cust_type' name='wpsc_ups_settings[CustomerType]' ".$cust." >\n\r";
|
172 |
-
|
173 |
$sel3_drop = "";
|
174 |
if (empty($wpsc_ups_settings['CustomerType'])){
|
175 |
$sel3_drop = "01";
|
@@ -201,16 +201,11 @@ class ash_ups {
|
|
201 |
$output .= " </select>\n\r";
|
202 |
$output .= " </td>\n\r";
|
203 |
$output .= "</tr>\n\r";
|
204 |
-
|
205 |
-
$selected_env = $wpsc_ups_settings['upsenvironment'];
|
206 |
-
if ($selected_env == "1"){
|
207 |
-
$env_test = "checked=\"checked\"";
|
208 |
-
}
|
209 |
$output .= ("
|
210 |
<tr>
|
211 |
<td><label for=\"ups_env_test\" >".__('Use Testing Environment', 'wpsc')."</label></td>
|
212 |
<td>
|
213 |
-
<input type=\"checkbox\" id=\"ups_env_test\" name=\"wpsc_ups_settings[upsenvironment]\" value=\"1\" "
|
214 |
</td>
|
215 |
</tr>
|
216 |
");
|
@@ -248,7 +243,7 @@ class ash_ups {
|
|
248 |
<td><label for=\"ups_singular_shipping\" >".__('Singular Shipping', 'wpsc')." *</label></td>
|
249 |
<td>
|
250 |
<input type=\"checkbox\" id=\"ups_singular_shipping\" name=\"wpsc_ups_settings[singular_shipping]\" value=\"1\" ".$singular_shipping." /><br />
|
251 |
-
".__('Rate each quantity of items in a cart as its own package using dimensions on product')."
|
252 |
</td>
|
253 |
</tr>
|
254 |
");
|
@@ -368,7 +363,7 @@ class ash_ups {
|
|
368 |
$pack["LargePackageIndicator"] = "";
|
369 |
}
|
370 |
}
|
371 |
-
|
372 |
private function _insured_value(&$pack, $package, $args){
|
373 |
$monetary_value = $package->value;
|
374 |
if ($package->insurance === TRUE){
|
@@ -380,16 +375,16 @@ class ash_ups {
|
|
380 |
"MonetaryValue" => $package->insured_amount
|
381 |
);
|
382 |
}
|
383 |
-
|
384 |
}
|
385 |
-
|
386 |
private function _declared_value(&$pack, $package, $args){
|
387 |
$pack["PackageServiceOptions"]["DeclaredValue"] = array(
|
388 |
"CurrencyCode" => $args["currency"],
|
389 |
"MonetaryValue" => $args["cart_total"]
|
390 |
);
|
391 |
}
|
392 |
-
|
393 |
private function _build_shipment(&$Shipment, $args){
|
394 |
$cart_shipment = $this->shipment;
|
395 |
|
@@ -500,9 +495,9 @@ class ash_ups {
|
|
500 |
$Shipper["Address"]["City"] = $args["shipr_city"];
|
501 |
}
|
502 |
}
|
503 |
-
|
504 |
$Shipment .= $this->array2xml(array("Shipper"=>$Shipper));
|
505 |
-
|
506 |
// The physical address the shipment is from (normally the same as billing)
|
507 |
$ShipFrom=array(
|
508 |
"Address"=>array(
|
@@ -519,7 +514,7 @@ class ash_ups {
|
|
519 |
}
|
520 |
|
521 |
$Shipment .= $this->array2xml(array("ShipFrom"=>$ShipFrom));
|
522 |
-
|
523 |
$ShipTo= array(
|
524 |
"Address"=>array(
|
525 |
"StateProvinceCode"=>$args['dest_state'], // The Destination State
|
@@ -531,7 +526,7 @@ class ash_ups {
|
|
531 |
if ($args['residential'] == '1'){ //ResidentialAddressIndicator orig - Indicator
|
532 |
$ShipTo["Address"]["ResidentialAddressIndicator"] = "1";
|
533 |
}
|
534 |
-
|
535 |
$Shipment .= $this->array2xml(array("ShipTo"=>$ShipTo));
|
536 |
|
537 |
// If there is a specific service being requested then
|
@@ -546,7 +541,7 @@ class ash_ups {
|
|
546 |
$Shipment .=array("RateInformation"=>array("NegotiatedRatesIndicator" => ""));
|
547 |
}
|
548 |
}
|
549 |
-
|
550 |
if ((boolean)$args["singular_shipping"]){
|
551 |
$this->_build_shipment($Shipment,$args);
|
552 |
}else{
|
@@ -565,7 +560,7 @@ class ash_ups {
|
|
565 |
)
|
566 |
);
|
567 |
}
|
568 |
-
|
569 |
$Shipment .= $this->array2xml($package);
|
570 |
}
|
571 |
|
@@ -754,7 +749,7 @@ class ash_ups {
|
|
754 |
function getQuote(){
|
755 |
global $wpdb, $wpec_ash;
|
756 |
if (!is_object($wpec_ash)){
|
757 |
-
$wpec_ash = new ASH();
|
758 |
}
|
759 |
|
760 |
|
@@ -766,7 +761,7 @@ class ash_ups {
|
|
766 |
$wpsc_ups_settings = get_option("wpsc_ups_settings", array());
|
767 |
// Get the wordpress shopping cart options
|
768 |
$wpsc_options = get_option("wpsc_options");
|
769 |
-
|
770 |
// API Auth settings //
|
771 |
$args['username'] = (array_key_exists('upsaccount',$wpsc_ups_settings)) ? $wpsc_ups_settings['upsusername'] : "";
|
772 |
$args['password'] = (array_key_exists('upspassword',$wpsc_ups_settings)) ? $wpsc_ups_settings['upspassword'] : "";
|
@@ -781,18 +776,18 @@ class ash_ups {
|
|
781 |
$args['DropoffType'] = $wpsc_ups_settings['DropoffType'];
|
782 |
$args['packaging'] = $wpsc_ups_settings['48_container'];
|
783 |
// Preferred Currency to display
|
784 |
-
$currency_data = $wpdb->get_row("SELECT `code`
|
785 |
FROM `".WPSC_TABLE_CURRENCY_LIST."`
|
786 |
-
WHERE `isocode`=
|
787 |
-
LIMIT 1", ARRAY_A) ;
|
788 |
if ($currency_data){
|
789 |
$args['currency'] = $currency_data['code'];
|
790 |
}else{
|
791 |
$args['currency'] = "USD";
|
792 |
}
|
793 |
// Shipping billing / account address
|
794 |
-
$origin_region_data = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
|
795 |
-
WHERE `".WPSC_TABLE_REGION_TAX."`.`id` =
|
796 |
$args['shipr_state']= (is_array($origin_region_data)) ? $origin_region_data[0]['code'] : "";
|
797 |
$args['shipr_city'] = get_option('base_city');
|
798 |
$args['shipr_ccode'] = get_option('base_country');
|
@@ -811,7 +806,7 @@ class ash_ups {
|
|
811 |
// So, UPS is a little off the times
|
812 |
$args['dest_ccode'] = "GB";
|
813 |
}
|
814 |
-
|
815 |
// If ths zip code is provided via a form post use it!
|
816 |
$args['dest_pcode'] = '';
|
817 |
if(isset($_POST['zipcode']) && ($_POST['zipcode'] != "Your Zipcode" && $_POST['zipcode'] != "YOURZIPCODE")) {
|
@@ -825,7 +820,7 @@ class ash_ups {
|
|
825 |
// We cannot get a quote without a zip code so might as well return!
|
826 |
return array();
|
827 |
}
|
828 |
-
|
829 |
// If the region code is provided via a form post use it!
|
830 |
if(isset($_POST['region']) && !empty($_POST['region'])) {
|
831 |
$query = $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
|
@@ -839,7 +834,7 @@ class ash_ups {
|
|
839 |
} else{
|
840 |
$args['dest_state'] = "";
|
841 |
}
|
842 |
-
|
843 |
$shipping_cache_check['state'] = $args['dest_state'];
|
844 |
$shipping_cache_check['zipcode'] = $args['dest_pcode'];
|
845 |
$shipping_cache_check['weight'] = $args['weight'];
|
@@ -858,7 +853,7 @@ class ash_ups {
|
|
858 |
// have a shipping quote!
|
859 |
if(($_SESSION['wpsc_shipping_cache_check'] === $shipping_cache_check)
|
860 |
&& ($_SESSION['wpsc_shipping_cache'][$this->internal_name] != null)) {
|
861 |
-
|
862 |
$rate_table = $_SESSION['wpsc_shipping_cache'][$this->internal_name];
|
863 |
return $rate_table;
|
864 |
}else{
|
@@ -888,11 +883,11 @@ class ash_ups {
|
|
888 |
}
|
889 |
}
|
890 |
}
|
891 |
-
|
892 |
$wpec_ash->cache_results($this->internal_name,
|
893 |
$args["dest_ccode"], $args["dest_state"],
|
894 |
$args["dest_pcode"], $rate_table, $this->shipment);
|
895 |
-
|
896 |
// return the final formatted array !
|
897 |
return $rate_table;
|
898 |
}
|
145 |
}
|
146 |
</script>");
|
147 |
$output .= " <select id='drop_type' name='wpsc_ups_settings[DropoffType]' onChange='checkDropValue()' >\n\r";
|
148 |
+
|
149 |
$sel2_drop = "";
|
150 |
if (empty($wpsc_ups_settings['DropoffType'])){
|
151 |
$sel2_drop = "01";
|
169 |
$output .= " <td>".__('Customer Type', 'wpsc')."</td>\n\r";
|
170 |
$output .= " <td>\n\r";
|
171 |
$output .= " <select id='cust_type' name='wpsc_ups_settings[CustomerType]' ".$cust." >\n\r";
|
172 |
+
|
173 |
$sel3_drop = "";
|
174 |
if (empty($wpsc_ups_settings['CustomerType'])){
|
175 |
$sel3_drop = "01";
|
201 |
$output .= " </select>\n\r";
|
202 |
$output .= " </td>\n\r";
|
203 |
$output .= "</tr>\n\r";
|
|
|
|
|
|
|
|
|
|
|
204 |
$output .= ("
|
205 |
<tr>
|
206 |
<td><label for=\"ups_env_test\" >".__('Use Testing Environment', 'wpsc')."</label></td>
|
207 |
<td>
|
208 |
+
<input type=\"checkbox\" id=\"ups_env_test\" name=\"wpsc_ups_settings[upsenvironment]\" value=\"1\" ". checked( $wpsc_ups_settings['upsenvironment'], 1, false ) ." /><br />
|
209 |
</td>
|
210 |
</tr>
|
211 |
");
|
243 |
<td><label for=\"ups_singular_shipping\" >".__('Singular Shipping', 'wpsc')." *</label></td>
|
244 |
<td>
|
245 |
<input type=\"checkbox\" id=\"ups_singular_shipping\" name=\"wpsc_ups_settings[singular_shipping]\" value=\"1\" ".$singular_shipping." /><br />
|
246 |
+
" . __( 'Rate each quantity of items in a cart as its own package using dimensions on product', 'wpsc' ) . "
|
247 |
</td>
|
248 |
</tr>
|
249 |
");
|
363 |
$pack["LargePackageIndicator"] = "";
|
364 |
}
|
365 |
}
|
366 |
+
|
367 |
private function _insured_value(&$pack, $package, $args){
|
368 |
$monetary_value = $package->value;
|
369 |
if ($package->insurance === TRUE){
|
375 |
"MonetaryValue" => $package->insured_amount
|
376 |
);
|
377 |
}
|
378 |
+
|
379 |
}
|
380 |
+
|
381 |
private function _declared_value(&$pack, $package, $args){
|
382 |
$pack["PackageServiceOptions"]["DeclaredValue"] = array(
|
383 |
"CurrencyCode" => $args["currency"],
|
384 |
"MonetaryValue" => $args["cart_total"]
|
385 |
);
|
386 |
}
|
387 |
+
|
388 |
private function _build_shipment(&$Shipment, $args){
|
389 |
$cart_shipment = $this->shipment;
|
390 |
|
495 |
$Shipper["Address"]["City"] = $args["shipr_city"];
|
496 |
}
|
497 |
}
|
498 |
+
|
499 |
$Shipment .= $this->array2xml(array("Shipper"=>$Shipper));
|
500 |
+
|
501 |
// The physical address the shipment is from (normally the same as billing)
|
502 |
$ShipFrom=array(
|
503 |
"Address"=>array(
|
514 |
}
|
515 |
|
516 |
$Shipment .= $this->array2xml(array("ShipFrom"=>$ShipFrom));
|
517 |
+
|
518 |
$ShipTo= array(
|
519 |
"Address"=>array(
|
520 |
"StateProvinceCode"=>$args['dest_state'], // The Destination State
|
526 |
if ($args['residential'] == '1'){ //ResidentialAddressIndicator orig - Indicator
|
527 |
$ShipTo["Address"]["ResidentialAddressIndicator"] = "1";
|
528 |
}
|
529 |
+
|
530 |
$Shipment .= $this->array2xml(array("ShipTo"=>$ShipTo));
|
531 |
|
532 |
// If there is a specific service being requested then
|
541 |
$Shipment .=array("RateInformation"=>array("NegotiatedRatesIndicator" => ""));
|
542 |
}
|
543 |
}
|
544 |
+
|
545 |
if ((boolean)$args["singular_shipping"]){
|
546 |
$this->_build_shipment($Shipment,$args);
|
547 |
}else{
|
560 |
)
|
561 |
);
|
562 |
}
|
563 |
+
|
564 |
$Shipment .= $this->array2xml($package);
|
565 |
}
|
566 |
|
749 |
function getQuote(){
|
750 |
global $wpdb, $wpec_ash;
|
751 |
if (!is_object($wpec_ash)){
|
752 |
+
$wpec_ash = new ASH();
|
753 |
}
|
754 |
|
755 |
|
761 |
$wpsc_ups_settings = get_option("wpsc_ups_settings", array());
|
762 |
// Get the wordpress shopping cart options
|
763 |
$wpsc_options = get_option("wpsc_options");
|
764 |
+
|
765 |
// API Auth settings //
|
766 |
$args['username'] = (array_key_exists('upsaccount',$wpsc_ups_settings)) ? $wpsc_ups_settings['upsusername'] : "";
|
767 |
$args['password'] = (array_key_exists('upspassword',$wpsc_ups_settings)) ? $wpsc_ups_settings['upspassword'] : "";
|
776 |
$args['DropoffType'] = $wpsc_ups_settings['DropoffType'];
|
777 |
$args['packaging'] = $wpsc_ups_settings['48_container'];
|
778 |
// Preferred Currency to display
|
779 |
+
$currency_data = $wpdb->get_row( $wpdb->prepare( "SELECT `code`
|
780 |
FROM `".WPSC_TABLE_CURRENCY_LIST."`
|
781 |
+
WHERE `isocode`= %s
|
782 |
+
LIMIT 1", get_option( 'currency_type' ) ), ARRAY_A ) ;
|
783 |
if ($currency_data){
|
784 |
$args['currency'] = $currency_data['code'];
|
785 |
}else{
|
786 |
$args['currency'] = "USD";
|
787 |
}
|
788 |
// Shipping billing / account address
|
789 |
+
$origin_region_data = $wpdb->get_results( $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
|
790 |
+
WHERE `".WPSC_TABLE_REGION_TAX."`.`id` = %d ", get_option( 'base_region' ) ),ARRAY_A);
|
791 |
$args['shipr_state']= (is_array($origin_region_data)) ? $origin_region_data[0]['code'] : "";
|
792 |
$args['shipr_city'] = get_option('base_city');
|
793 |
$args['shipr_ccode'] = get_option('base_country');
|
806 |
// So, UPS is a little off the times
|
807 |
$args['dest_ccode'] = "GB";
|
808 |
}
|
809 |
+
|
810 |
// If ths zip code is provided via a form post use it!
|
811 |
$args['dest_pcode'] = '';
|
812 |
if(isset($_POST['zipcode']) && ($_POST['zipcode'] != "Your Zipcode" && $_POST['zipcode'] != "YOURZIPCODE")) {
|
820 |
// We cannot get a quote without a zip code so might as well return!
|
821 |
return array();
|
822 |
}
|
823 |
+
|
824 |
// If the region code is provided via a form post use it!
|
825 |
if(isset($_POST['region']) && !empty($_POST['region'])) {
|
826 |
$query = $wpdb->prepare( "SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`
|
834 |
} else{
|
835 |
$args['dest_state'] = "";
|
836 |
}
|
837 |
+
|
838 |
$shipping_cache_check['state'] = $args['dest_state'];
|
839 |
$shipping_cache_check['zipcode'] = $args['dest_pcode'];
|
840 |
$shipping_cache_check['weight'] = $args['weight'];
|
853 |
// have a shipping quote!
|
854 |
if(($_SESSION['wpsc_shipping_cache_check'] === $shipping_cache_check)
|
855 |
&& ($_SESSION['wpsc_shipping_cache'][$this->internal_name] != null)) {
|
856 |
+
|
857 |
$rate_table = $_SESSION['wpsc_shipping_cache'][$this->internal_name];
|
858 |
return $rate_table;
|
859 |
}else{
|
883 |
}
|
884 |
}
|
885 |
}
|
886 |
+
|
887 |
$wpec_ash->cache_results($this->internal_name,
|
888 |
$args["dest_ccode"], $args["dest_state"],
|
889 |
$args["dest_pcode"], $rate_table, $this->shipment);
|
890 |
+
|
891 |
// return the final formatted array !
|
892 |
return $rate_table;
|
893 |
}
|
wpsc-shipping/usps_20.php
CHANGED
@@ -55,7 +55,7 @@ class ash_usps{
|
|
55 |
* @var ASHShipment|Null
|
56 |
*/
|
57 |
var $shipment=NULL;
|
58 |
-
|
59 |
/**
|
60 |
* Constructor for USPS class
|
61 |
* Automatically loads services that are available into the class instance
|
@@ -65,7 +65,7 @@ class ash_usps{
|
|
65 |
$this->_load_services();
|
66 |
return TRUE;
|
67 |
}
|
68 |
-
|
69 |
/**
|
70 |
* retrieves the USPS ID, not used
|
71 |
* This function only exists due to legacy code
|
@@ -76,7 +76,7 @@ class ash_usps{
|
|
76 |
function getID(){
|
77 |
return $this->$usps_id;
|
78 |
}
|
79 |
-
|
80 |
/**
|
81 |
* Sets the USPS ID, not used
|
82 |
* This function only exists due to legacy code, unused
|
@@ -87,7 +87,7 @@ class ash_usps{
|
|
87 |
function setId($id){
|
88 |
$this->$usps_id = $id;
|
89 |
}
|
90 |
-
|
91 |
/**
|
92 |
* Retrieves the external display name for the module
|
93 |
* @since 1.0
|
@@ -96,7 +96,7 @@ class ash_usps{
|
|
96 |
function getName() {
|
97 |
return $this->name;
|
98 |
}
|
99 |
-
|
100 |
/**
|
101 |
* Retrieves internal name of the module
|
102 |
* @since 1.0
|
@@ -105,7 +105,7 @@ class ash_usps{
|
|
105 |
function getInternalName(){
|
106 |
return $this->internal_name;
|
107 |
}
|
108 |
-
|
109 |
/**
|
110 |
* Houses the list of services available to USPS API.
|
111 |
* The majority is commented out until a proper
|
@@ -133,9 +133,9 @@ class ash_usps{
|
|
133 |
// "Express Hold for Pickup Commercial"=>"EXPRESS HFP COMMERCIAL"
|
134 |
);
|
135 |
$this->services = $services;
|
136 |
-
|
137 |
}
|
138 |
-
|
139 |
/**
|
140 |
* Provides the appropriate endpoint for the API to use to
|
141 |
* retrieve rates from USPS
|
@@ -158,32 +158,28 @@ class ash_usps{
|
|
158 |
if ($intl){
|
159 |
$api = "IntlRateV2";
|
160 |
}
|
161 |
-
|
162 |
$env = "prod";
|
163 |
if((boolean)$this->use_test_env === TRUE){
|
164 |
$env = "test";
|
165 |
}
|
166 |
-
|
167 |
return "http://".$end_points[$env]["server"]."/".$end_points[$env]["dll"]."?".$api;
|
168 |
}
|
169 |
-
|
170 |
/**
|
171 |
* Returns the settings form that controls the USPS API information
|
172 |
* @since 1.0
|
173 |
*/
|
174 |
function getForm() {
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
if($settings["adv_rate"] == '1'){
|
184 |
-
$checked_adv = 'checked = "checked"';
|
185 |
-
}
|
186 |
-
|
187 |
$output=("
|
188 |
<tr>
|
189 |
<td>
|
@@ -194,7 +190,7 @@ class ash_usps{
|
|
194 |
|
195 |
<br />
|
196 |
".__("Don't have a USPS API account ? ",'wpsc')."
|
197 |
-
|
198 |
<a href=\"https://secure.shippingapis.com/registration/\" target=\"_blank\" >".__('Click Here','wpsc')."</a>
|
199 |
</td>
|
200 |
</tr>
|
@@ -210,8 +206,8 @@ class ash_usps{
|
|
210 |
".__('Use Test Server:','wpsc')."
|
211 |
</td>
|
212 |
<td>
|
213 |
-
<input type='checkbox' "
|
214 |
-
|
215 |
Yes
|
216 |
</td>
|
217 |
</tr>
|
@@ -220,8 +216,8 @@ class ash_usps{
|
|
220 |
".__('Advanced Rates:','wpsc')."
|
221 |
</td>
|
222 |
<td>
|
223 |
-
<input type='checkbox' "
|
224 |
-
|
225 |
Yes
|
226 |
<br />
|
227 |
<span style=\"font-size: x-small\">" . __( 'This setting will provide rates based on the dimensions from each item in your cart', 'wpsc' )."</span>
|
@@ -231,12 +227,8 @@ class ash_usps{
|
|
231 |
<td>".__('Select Services','wpsc')."</td>
|
232 |
<td>
|
233 |
<div id=\"resizeable\" class=\"ui-widget-content multiple-select\">");
|
234 |
-
$wpec_usps_services =
|
235 |
-
|
236 |
-
// If no selections have been made, default selection to ONLINE, that is what the old USPS essentially rated
|
237 |
-
array_push($wpec_usps_services, "ONLINE");
|
238 |
-
}
|
239 |
-
|
240 |
foreach($this->services as $label=>$service){
|
241 |
$checked = "";
|
242 |
if ((array_search($service, $wpec_usps_services) !== false)){
|
@@ -287,12 +279,12 @@ class ash_usps{
|
|
287 |
</td>
|
288 |
<td>
|
289 |
");
|
290 |
-
|
291 |
// If First Class, Online or All is selected then we need to know what Kind of First class
|
292 |
// will be used.
|
293 |
$fcl_types = array("Parcel"=>"PARCEL", "Letter"=>"LETTER", "Flat"=>"FLAT", "Postcard"=>"POSTCARD");
|
294 |
$type_selected = (array_key_exists("fcl_type",$settings)) ? $settings["fcl_type"] : $fcl_types["Parcel"];
|
295 |
-
|
296 |
$output .=("
|
297 |
<select id =\"\first_cls_type\" name=\"wpec_usps[fcl_type]\">
|
298 |
");
|
@@ -340,10 +332,10 @@ class ash_usps{
|
|
340 |
$size = "REGULAR";
|
341 |
switch($service){
|
342 |
case "PRIORITY":
|
343 |
-
$container = "
|
344 |
break;
|
345 |
case "EXPRESS":
|
346 |
-
$container = "
|
347 |
break;
|
348 |
case "PARCEL":
|
349 |
$container = "VARIABLE";
|
@@ -387,7 +379,7 @@ class ash_usps{
|
|
387 |
$ounce = ($data["weight"]-$pound) * 16;
|
388 |
$data["pound"] = $pound;
|
389 |
$data["ounce"] = $ounce;
|
390 |
-
|
391 |
if (!array_key_exists("services",(array)$data)){
|
392 |
$data["services"] = array("ONLINE");
|
393 |
}
|
@@ -401,7 +393,7 @@ class ash_usps{
|
|
401 |
$temp = array();
|
402 |
$temp["Service"] = $service;
|
403 |
$temp["@attr"] = array("ID"=>count($shipment));
|
404 |
-
|
405 |
if ($ounce > 13 || $pound > 1 ){
|
406 |
if(strpos($service,"FIRST") === FALSE || $service == "ONLINE"){
|
407 |
$temp["FirstClassMailType"] = $data["fcl_type"];
|
@@ -435,14 +427,14 @@ class ash_usps{
|
|
435 |
*/
|
436 |
function _build_intl_shipment(&$request,array $data, $package){
|
437 |
$shipment = array();
|
438 |
-
|
439 |
$data["pounds"] = floor($package->weight);
|
440 |
$data["ounces"] = ($data["weight"]-$data["pounds"]) * 16;
|
441 |
-
|
442 |
if (!array_key_exists("mail_type",(array)$data)){
|
443 |
$data["mail_type"] = array("Package");
|
444 |
}
|
445 |
-
|
446 |
$base = array( "Pounds"=>$data["pounds"],
|
447 |
"Ounces"=>$data["ounces"],
|
448 |
"Machinable"=>"True",
|
@@ -464,7 +456,7 @@ class ash_usps{
|
|
464 |
array_push($shipment, $base);
|
465 |
$request[$data["req"]]["Package"] = $shipment;
|
466 |
}
|
467 |
-
|
468 |
/**
|
469 |
* Used to build request to send to USPS API
|
470 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -516,7 +508,7 @@ class ash_usps{
|
|
516 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
517 |
$body = curl_exec($ch);
|
518 |
curl_close($ch);
|
519 |
-
|
520 |
return $body;
|
521 |
}
|
522 |
|
@@ -544,7 +536,7 @@ class ash_usps{
|
|
544 |
global $wpec_ash_xml;
|
545 |
$service = "";
|
546 |
$temp_service = $wpec_ash_xml->get($ServiceTag, $package);
|
547 |
-
|
548 |
if ($temp_service){
|
549 |
$service = $temp_service[0];
|
550 |
}
|
@@ -553,10 +545,10 @@ class ash_usps{
|
|
553 |
if (!empty($temp)){
|
554 |
$service = $temp[1];
|
555 |
}
|
556 |
-
|
557 |
return $service;
|
558 |
}
|
559 |
-
|
560 |
/**
|
561 |
* Merges N-Many arrays together by key, without replacement
|
562 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -583,7 +575,7 @@ class ash_usps{
|
|
583 |
}
|
584 |
return $final_array;
|
585 |
}
|
586 |
-
|
587 |
/**
|
588 |
* This function parses the provided XML response from USPS to retrieve the final rates.
|
589 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -595,12 +587,12 @@ class ash_usps{
|
|
595 |
global $wpec_ash_xml;
|
596 |
$package_services = array();
|
597 |
$this->_clean_response($response);
|
598 |
-
|
599 |
$packages = $wpec_ash_xml->get("Package", $response);
|
600 |
if (!is_array($packages)){
|
601 |
return array();
|
602 |
}
|
603 |
-
|
604 |
foreach($packages as $package){
|
605 |
$temp = array();
|
606 |
$postage_services = $wpec_ash_xml->get("Postage", $package);
|
@@ -632,7 +624,7 @@ class ash_usps{
|
|
632 |
global $wpec_ash_xml;
|
633 |
$services_table = array();
|
634 |
$this->_clean_response($response);
|
635 |
-
|
636 |
$services = $wpec_ash_xml->get("Service", $response);
|
637 |
if (empty($services)){
|
638 |
return array();
|
@@ -647,7 +639,7 @@ class ash_usps{
|
|
647 |
}
|
648 |
return $service_table;
|
649 |
}
|
650 |
-
|
651 |
/**
|
652 |
* Returns an array using the common keys from all arrasy and the sum of those common keys values;
|
653 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -678,7 +670,7 @@ class ash_usps{
|
|
678 |
}
|
679 |
return $final_table;
|
680 |
}
|
681 |
-
|
682 |
/**
|
683 |
* Merges arrays and adds the values of common keys.
|
684 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -697,7 +689,7 @@ class ash_usps{
|
|
697 |
}else{
|
698 |
$intersect_keys = array_keys($arrays[0]);
|
699 |
}
|
700 |
-
|
701 |
foreach($arrays as $arr){
|
702 |
foreach($arr as $key=>$value){
|
703 |
if (in_array($key,(array)$intersect_keys)){
|
@@ -710,7 +702,7 @@ class ash_usps{
|
|
710 |
}
|
711 |
return $temp;
|
712 |
}
|
713 |
-
|
714 |
/**
|
715 |
* Runs the quote process for a simple quote and returns the final quote table
|
716 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -737,7 +729,7 @@ class ash_usps{
|
|
737 |
$rate_table = $this->_merge_arrays($package_rate_table);
|
738 |
return $rate_table;
|
739 |
}
|
740 |
-
|
741 |
/**
|
742 |
* Runs the quote process for an advanced quote and returns the final quote table
|
743 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -765,14 +757,14 @@ class ash_usps{
|
|
765 |
$package_rate_table = $this->_parse_domestic_response($response);
|
766 |
//*** Reformat the array structure ***\\
|
767 |
$temp = $this->_merge_arrays($package_rate_table);
|
768 |
-
|
769 |
array_push($rate_tables, $temp);
|
770 |
}
|
771 |
|
772 |
$rates = $this->merge_sum_arrays($rate_tables);
|
773 |
return $rates;
|
774 |
}
|
775 |
-
|
776 |
/**
|
777 |
* Runs the quote process for an international quote and returns the final quote table
|
778 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -802,7 +794,7 @@ class ash_usps{
|
|
802 |
$rates = $this->_combine_rates($rate_tables);
|
803 |
return $rates;
|
804 |
}
|
805 |
-
|
806 |
/**
|
807 |
* Returns an updated country based on several rules that USPS has
|
808 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -827,7 +819,7 @@ class ash_usps{
|
|
827 |
}
|
828 |
return $full_name;
|
829 |
}
|
830 |
-
|
831 |
/**
|
832 |
* Takes a rate table and returns a new table with only services selected in the back end
|
833 |
* @author Greg Gullett (greg@ecsquest.com)
|
@@ -851,7 +843,7 @@ class ash_usps{
|
|
851 |
$valid_services = array_intersect_key((array)$rate_table, $services);
|
852 |
return $valid_services;
|
853 |
}
|
854 |
-
|
855 |
/**
|
856 |
* This function handles the process of getting a quote.
|
857 |
* It is kept abstracted from the entry points so you can
|
@@ -876,11 +868,11 @@ class ash_usps{
|
|
876 |
if (empty($data["weight"])){
|
877 |
return array();
|
878 |
}
|
879 |
-
|
880 |
if (empty($data["dest_zipcode"])){
|
881 |
return array();
|
882 |
}
|
883 |
-
|
884 |
if ($wpec_ash_tools->is_military_zip($data["dest_zipcode"])){
|
885 |
$data["dest_country"] = "USA";
|
886 |
}
|
@@ -897,7 +889,7 @@ class ash_usps{
|
|
897 |
$rate_table = $this->_validate_services($quotes, $data);
|
898 |
return $quotes;
|
899 |
}
|
900 |
-
|
901 |
/**
|
902 |
* This function is used to provide rates for single items
|
903 |
* Due to the nature of external calculators it is too costly to use this
|
@@ -925,7 +917,7 @@ class ash_usps{
|
|
925 |
$this->shipment->set_destination($this->internal_name);
|
926 |
// Check to see if the cached shipment is still accurate, if not we need new rate
|
927 |
$cache = $wpec_ash->check_cache($this->internal_name, $this->shipment);
|
928 |
-
|
929 |
if ($cache){
|
930 |
return $cache["rate_table"];
|
931 |
}
|
55 |
* @var ASHShipment|Null
|
56 |
*/
|
57 |
var $shipment=NULL;
|
58 |
+
|
59 |
/**
|
60 |
* Constructor for USPS class
|
61 |
* Automatically loads services that are available into the class instance
|
65 |
$this->_load_services();
|
66 |
return TRUE;
|
67 |
}
|
68 |
+
|
69 |
/**
|
70 |
* retrieves the USPS ID, not used
|
71 |
* This function only exists due to legacy code
|
76 |
function getID(){
|
77 |
return $this->$usps_id;
|
78 |
}
|
79 |
+
|
80 |
/**
|
81 |
* Sets the USPS ID, not used
|
82 |
* This function only exists due to legacy code, unused
|
87 |
function setId($id){
|
88 |
$this->$usps_id = $id;
|
89 |
}
|
90 |
+
|
91 |
/**
|
92 |
* Retrieves the external display name for the module
|
93 |
* @since 1.0
|
96 |
function getName() {
|
97 |
return $this->name;
|
98 |
}
|
99 |
+
|
100 |
/**
|
101 |
* Retrieves internal name of the module
|
102 |
* @since 1.0
|
105 |
function getInternalName(){
|
106 |
return $this->internal_name;
|
107 |
}
|
108 |
+
|
109 |
/**
|
110 |
* Houses the list of services available to USPS API.
|
111 |
* The majority is commented out until a proper
|
133 |
// "Express Hold for Pickup Commercial"=>"EXPRESS HFP COMMERCIAL"
|
134 |
);
|
135 |
$this->services = $services;
|
136 |
+
|
137 |
}
|
138 |
+
|
139 |
/**
|
140 |
* Provides the appropriate endpoint for the API to use to
|
141 |
* retrieve rates from USPS
|
158 |
if ($intl){
|
159 |
$api = "IntlRateV2";
|
160 |
}
|
161 |
+
|
162 |
$env = "prod";
|
163 |
if((boolean)$this->use_test_env === TRUE){
|
164 |
$env = "test";
|
165 |
}
|
166 |
+
|
167 |
return "http://".$end_points[$env]["server"]."/".$end_points[$env]["dll"]."?".$api;
|
168 |
}
|
169 |
+
|
170 |
/**
|
171 |
* Returns the settings form that controls the USPS API information
|
172 |
* @since 1.0
|
173 |
*/
|
174 |
function getForm() {
|
175 |
+
$defaults = array(
|
176 |
+
'test_server' => 0,
|
177 |
+
'adv_rate' => 0,
|
178 |
+
'id' => '',
|
179 |
+
'services' => array( 'ONLINE' ),
|
180 |
+
);
|
181 |
+
$settings = get_option( "wpec_usps", array() );
|
182 |
+
$settings = array_merge_recursive( $defaults, $settings );
|
|
|
|
|
|
|
|
|
183 |
$output=("
|
184 |
<tr>
|
185 |
<td>
|
190 |
|
191 |
<br />
|
192 |
".__("Don't have a USPS API account ? ",'wpsc')."
|
193 |
+
|
194 |
<a href=\"https://secure.shippingapis.com/registration/\" target=\"_blank\" >".__('Click Here','wpsc')."</a>
|
195 |
</td>
|
196 |
</tr>
|
206 |
".__('Use Test Server:','wpsc')."
|
207 |
</td>
|
208 |
<td>
|
209 |
+
<input type='checkbox' ". checked( $settings['test_server'], 1, false ) ." name='wpec_usps[test_server]' value='1' />
|
210 |
+
|
211 |
Yes
|
212 |
</td>
|
213 |
</tr>
|
216 |
".__('Advanced Rates:','wpsc')."
|
217 |
</td>
|
218 |
<td>
|
219 |
+
<input type='checkbox' ". checked( $settings['adv_rate'], 1, false ) . " name='wpec_usps[adv_rate]' value='1' />
|
220 |
+
|
221 |
Yes
|
222 |
<br />
|
223 |
<span style=\"font-size: x-small\">" . __( 'This setting will provide rates based on the dimensions from each item in your cart', 'wpsc' )."</span>
|
227 |
<td>".__('Select Services','wpsc')."</td>
|
228 |
<td>
|
229 |
<div id=\"resizeable\" class=\"ui-widget-content multiple-select\">");
|
230 |
+
$wpec_usps_services = $settings["services"];
|
231 |
+
|
|
|
|
|
|
|
|
|
232 |
foreach($this->services as $label=>$service){
|
233 |
$checked = "";
|
234 |
if ((array_search($service, $wpec_usps_services) !== false)){
|
279 |
</td>
|
280 |
<td>
|
281 |
");
|
282 |
+
|
283 |
// If First Class, Online or All is selected then we need to know what Kind of First class
|
284 |
// will be used.
|
285 |
$fcl_types = array("Parcel"=>"PARCEL", "Letter"=>"LETTER", "Flat"=>"FLAT", "Postcard"=>"POSTCARD");
|
286 |
$type_selected = (array_key_exists("fcl_type",$settings)) ? $settings["fcl_type"] : $fcl_types["Parcel"];
|
287 |
+
|
288 |
$output .=("
|
289 |
<select id =\"\first_cls_type\" name=\"wpec_usps[fcl_type]\">
|
290 |
");
|
332 |
$size = "REGULAR";
|
333 |
switch($service){
|
334 |
case "PRIORITY":
|
335 |
+
$container = "VARIABLE";
|
336 |
break;
|
337 |
case "EXPRESS":
|
338 |
+
$container = "VARIABLE";
|
339 |
break;
|
340 |
case "PARCEL":
|
341 |
$container = "VARIABLE";
|
379 |
$ounce = ($data["weight"]-$pound) * 16;
|
380 |
$data["pound"] = $pound;
|
381 |
$data["ounce"] = $ounce;
|
382 |
+
|
383 |
if (!array_key_exists("services",(array)$data)){
|
384 |
$data["services"] = array("ONLINE");
|
385 |
}
|
393 |
$temp = array();
|
394 |
$temp["Service"] = $service;
|
395 |
$temp["@attr"] = array("ID"=>count($shipment));
|
396 |
+
|
397 |
if ($ounce > 13 || $pound > 1 ){
|
398 |
if(strpos($service,"FIRST") === FALSE || $service == "ONLINE"){
|
399 |
$temp["FirstClassMailType"] = $data["fcl_type"];
|
427 |
*/
|
428 |
function _build_intl_shipment(&$request,array $data, $package){
|
429 |
$shipment = array();
|
430 |
+
|
431 |
$data["pounds"] = floor($package->weight);
|
432 |
$data["ounces"] = ($data["weight"]-$data["pounds"]) * 16;
|
433 |
+
|
434 |
if (!array_key_exists("mail_type",(array)$data)){
|
435 |
$data["mail_type"] = array("Package");
|
436 |
}
|
437 |
+
|
438 |
$base = array( "Pounds"=>$data["pounds"],
|
439 |
"Ounces"=>$data["ounces"],
|
440 |
"Machinable"=>"True",
|
456 |
array_push($shipment, $base);
|
457 |
$request[$data["req"]]["Package"] = $shipment;
|
458 |
}
|
459 |
+
|
460 |
/**
|
461 |
* Used to build request to send to USPS API
|
462 |
* @author Greg Gullett (greg@ecsquest.com)
|
508 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
509 |
$body = curl_exec($ch);
|
510 |
curl_close($ch);
|
511 |
+
|
512 |
return $body;
|
513 |
}
|
514 |
|
536 |
global $wpec_ash_xml;
|
537 |
$service = "";
|
538 |
$temp_service = $wpec_ash_xml->get($ServiceTag, $package);
|
539 |
+
|
540 |
if ($temp_service){
|
541 |
$service = $temp_service[0];
|
542 |
}
|
545 |
if (!empty($temp)){
|
546 |
$service = $temp[1];
|
547 |
}
|
548 |
+
|
549 |
return $service;
|
550 |
}
|
551 |
+
|
552 |
/**
|
553 |
* Merges N-Many arrays together by key, without replacement
|
554 |
* @author Greg Gullett (greg@ecsquest.com)
|
575 |
}
|
576 |
return $final_array;
|
577 |
}
|
578 |
+
|
579 |
/**
|
580 |
* This function parses the provided XML response from USPS to retrieve the final rates.
|
581 |
* @author Greg Gullett (greg@ecsquest.com)
|
587 |
global $wpec_ash_xml;
|
588 |
$package_services = array();
|
589 |
$this->_clean_response($response);
|
590 |
+
|
591 |
$packages = $wpec_ash_xml->get("Package", $response);
|
592 |
if (!is_array($packages)){
|
593 |
return array();
|
594 |
}
|
595 |
+
|
596 |
foreach($packages as $package){
|
597 |
$temp = array();
|
598 |
$postage_services = $wpec_ash_xml->get("Postage", $package);
|
624 |
global $wpec_ash_xml;
|
625 |
$services_table = array();
|
626 |
$this->_clean_response($response);
|
627 |
+
|
628 |
$services = $wpec_ash_xml->get("Service", $response);
|
629 |
if (empty($services)){
|
630 |
return array();
|
639 |
}
|
640 |
return $service_table;
|
641 |
}
|
642 |
+
|
643 |
/**
|
644 |
* Returns an array using the common keys from all arrasy and the sum of those common keys values;
|
645 |
* @author Greg Gullett (greg@ecsquest.com)
|
670 |
}
|
671 |
return $final_table;
|
672 |
}
|
673 |
+
|
674 |
/**
|
675 |
* Merges arrays and adds the values of common keys.
|
676 |
* @author Greg Gullett (greg@ecsquest.com)
|
689 |
}else{
|
690 |
$intersect_keys = array_keys($arrays[0]);
|
691 |
}
|
692 |
+
|
693 |
foreach($arrays as $arr){
|
694 |
foreach($arr as $key=>$value){
|
695 |
if (in_array($key,(array)$intersect_keys)){
|
702 |
}
|
703 |
return $temp;
|
704 |
}
|
705 |
+
|
706 |
/**
|
707 |
* Runs the quote process for a simple quote and returns the final quote table
|
708 |
* @author Greg Gullett (greg@ecsquest.com)
|
729 |
$rate_table = $this->_merge_arrays($package_rate_table);
|
730 |
return $rate_table;
|
731 |
}
|
732 |
+
|
733 |
/**
|
734 |
* Runs the quote process for an advanced quote and returns the final quote table
|
735 |
* @author Greg Gullett (greg@ecsquest.com)
|
757 |
$package_rate_table = $this->_parse_domestic_response($response);
|
758 |
//*** Reformat the array structure ***\\
|
759 |
$temp = $this->_merge_arrays($package_rate_table);
|
760 |
+
|
761 |
array_push($rate_tables, $temp);
|
762 |
}
|
763 |
|
764 |
$rates = $this->merge_sum_arrays($rate_tables);
|
765 |
return $rates;
|
766 |
}
|
767 |
+
|
768 |
/**
|
769 |
* Runs the quote process for an international quote and returns the final quote table
|
770 |
* @author Greg Gullett (greg@ecsquest.com)
|
794 |
$rates = $this->_combine_rates($rate_tables);
|
795 |
return $rates;
|
796 |
}
|
797 |
+
|
798 |
/**
|
799 |
* Returns an updated country based on several rules that USPS has
|
800 |
* @author Greg Gullett (greg@ecsquest.com)
|
819 |
}
|
820 |
return $full_name;
|
821 |
}
|
822 |
+
|
823 |
/**
|
824 |
* Takes a rate table and returns a new table with only services selected in the back end
|
825 |
* @author Greg Gullett (greg@ecsquest.com)
|
843 |
$valid_services = array_intersect_key((array)$rate_table, $services);
|
844 |
return $valid_services;
|
845 |
}
|
846 |
+
|
847 |
/**
|
848 |
* This function handles the process of getting a quote.
|
849 |
* It is kept abstracted from the entry points so you can
|
868 |
if (empty($data["weight"])){
|
869 |
return array();
|
870 |
}
|
871 |
+
|
872 |
if (empty($data["dest_zipcode"])){
|
873 |
return array();
|
874 |
}
|
875 |
+
|
876 |
if ($wpec_ash_tools->is_military_zip($data["dest_zipcode"])){
|
877 |
$data["dest_country"] = "USA";
|
878 |
}
|
889 |
$rate_table = $this->_validate_services($quotes, $data);
|
890 |
return $quotes;
|
891 |
}
|
892 |
+
|
893 |
/**
|
894 |
* This function is used to provide rates for single items
|
895 |
* Due to the nature of external calculators it is too costly to use this
|
917 |
$this->shipment->set_destination($this->internal_name);
|
918 |
// Check to see if the cached shipment is still accurate, if not we need new rate
|
919 |
$cache = $wpec_ash->check_cache($this->internal_name, $this->shipment);
|
920 |
+
|
921 |
if ($cache){
|
922 |
return $cache["rate_table"];
|
923 |
}
|
wpsc-shipping/weightrate.php
CHANGED
@@ -39,32 +39,69 @@ class weightrate {
|
|
39 |
return $this->internal_name;
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
*
|
44 |
*
|
45 |
* @return unknown
|
46 |
*/
|
47 |
function getForm() {
|
48 |
-
$
|
49 |
-
$
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
/**
|
@@ -73,38 +110,27 @@ class weightrate {
|
|
73 |
* @return unknown
|
74 |
*/
|
75 |
function submit_form() {
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
if (!isset($_POST['weight_shipping'])) {
|
81 |
-
$_POST['weight_shipping'] = '';
|
82 |
-
}
|
83 |
-
$new_layer = '';
|
84 |
-
$layers = (array)$_POST['weight_layer'];
|
85 |
-
$shippings = (array)$_POST['weight_shipping'];
|
86 |
|
87 |
if ( !empty($shippings) ) {
|
88 |
|
89 |
foreach ($shippings as $key => $price) {
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
unset($shippings[$key]);
|
94 |
-
unset($layers[$key]);
|
95 |
-
|
96 |
-
} else {
|
97 |
-
|
98 |
-
$new_layer[$layers[$key]] = $price;
|
99 |
-
|
100 |
-
}
|
101 |
|
102 |
}
|
103 |
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
|
108 |
return true;
|
109 |
}
|
110 |
|
39 |
return $this->internal_name;
|
40 |
}
|
41 |
|
42 |
+
private function output_row( $key = '', $shipping = '' ) {
|
43 |
+
$currency = wpsc_get_currency_symbol();
|
44 |
+
$class = ( $this->alt ) ? ' class="alternate"' : '';
|
45 |
+
$this->alt = ! $this->alt;
|
46 |
+
?>
|
47 |
+
<tr>
|
48 |
+
<td<?php echo $class; ?>>
|
49 |
+
<div class="cell-wrapper">
|
50 |
+
<input type="text" name="wpsc_shipping_weightrate_layer[]" value="<?php echo esc_attr( $key ); ?>" size="4" />
|
51 |
+
<small><?php _e( ' lbs and above', 'wpsc' ); ?></small>
|
52 |
+
</div>
|
53 |
+
</td>
|
54 |
+
<td<?php echo $class; ?>>
|
55 |
+
<div class="cell-wrapper">
|
56 |
+
<small><?php echo esc_html( $currency ); ?></small>
|
57 |
+
<input type="text" name="wpsc_shipping_weightrate_shipping[]" value="<?php echo esc_attr( $shipping ); ?>" size="4" />
|
58 |
+
<div class="actions">
|
59 |
+
<a tabindex="-1" title="<?php _e( 'Add Layer', 'wpsc' ); ?>" class="action add" href="#">Add</a>
|
60 |
+
<a tabindex="-1" title="<?php _e( 'Delete Layer', 'wpsc' ); ?>" class="action delete" href="#">Delete</a>
|
61 |
+
</div>
|
62 |
+
</div>
|
63 |
+
</td>
|
64 |
+
</tr>
|
65 |
+
<?php
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
/**
|
70 |
*
|
71 |
*
|
72 |
* @return unknown
|
73 |
*/
|
74 |
function getForm() {
|
75 |
+
$this->alt = false;
|
76 |
+
$layers = get_option( 'weight_rate_layers', array() );
|
77 |
+
ob_start();
|
78 |
+
?>
|
79 |
+
<thead>
|
80 |
+
<tr>
|
81 |
+
<th class="total-weight" title="<?php _e( 'You must enter the weight here in pounds, regardless of what you used on your products', 'wpsc' ); ?>">
|
82 |
+
<?php _e( 'Total Weight', 'wpsc' ); ?><br /><small><?php _e( 'in pounds' ); ?></small>
|
83 |
+
</th>
|
84 |
+
<th class="shipping"><?php _e( 'Shipping Price', 'wpsc' ); ?></th>
|
85 |
+
</tr>
|
86 |
+
</thead>
|
87 |
+
<tbody class="table-rate">
|
88 |
+
<tr class="js-warning">
|
89 |
+
<td colspan="2">
|
90 |
+
<small><?php echo sprintf( __( 'To remove a rate layer, simply leave the values on that row blank. By the way, <a href="%s">enable JavaScript</a> for a better user experience.'), 'http://www.google.com/support/bin/answer.py?answer=23852' ); ?></small>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<?php if ( ! empty( $layers ) ): ?>
|
94 |
+
<?php
|
95 |
+
foreach( $layers as $key => $shipping ){
|
96 |
+
$this->output_row( $key, $shipping );
|
97 |
+
}
|
98 |
+
?>
|
99 |
+
<?php else: ?>
|
100 |
+
<?php $this->output_row(); ?>
|
101 |
+
<?php endif ?>
|
102 |
+
</tbody>
|
103 |
+
<?php
|
104 |
+
return ob_get_clean();
|
105 |
}
|
106 |
|
107 |
/**
|
110 |
* @return unknown
|
111 |
*/
|
112 |
function submit_form() {
|
113 |
+
if ( empty( $_POST['wpsc_shipping_weightrate_shipping'] ) || empty( $_POST['wpsc_shipping_weightrate_layer'] ) )
|
114 |
+
return false;
|
115 |
|
116 |
+
$new_layers = array();
|
117 |
+
$layers = (array)$_POST['wpsc_shipping_weightrate_layer'];
|
118 |
+
$shippings = (array)$_POST['wpsc_shipping_weightrate_shipping'];
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
if ( !empty($shippings) ) {
|
121 |
|
122 |
foreach ($shippings as $key => $price) {
|
123 |
+
if ( empty( $price ) || empty( $layers[$key] ) )
|
124 |
+
continue;
|
125 |
|
126 |
+
$new_layers[$layers[$key]] = $price;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
}
|
129 |
|
130 |
}
|
131 |
|
132 |
+
krsort( $new_layers );
|
133 |
+
update_option( 'weight_rate_layers', $new_layers );
|
134 |
return true;
|
135 |
}
|
136 |
|
wpsc-taxes/controllers/taxes_controller.class.php
CHANGED
@@ -53,13 +53,13 @@ class wpec_taxes_controller {
|
|
53 |
if ( $this->wpec_taxes_run_logic() ) {
|
54 |
//get selected country code
|
55 |
$wpec_selected_country = $this->wpec_taxes_retrieve_selected_country();
|
56 |
-
|
57 |
//set tax region
|
58 |
$region = $this->wpec_taxes_retrieve_region();
|
59 |
-
|
60 |
//get the rate for the country and region if set
|
61 |
$tax_rate = $this->wpec_taxes->wpec_taxes_get_rate( $wpec_selected_country, $region );
|
62 |
-
|
63 |
//start the total_tax off at 0
|
64 |
$total_tax = 0;
|
65 |
|
@@ -79,7 +79,7 @@ class wpec_taxes_controller {
|
|
79 |
$total_tax += $taxes['tax'];
|
80 |
}// if
|
81 |
}// foreach
|
82 |
-
|
83 |
$free_shipping = false;
|
84 |
if ( isset( $_SESSION['coupon_numbers'] ) ) {
|
85 |
$coupon = new wpsc_coupons( $_SESSION['coupon_numbers'] );
|
@@ -88,12 +88,12 @@ class wpec_taxes_controller {
|
|
88 |
|
89 |
// minus coupon tax if we are using coupons, but make sure the coupon is not a free shipping coupon
|
90 |
if ($wpsc_cart->coupons_amount > 0 && ! $free_shipping){
|
91 |
-
|
92 |
if ( $this->wpec_taxes_isincluded() )
|
93 |
$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate'], false);
|
94 |
else
|
95 |
$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate']);
|
96 |
-
|
97 |
$total_tax -= $coupon_tax;
|
98 |
}
|
99 |
|
@@ -105,7 +105,7 @@ class wpec_taxes_controller {
|
|
105 |
else
|
106 |
$total_tax += $this->wpec_taxes_calculate_tax( $wpsc_cart->calculate_total_shipping(), $tax_rate['rate'] );
|
107 |
}// if
|
108 |
-
|
109 |
$returnable = array( 'total' => $total_tax );
|
110 |
|
111 |
if ( !$this->wpec_taxes_isincluded() ) {
|
@@ -116,7 +116,7 @@ class wpec_taxes_controller {
|
|
116 |
|
117 |
return $returnable;
|
118 |
} // wpec_taxes_calculate_total
|
119 |
-
|
120 |
/**
|
121 |
* @description: wpec_taxes_calculate_tax - a simple function to calculate tax based on a given
|
122 |
* price and tax percentage.
|
@@ -134,20 +134,20 @@ class wpec_taxes_controller {
|
|
134 |
else{
|
135 |
$returnable = ($price / (100 + $tax_percentage) ) * $tax_percentage;
|
136 |
}
|
137 |
-
|
138 |
}// if
|
139 |
|
140 |
return $returnable;
|
141 |
} // wpec_taxes_calculate_tax
|
142 |
-
|
143 |
function wpec_taxes_calculate_excluded_tax( $cart_item, $tax_rate )
|
144 |
{
|
145 |
$returnable = false;
|
146 |
-
|
147 |
//do not calculate tax for this item if it is not taxable
|
148 |
if(!isset($cart_item->meta[0]['wpec_taxes_taxable']))
|
149 |
{
|
150 |
-
if ( $this->wpec_taxes_run_logic() ) {
|
151 |
//get the taxable amount
|
152 |
if(isset($cart_item->meta[0]['wpec_taxes_taxable_amount']) && !empty($cart_item->meta[0]['wpec_taxes_taxable_amount']))
|
153 |
{
|
@@ -161,12 +161,12 @@ class wpec_taxes_controller {
|
|
161 |
}// if
|
162 |
//get the taxable price - unit price multiplied by qty
|
163 |
$taxable_price = $taxable_amount * $cart_item->quantity;
|
164 |
-
|
165 |
//calculate tax
|
166 |
$returnable = array( 'tax' => $this->wpec_taxes_calculate_tax( $taxable_price, $tax_rate['rate'] ), 'rate' => $tax_rate['rate'] );
|
167 |
}// if
|
168 |
}// if
|
169 |
-
|
170 |
return $returnable;
|
171 |
}// wpec_taxes_calculate_excluded_tax
|
172 |
|
@@ -189,7 +189,7 @@ class wpec_taxes_controller {
|
|
189 |
$region = $this->wpec_taxes_retrieve_region();
|
190 |
|
191 |
$taxes_band = isset( $cart_item->meta[0]['wpec_taxes_band'] ) ? $cart_item->meta[0]['wpec_taxes_band'] : null;
|
192 |
-
|
193 |
//get the tax percentage rate
|
194 |
$tax_rate = $this->wpec_taxes->wpec_taxes_get_included_rate( $taxes_band, $wpec_base_country, $region );
|
195 |
|
@@ -247,7 +247,7 @@ class wpec_taxes_controller {
|
|
247 |
default:
|
248 |
$returnable = true;
|
249 |
}// switch
|
250 |
-
|
251 |
return $returnable;
|
252 |
|
253 |
} // wpec_taxes_run_logic
|
@@ -345,9 +345,7 @@ class wpec_taxes_controller {
|
|
345 |
$returnable = '<p>' . __( 'No Tax Bands Setup. Set Tax Bands up in <a href="options-general.php?page=wpsc-settings&tab=taxes">Settings > Taxes</a>', 'wpsc' ) . '</p>';
|
346 |
}// if
|
347 |
} elseif(!$this->wpec_taxes->wpec_taxes_get_enabled()) {
|
348 |
-
$returnable = '<p>';
|
349 |
$returnable .= __( 'Taxes are not enabled. See <a href="options-general.php?page=wpsc-settings&tab=taxes">Settings > Taxes</a>', 'wpsc' );
|
350 |
-
$returnable .= '</p>';
|
351 |
}// if
|
352 |
|
353 |
return $returnable;
|
@@ -526,8 +524,9 @@ class wpec_taxes_controller {
|
|
526 |
$country_select_settings = array(
|
527 |
'id' => "{$type}-country-{$key}",
|
528 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][country_code]",
|
529 |
-
'class' => 'country',
|
530 |
-
'
|
|
|
531 |
);
|
532 |
$rate_input_settings = array(
|
533 |
'id' => "{$type}-rate-{$key}",
|
@@ -575,12 +574,14 @@ class wpec_taxes_controller {
|
|
575 |
$country_code = $tax_rate['country_code'];
|
576 |
}// if
|
577 |
|
578 |
-
|
|
|
|
|
579 |
//set the region up
|
580 |
$region_select_settings = array(
|
581 |
'id' => "{$type}-region-{$key}",
|
582 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
|
583 |
-
'class' => 'region'
|
584 |
);
|
585 |
|
586 |
//country code should be set - but just in case it's not
|
@@ -594,7 +595,6 @@ class wpec_taxes_controller {
|
|
594 |
'name' => $this->wpec_taxes->wpec_taxes_get_region_information( $tax_rate['region_code'], 'name' )
|
595 |
);
|
596 |
|
597 |
-
$regions = $this->wpec_taxes->wpec_taxes_get_regions( $country_code );
|
598 |
$region_select = $this->wpec_taxes_build_select_options( $regions, 'region_code', 'name', $selected_region, $region_select_settings );
|
599 |
}// if
|
600 |
|
@@ -608,7 +608,7 @@ class wpec_taxes_controller {
|
|
608 |
'isocode' => $country_code,
|
609 |
'country' => $this->wpec_taxes->wpec_taxes_get_country_information( 'country', array( 'isocode' => $country_code ) )
|
610 |
);
|
611 |
-
|
612 |
if(isset($tax_rate['index']))
|
613 |
{
|
614 |
$bands_hidden_index['value'] = $tax_rate['index'];
|
@@ -636,9 +636,9 @@ class wpec_taxes_controller {
|
|
636 |
if ( $type == 'rates' ) {
|
637 |
$returnable[] = $this->wpec_taxes_build_input( $shipping_input_settings );
|
638 |
}// if
|
639 |
-
$returnable[] = "<a class='taxes-{$type}-delete' id='delete-{$key}' href='#'>" . __( 'Delete', 'wpsc' ) . "</a>";
|
640 |
-
|
641 |
-
$returnable = "<p id='{$type}-row-{$key}' class='
|
642 |
|
643 |
return $returnable;
|
644 |
} // wpec_taxes_build_form
|
53 |
if ( $this->wpec_taxes_run_logic() ) {
|
54 |
//get selected country code
|
55 |
$wpec_selected_country = $this->wpec_taxes_retrieve_selected_country();
|
56 |
+
|
57 |
//set tax region
|
58 |
$region = $this->wpec_taxes_retrieve_region();
|
59 |
+
|
60 |
//get the rate for the country and region if set
|
61 |
$tax_rate = $this->wpec_taxes->wpec_taxes_get_rate( $wpec_selected_country, $region );
|
62 |
+
|
63 |
//start the total_tax off at 0
|
64 |
$total_tax = 0;
|
65 |
|
79 |
$total_tax += $taxes['tax'];
|
80 |
}// if
|
81 |
}// foreach
|
82 |
+
|
83 |
$free_shipping = false;
|
84 |
if ( isset( $_SESSION['coupon_numbers'] ) ) {
|
85 |
$coupon = new wpsc_coupons( $_SESSION['coupon_numbers'] );
|
88 |
|
89 |
// minus coupon tax if we are using coupons, but make sure the coupon is not a free shipping coupon
|
90 |
if ($wpsc_cart->coupons_amount > 0 && ! $free_shipping){
|
91 |
+
|
92 |
if ( $this->wpec_taxes_isincluded() )
|
93 |
$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate'], false);
|
94 |
else
|
95 |
$coupon_tax = $this->wpec_taxes_calculate_tax($wpsc_cart->coupons_amount, $tax_rate['rate']);
|
96 |
+
|
97 |
$total_tax -= $coupon_tax;
|
98 |
}
|
99 |
|
105 |
else
|
106 |
$total_tax += $this->wpec_taxes_calculate_tax( $wpsc_cart->calculate_total_shipping(), $tax_rate['rate'] );
|
107 |
}// if
|
108 |
+
|
109 |
$returnable = array( 'total' => $total_tax );
|
110 |
|
111 |
if ( !$this->wpec_taxes_isincluded() ) {
|
116 |
|
117 |
return $returnable;
|
118 |
} // wpec_taxes_calculate_total
|
119 |
+
|
120 |
/**
|
121 |
* @description: wpec_taxes_calculate_tax - a simple function to calculate tax based on a given
|
122 |
* price and tax percentage.
|
134 |
else{
|
135 |
$returnable = ($price / (100 + $tax_percentage) ) * $tax_percentage;
|
136 |
}
|
137 |
+
|
138 |
}// if
|
139 |
|
140 |
return $returnable;
|
141 |
} // wpec_taxes_calculate_tax
|
142 |
+
|
143 |
function wpec_taxes_calculate_excluded_tax( $cart_item, $tax_rate )
|
144 |
{
|
145 |
$returnable = false;
|
146 |
+
|
147 |
//do not calculate tax for this item if it is not taxable
|
148 |
if(!isset($cart_item->meta[0]['wpec_taxes_taxable']))
|
149 |
{
|
150 |
+
if ( $this->wpec_taxes_run_logic() ) {
|
151 |
//get the taxable amount
|
152 |
if(isset($cart_item->meta[0]['wpec_taxes_taxable_amount']) && !empty($cart_item->meta[0]['wpec_taxes_taxable_amount']))
|
153 |
{
|
161 |
}// if
|
162 |
//get the taxable price - unit price multiplied by qty
|
163 |
$taxable_price = $taxable_amount * $cart_item->quantity;
|
164 |
+
|
165 |
//calculate tax
|
166 |
$returnable = array( 'tax' => $this->wpec_taxes_calculate_tax( $taxable_price, $tax_rate['rate'] ), 'rate' => $tax_rate['rate'] );
|
167 |
}// if
|
168 |
}// if
|
169 |
+
|
170 |
return $returnable;
|
171 |
}// wpec_taxes_calculate_excluded_tax
|
172 |
|
189 |
$region = $this->wpec_taxes_retrieve_region();
|
190 |
|
191 |
$taxes_band = isset( $cart_item->meta[0]['wpec_taxes_band'] ) ? $cart_item->meta[0]['wpec_taxes_band'] : null;
|
192 |
+
|
193 |
//get the tax percentage rate
|
194 |
$tax_rate = $this->wpec_taxes->wpec_taxes_get_included_rate( $taxes_band, $wpec_base_country, $region );
|
195 |
|
247 |
default:
|
248 |
$returnable = true;
|
249 |
}// switch
|
250 |
+
|
251 |
return $returnable;
|
252 |
|
253 |
} // wpec_taxes_run_logic
|
345 |
$returnable = '<p>' . __( 'No Tax Bands Setup. Set Tax Bands up in <a href="options-general.php?page=wpsc-settings&tab=taxes">Settings > Taxes</a>', 'wpsc' ) . '</p>';
|
346 |
}// if
|
347 |
} elseif(!$this->wpec_taxes->wpec_taxes_get_enabled()) {
|
|
|
348 |
$returnable .= __( 'Taxes are not enabled. See <a href="options-general.php?page=wpsc-settings&tab=taxes">Settings > Taxes</a>', 'wpsc' );
|
|
|
349 |
}// if
|
350 |
|
351 |
return $returnable;
|
524 |
$country_select_settings = array(
|
525 |
'id' => "{$type}-country-{$key}",
|
526 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][country_code]",
|
527 |
+
'class' => 'wpsc-taxes-country-drop-down',
|
528 |
+
'data-key' => $key,
|
529 |
+
'data-type' => $type,
|
530 |
);
|
531 |
$rate_input_settings = array(
|
532 |
'id' => "{$type}-rate-{$key}",
|
574 |
$country_code = $tax_rate['country_code'];
|
575 |
}// if
|
576 |
|
577 |
+
$regions = $this->wpec_taxes->wpec_taxes_get_regions( $country_code );
|
578 |
+
|
579 |
+
if ( isset( $tax_rate['region_code'] ) && ! empty( $regions ) ) {
|
580 |
//set the region up
|
581 |
$region_select_settings = array(
|
582 |
'id' => "{$type}-region-{$key}",
|
583 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
|
584 |
+
'class' => 'wpsc-taxes-region-drop-down'
|
585 |
);
|
586 |
|
587 |
//country code should be set - but just in case it's not
|
595 |
'name' => $this->wpec_taxes->wpec_taxes_get_region_information( $tax_rate['region_code'], 'name' )
|
596 |
);
|
597 |
|
|
|
598 |
$region_select = $this->wpec_taxes_build_select_options( $regions, 'region_code', 'name', $selected_region, $region_select_settings );
|
599 |
}// if
|
600 |
|
608 |
'isocode' => $country_code,
|
609 |
'country' => $this->wpec_taxes->wpec_taxes_get_country_information( 'country', array( 'isocode' => $country_code ) )
|
610 |
);
|
611 |
+
|
612 |
if(isset($tax_rate['index']))
|
613 |
{
|
614 |
$bands_hidden_index['value'] = $tax_rate['index'];
|
636 |
if ( $type == 'rates' ) {
|
637 |
$returnable[] = $this->wpec_taxes_build_input( $shipping_input_settings );
|
638 |
}// if
|
639 |
+
$returnable[] = "<a class='wpsc-taxes-{$type}-delete' id='wpsc-taxes-{$type}-delete-{$key}' href='#'>" . __( 'Delete', 'wpsc' ) . "</a>";
|
640 |
+
$returnable[] = '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="ajax-feedback" title="" alt="" />';
|
641 |
+
$returnable = "<p id='wpsc-taxes-{$type}-row-{$key}' class='wpsc-tax-{$type}-row'>" . implode( "\n", $returnable ) . '</p>';
|
642 |
|
643 |
return $returnable;
|
644 |
} // wpec_taxes_build_form
|
wpsc-taxes/models/taxes.class.php
CHANGED
@@ -87,7 +87,7 @@ class wpec_taxes {
|
|
87 |
//initialize return variable
|
88 |
// use wpsc_tax_rate hook to provide your own tax solution
|
89 |
$returnable = apply_filters( 'wpsc_tax_rate', false, $this, $country_code, $region_code );
|
90 |
-
|
91 |
if ( $returnable !== false )
|
92 |
return $returnable;
|
93 |
|
@@ -152,7 +152,7 @@ class wpec_taxes {
|
|
152 |
|
153 |
return $returnable;
|
154 |
} // wpec_taxes_get_band_from_name
|
155 |
-
|
156 |
/**
|
157 |
* @author: Jeremy Smith
|
158 |
* @description: wpec_taxes_get_band_from_index - retrieves the tax band for the given name
|
@@ -191,7 +191,7 @@ class wpec_taxes {
|
|
191 |
//get the tax band and tax rate
|
192 |
$tax_band = $this->wpec_taxes_get_band_from_index( $taxes_band_index );
|
193 |
$rate_array = $this->wpec_taxes_get_rate( $country_code, $region_code );
|
194 |
-
|
195 |
//set the tax rate depending on product rate settings
|
196 |
if(isset($tax_band['rate']))
|
197 |
switch ( $this->wpec_taxes_get_product() ) {
|
@@ -252,9 +252,9 @@ class wpec_taxes {
|
|
252 |
* Default action is to not include an order by statement.
|
253 |
* @return: array, int, string or false
|
254 |
* */
|
255 |
-
function wpec_taxes_get_country_information( $columns=false, $where=false, $order_by=false ) {
|
256 |
//check for all-markets
|
257 |
-
if('country' == $columns && 1 == count($where) && 'all-markets' == $where['isocode'])
|
258 |
{
|
259 |
$returnable = 'All Markets';
|
260 |
}
|
@@ -267,30 +267,35 @@ class wpec_taxes {
|
|
267 |
$columns = ($columns) ? $columns : array( '*' );
|
268 |
|
269 |
//change columns to array if not an array
|
270 |
-
if ( !is_array( $columns ) )
|
271 |
$columns = array( $columns );
|
272 |
-
|
|
|
273 |
|
274 |
//if where is set then formulate conditions
|
275 |
if ( $where ) {
|
276 |
foreach ( $where as $column => $condition ) {
|
277 |
-
$
|
|
|
278 |
}// foreach
|
279 |
}// if
|
|
|
280 |
//formulate query
|
281 |
$query = 'SELECT ' . implode( ',', $columns ) . ' FROM ' . WPSC_TABLE_CURRENCY_LIST;
|
282 |
-
|
|
|
283 |
$query .= ' WHERE ' . implode( ' AND ', $where_query );
|
284 |
-
|
285 |
//if order_by is set, add to query
|
286 |
if ( $order_by ) {
|
287 |
-
if ( !is_array( $order_by ) )
|
288 |
$order_by = array( $order_by );
|
289 |
-
|
|
|
290 |
$query .= ' ORDER BY ' . implode( ',', $order_by );
|
291 |
}// if
|
292 |
|
293 |
-
$returnable = (count( $columns ) > 1) ? $wpdb->get_results( $query, ARRAY_A ) : $wpdb->get_var( $query );
|
294 |
}// if
|
295 |
|
296 |
//return the result
|
@@ -306,7 +311,7 @@ class wpec_taxes {
|
|
306 |
* Default action is to retrieve the id column.
|
307 |
* @return: int, string, or false
|
308 |
* */
|
309 |
-
function wpec_taxes_get_region_information( $region_code, $column='id' ) {
|
310 |
//check for all markets ifset return the string 'All Markets'
|
311 |
if('all-markets' == $region_code)
|
312 |
{
|
@@ -315,7 +320,7 @@ class wpec_taxes {
|
|
315 |
else
|
316 |
{
|
317 |
global $wpdb;
|
318 |
-
$query = "SELECT
|
319 |
$returnable = $wpdb->get_var( $query );
|
320 |
}// if
|
321 |
|
@@ -342,7 +347,8 @@ class wpec_taxes {
|
|
342 |
$result = $wpdb->get_results( $query, ARRAY_A );
|
343 |
|
344 |
//add the all markets option to the list
|
345 |
-
|
|
|
346 |
|
347 |
return $result;
|
348 |
} // wpec_taxes_get_regions
|
@@ -357,13 +363,13 @@ class wpec_taxes {
|
|
357 |
function wpec_taxes_get_region_code_by_id( $id ) {
|
358 |
//database connection
|
359 |
global $wpdb;
|
360 |
-
if(!empty($id)){
|
361 |
//get the region code
|
362 |
-
$query = 'SELECT code AS region_code FROM ' . WPSC_TABLE_REGION_TAX . " WHERE id
|
363 |
return $wpdb->get_var( $query );
|
364 |
}
|
365 |
return false;
|
366 |
} // wpec_taxes_get_region_code_by_id
|
367 |
} // wpec_taxes
|
368 |
|
369 |
-
?>
|
87 |
//initialize return variable
|
88 |
// use wpsc_tax_rate hook to provide your own tax solution
|
89 |
$returnable = apply_filters( 'wpsc_tax_rate', false, $this, $country_code, $region_code );
|
90 |
+
|
91 |
if ( $returnable !== false )
|
92 |
return $returnable;
|
93 |
|
152 |
|
153 |
return $returnable;
|
154 |
} // wpec_taxes_get_band_from_name
|
155 |
+
|
156 |
/**
|
157 |
* @author: Jeremy Smith
|
158 |
* @description: wpec_taxes_get_band_from_index - retrieves the tax band for the given name
|
191 |
//get the tax band and tax rate
|
192 |
$tax_band = $this->wpec_taxes_get_band_from_index( $taxes_band_index );
|
193 |
$rate_array = $this->wpec_taxes_get_rate( $country_code, $region_code );
|
194 |
+
|
195 |
//set the tax rate depending on product rate settings
|
196 |
if(isset($tax_band['rate']))
|
197 |
switch ( $this->wpec_taxes_get_product() ) {
|
252 |
* Default action is to not include an order by statement.
|
253 |
* @return: array, int, string or false
|
254 |
* */
|
255 |
+
function wpec_taxes_get_country_information( $columns = false, $where = false, $order_by = false ) {
|
256 |
//check for all-markets
|
257 |
+
if( 'country' == $columns && 1 == count( $where ) && 'all-markets' == $where['isocode'] )
|
258 |
{
|
259 |
$returnable = 'All Markets';
|
260 |
}
|
267 |
$columns = ($columns) ? $columns : array( '*' );
|
268 |
|
269 |
//change columns to array if not an array
|
270 |
+
if ( ! is_array( $columns ) )
|
271 |
$columns = array( $columns );
|
272 |
+
|
273 |
+
$columns = array_map( 'esc_sql', $columns );
|
274 |
|
275 |
//if where is set then formulate conditions
|
276 |
if ( $where ) {
|
277 |
foreach ( $where as $column => $condition ) {
|
278 |
+
$condition = esc_sql( $condition );
|
279 |
+
$where_query[] = ( is_numeric( $condition ) ) ? "{$column}={$condition}" : "{$column}='{$condition}'";
|
280 |
}// foreach
|
281 |
}// if
|
282 |
+
|
283 |
//formulate query
|
284 |
$query = 'SELECT ' . implode( ',', $columns ) . ' FROM ' . WPSC_TABLE_CURRENCY_LIST;
|
285 |
+
|
286 |
+
if ( isset( $where_query ) )
|
287 |
$query .= ' WHERE ' . implode( ' AND ', $where_query );
|
288 |
+
|
289 |
//if order_by is set, add to query
|
290 |
if ( $order_by ) {
|
291 |
+
if ( ! is_array( $order_by ) )
|
292 |
$order_by = array( $order_by );
|
293 |
+
|
294 |
+
$order_by = array_map( 'esc_sql', $order_by );
|
295 |
$query .= ' ORDER BY ' . implode( ',', $order_by );
|
296 |
}// if
|
297 |
|
298 |
+
$returnable = ( count( $columns ) > 1 ) ? $wpdb->get_results( $query, ARRAY_A ) : $wpdb->get_var( $query );
|
299 |
}// if
|
300 |
|
301 |
//return the result
|
311 |
* Default action is to retrieve the id column.
|
312 |
* @return: int, string, or false
|
313 |
* */
|
314 |
+
function wpec_taxes_get_region_information( $region_code, $column='id' ) {
|
315 |
//check for all markets ifset return the string 'All Markets'
|
316 |
if('all-markets' == $region_code)
|
317 |
{
|
320 |
else
|
321 |
{
|
322 |
global $wpdb;
|
323 |
+
$query = $wpdb->prepare( "SELECT " . esc_sql( $column ) . " FROM " . WPSC_TABLE_REGION_TAX . " WHERE code = %s", $region_code );
|
324 |
$returnable = $wpdb->get_var( $query );
|
325 |
}// if
|
326 |
|
347 |
$result = $wpdb->get_results( $query, ARRAY_A );
|
348 |
|
349 |
//add the all markets option to the list
|
350 |
+
if ( ! empty( $result ) )
|
351 |
+
array_unshift($result, array('region_code'=>'all-markets', 'name'=>'All Markets'));
|
352 |
|
353 |
return $result;
|
354 |
} // wpec_taxes_get_regions
|
363 |
function wpec_taxes_get_region_code_by_id( $id ) {
|
364 |
//database connection
|
365 |
global $wpdb;
|
366 |
+
if( ! empty( $id ) ){
|
367 |
//get the region code
|
368 |
+
$query = $wpdb->prepare( 'SELECT code AS region_code FROM ' . WPSC_TABLE_REGION_TAX . " WHERE id = %d", $id );
|
369 |
return $wpdb->get_var( $query );
|
370 |
}
|
371 |
return false;
|
372 |
} // wpec_taxes_get_region_code_by_id
|
373 |
} // wpec_taxes
|
374 |
|
375 |
+
?>
|
wpsc-taxes/taxes_module.php
CHANGED
@@ -6,13 +6,6 @@
|
|
6 |
require_once WPSC_FILE_PATH.'/wpsc-taxes/models/taxes.class.php';
|
7 |
require_once WPSC_FILE_PATH.'/wpsc-taxes/controllers/taxes_controller.class.php';
|
8 |
|
9 |
-
function wpsc_include_taxes_js() {
|
10 |
-
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
11 |
-
//include required js file
|
12 |
-
wp_enqueue_script( 'wp-e-commerce-taxes-functions', WPSC_URL . '/wpsc-taxes/view/js/taxes-functions.js', array( 'wp-e-commerce-admin' ), $version_identifier, false );
|
13 |
-
}
|
14 |
-
add_action( 'admin_enqueue_scripts', 'wpsc_include_taxes_js' );
|
15 |
-
|
16 |
/**
|
17 |
* @description: wpec_taxes_settings_page - used by wpec to display the admin settings page.
|
18 |
* @param: void
|
@@ -32,6 +25,9 @@ function wpec_taxes_settings_page() {
|
|
32 |
* @return: null
|
33 |
* */
|
34 |
function wpec_taxes_ajax_controller() {
|
|
|
|
|
|
|
35 |
//include taxes controller
|
36 |
$wpec_taxes_controller = new wpec_taxes_controller;
|
37 |
|
@@ -40,19 +36,20 @@ function wpec_taxes_ajax_controller() {
|
|
40 |
$regions = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_regions( $_REQUEST['country_code'] );
|
41 |
$key = $_REQUEST['current_key'];
|
42 |
$type = $_REQUEST['taxes_type'];
|
|
|
43 |
$default_option = array( 'region_code' => 'all-markets', 'name' => 'All Markets' );
|
44 |
$select_settings = array(
|
45 |
'id' => "{$type}-region-{$key}",
|
46 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
|
47 |
-
'class' => 'region'
|
48 |
);
|
49 |
$returnable = $wpec_taxes_controller->wpec_taxes_build_select_options( $regions, 'region_code', 'name', $default_option, $select_settings );
|
50 |
break;
|
51 |
-
case '
|
52 |
$key = $_REQUEST['current_key'];
|
53 |
$returnable = $wpec_taxes_controller->wpec_taxes_build_form( $key );
|
54 |
break;
|
55 |
-
case '
|
56 |
$key = $_REQUEST['current_key'];
|
57 |
//get a new key if a band is already defined for this key
|
58 |
while($wpec_taxes_controller->wpec_taxes->wpec_taxes_get_band_from_index($key))
|
@@ -71,92 +68,8 @@ function wpec_taxes_ajax_controller() {
|
|
71 |
|
72 |
// wpec_taxes_ajax_controller
|
73 |
|
74 |
-
/**
|
75 |
-
* @description: wpec_submit_taxes_options - filters the options submitted in $_POST. Uses
|
76 |
-
* wpsc_submit_options to submit filtered array.
|
77 |
-
* @param: void
|
78 |
-
* @return: null
|
79 |
-
* */
|
80 |
-
function wpec_submit_taxes_options() {
|
81 |
-
//define the name of the checkbox options
|
82 |
-
$taxes_check_options = array( 'wpec_taxes_enabled' );
|
83 |
-
|
84 |
-
//check if checkbox options are checked and modify post output
|
85 |
-
foreach ( $taxes_check_options as $option ) {
|
86 |
-
$_POST['wpsc_options'][$option] = (isset( $_POST['wpsc_options'][$option] )) ? 1 : 0;
|
87 |
-
}// foreach
|
88 |
-
//currently there are two types - bands and rates
|
89 |
-
$taxes_rates_types = array( 'rates', 'bands' );
|
90 |
-
|
91 |
-
foreach ( $taxes_rates_types as $taxes_type ) {
|
92 |
-
$saved_rates = array( ); //keep track of saved rates
|
93 |
-
$exists = array( ); //keep track of what rates or names have been saved
|
94 |
-
//check the rates
|
95 |
-
if ( isset( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] ) ) {
|
96 |
-
foreach ( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] as $tax_rate ) {
|
97 |
-
if( !isset( $tax_rate['region_code'] ) )
|
98 |
-
$tax_rate['region_code'] = '';
|
99 |
-
|
100 |
-
//if there is no country then skip
|
101 |
-
if ( empty( $tax_rate['country_code'] ) ) {
|
102 |
-
continue;
|
103 |
-
}
|
104 |
-
|
105 |
-
//bands - if the name already exists then skip - if not save it
|
106 |
-
if ( $taxes_type == 'bands' ) {
|
107 |
-
if ( empty( $tax_rate['name'] ) || in_array( $tax_rate['name'], $exists ) || $tax_rate['name'] == 'Disabled' ) {
|
108 |
-
continue;
|
109 |
-
} else {
|
110 |
-
$exists[] = $tax_rate['name'];
|
111 |
-
$saved_rates[] = $tax_rate;
|
112 |
-
}// if
|
113 |
-
}// if
|
114 |
-
//rates - check the shipping checkbox
|
115 |
-
if ( $taxes_type == 'rates' ) {
|
116 |
-
//if there is no rate then skip
|
117 |
-
if ( empty( $tax_rate['rate'] ) ) {
|
118 |
-
continue;
|
119 |
-
}
|
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 |
-
//if region already exists skip
|
126 |
-
if ( array_search( $tax_rate['region_code'], $exists[$tax_rate['country_code']] ) == $tax_rate['country_code'] ) {
|
127 |
-
continue;
|
128 |
-
} else {
|
129 |
-
//it's not in the array add it
|
130 |
-
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
131 |
-
|
132 |
-
//save it
|
133 |
-
$saved_rates[] = $tax_rate;
|
134 |
-
}// if
|
135 |
-
} else {
|
136 |
-
//add codes to exists array
|
137 |
-
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
138 |
-
|
139 |
-
//save it
|
140 |
-
$saved_rates[] = $tax_rate;
|
141 |
-
}// if
|
142 |
-
}// if
|
143 |
-
}// foreach
|
144 |
-
}// if
|
145 |
-
//replace post tax rates with filtered rates
|
146 |
-
$_POST['wpsc_options']['wpec_taxes_' . $taxes_type] = $saved_rates;
|
147 |
-
}// foreach
|
148 |
-
//submit options using built in functions
|
149 |
-
wpsc_submit_options();
|
150 |
-
}
|
151 |
-
|
152 |
-
// wpec_submit_taxes_options
|
153 |
-
|
154 |
/**
|
155 |
* Add actions used by wpec-taxes module
|
156 |
* */
|
157 |
add_action( 'wp_ajax_wpec_taxes_ajax', 'wpec_taxes_ajax_controller' );
|
158 |
-
|
159 |
-
if ( isset( $_REQUEST['wpec_admin_action'] ) && $_REQUEST['wpec_admin_action'] == 'submit_taxes_options' ) {
|
160 |
-
add_action( 'admin_init', 'wpec_submit_taxes_options' );
|
161 |
-
}
|
162 |
?>
|
6 |
require_once WPSC_FILE_PATH.'/wpsc-taxes/models/taxes.class.php';
|
7 |
require_once WPSC_FILE_PATH.'/wpsc-taxes/controllers/taxes_controller.class.php';
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
/**
|
10 |
* @description: wpec_taxes_settings_page - used by wpec to display the admin settings page.
|
11 |
* @param: void
|
25 |
* @return: null
|
26 |
* */
|
27 |
function wpec_taxes_ajax_controller() {
|
28 |
+
if ( ! wp_verify_nonce( $_POST['nonce'], 'wpsc_settings_page_nonce' ) )
|
29 |
+
die( 'Session expired. Try refreshing your settings page.' );
|
30 |
+
|
31 |
//include taxes controller
|
32 |
$wpec_taxes_controller = new wpec_taxes_controller;
|
33 |
|
36 |
$regions = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_regions( $_REQUEST['country_code'] );
|
37 |
$key = $_REQUEST['current_key'];
|
38 |
$type = $_REQUEST['taxes_type'];
|
39 |
+
|
40 |
$default_option = array( 'region_code' => 'all-markets', 'name' => 'All Markets' );
|
41 |
$select_settings = array(
|
42 |
'id' => "{$type}-region-{$key}",
|
43 |
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
|
44 |
+
'class' => 'wpsc-taxes-region-drop-down'
|
45 |
);
|
46 |
$returnable = $wpec_taxes_controller->wpec_taxes_build_select_options( $regions, 'region_code', 'name', $default_option, $select_settings );
|
47 |
break;
|
48 |
+
case 'wpec_taxes_build_rates_form':
|
49 |
$key = $_REQUEST['current_key'];
|
50 |
$returnable = $wpec_taxes_controller->wpec_taxes_build_form( $key );
|
51 |
break;
|
52 |
+
case 'wpec_taxes_build_bands_form':
|
53 |
$key = $_REQUEST['current_key'];
|
54 |
//get a new key if a band is already defined for this key
|
55 |
while($wpec_taxes_controller->wpec_taxes->wpec_taxes_get_band_from_index($key))
|
68 |
|
69 |
// wpec_taxes_ajax_controller
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
/**
|
72 |
* Add actions used by wpec-taxes module
|
73 |
* */
|
74 |
add_action( 'wp_ajax_wpec_taxes_ajax', 'wpec_taxes_ajax_controller' );
|
|
|
|
|
|
|
|
|
75 |
?>
|
wpsc-taxes/view/js/taxes-functions.js
DELETED
@@ -1,167 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* @author: Jeremy Smith - www.firefly-media-solutions.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 |
-
//add the loading indicator
|
29 |
-
jQuery('#'+type+'-country-'+key).after('<img id="'+type+'-'+key+'-loading" src="'+WPSC_CORE_IMAGES_URL+'/indicator.gif" />');
|
30 |
-
|
31 |
-
//run ajax and process response
|
32 |
-
jQuery.get(ajaxurl, data, function(response) {
|
33 |
-
//remove the loading indicator
|
34 |
-
jQuery('#'+type+'-'+key+'-loading').remove();
|
35 |
-
|
36 |
-
//add the new region information
|
37 |
-
jQuery('#'+type+'-country-'+key).after(response);
|
38 |
-
});
|
39 |
-
}// wpec_taxes_get_regions
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @description: wpec_taxes_count_rates - counts all elements with the wpec-tax-rates class.
|
43 |
-
*
|
44 |
-
* @param: void
|
45 |
-
* @return: integer
|
46 |
-
**/
|
47 |
-
function wpec_taxes_count_rates()
|
48 |
-
{
|
49 |
-
return jQuery('.wpec-tax-rates').size();
|
50 |
-
}// wpec_taxes_count_rates
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @description: wpec_taxes_build_rate_form - retrieves an entire tax rate row from the server.
|
54 |
-
*
|
55 |
-
* @param: void
|
56 |
-
* @return: boolean false
|
57 |
-
**/
|
58 |
-
function wpec_taxes_build_rate_form()
|
59 |
-
{
|
60 |
-
var key = wpec_taxes_count_rates();
|
61 |
-
|
62 |
-
var data = {
|
63 |
-
action: 'wpec_taxes_ajax',
|
64 |
-
wpec_taxes_action: 'wpec_taxes_build_rate_form',
|
65 |
-
current_key: key
|
66 |
-
};
|
67 |
-
|
68 |
-
//run ajax and process response
|
69 |
-
jQuery.get(ajaxurl, data, function(response) {
|
70 |
-
jQuery('#add_taxes_rate').before(response);
|
71 |
-
});
|
72 |
-
return false;
|
73 |
-
}// wpec_taxes_tax_rate_form
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @description: wpec_taxes_count_bands - counts all elements with the wpec-tax-bands class.
|
77 |
-
*
|
78 |
-
* @param: void
|
79 |
-
* @return: integer
|
80 |
-
**/
|
81 |
-
function wpec_taxes_count_bands()
|
82 |
-
{
|
83 |
-
return jQuery('.wpec-tax-bands').size();
|
84 |
-
}// wpec_taxes_count_rates
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @description: wpec_taxes_build_band_form - retrieves an entire tax band row from the server.
|
88 |
-
*
|
89 |
-
* @param: void
|
90 |
-
* @return: boolean false
|
91 |
-
**/
|
92 |
-
function wpec_taxes_build_band_form()
|
93 |
-
{
|
94 |
-
var key = wpec_taxes_count_bands();
|
95 |
-
|
96 |
-
var data = {
|
97 |
-
action: 'wpec_taxes_ajax',
|
98 |
-
wpec_taxes_action: 'wpec_taxes_build_band_form',
|
99 |
-
current_key: key
|
100 |
-
};
|
101 |
-
|
102 |
-
//run ajax and process response
|
103 |
-
jQuery.get(ajaxurl, data, function(response) {
|
104 |
-
jQuery('#add_taxes_band').before(response);
|
105 |
-
});
|
106 |
-
return false;
|
107 |
-
}// wpec_taxes_tax_band_form
|
108 |
-
|
109 |
-
/**
|
110 |
-
* @description: wpec_taxes_delete_tax_rate - given a key will remove the associated
|
111 |
-
* tax rate form row.
|
112 |
-
*
|
113 |
-
* @param: key - integer. Used in referring to the id for the row.
|
114 |
-
* @return: null
|
115 |
-
**/
|
116 |
-
function wpec_taxes_delete_tax_rate(key)
|
117 |
-
{
|
118 |
-
if(isNaN(key))
|
119 |
-
{
|
120 |
-
var key = key.split('-');
|
121 |
-
key = key[1];
|
122 |
-
}
|
123 |
-
|
124 |
-
jQuery('#rates-row-'+key).remove();
|
125 |
-
}// wpec_taxes_delete_tax_rate
|
126 |
-
|
127 |
-
/**
|
128 |
-
* @description: wpec_taxes_delete_tax_band - given a key will remove the associated
|
129 |
-
* tax band form row.
|
130 |
-
*
|
131 |
-
* @param: key - integer. Used in referring to the id for the row.
|
132 |
-
* @return: null
|
133 |
-
**/
|
134 |
-
function wpec_taxes_delete_tax_band(key)
|
135 |
-
{
|
136 |
-
if(isNaN(key))
|
137 |
-
{
|
138 |
-
var key = key.split('-');
|
139 |
-
key = key[1];
|
140 |
-
}
|
141 |
-
|
142 |
-
jQuery('#bands-row-'+key).remove();
|
143 |
-
}// wpec_taxes_delete_tax_band
|
144 |
-
|
145 |
-
//bind the click function to the add_tax_rate link and initialize with 0
|
146 |
-
jQuery('#add_taxes_rate').live('click', function(){
|
147 |
-
wpec_taxes_build_rate_form();
|
148 |
-
return false;
|
149 |
-
});
|
150 |
-
|
151 |
-
//bind the click function to each new tax_rate delete link
|
152 |
-
jQuery('.taxes-rates-delete').live('click', function(){
|
153 |
-
wpec_taxes_delete_tax_rate(jQuery(this).attr('id'));
|
154 |
-
return false;
|
155 |
-
});
|
156 |
-
|
157 |
-
//bind the click function to the add_tax_band link and initialize with 0
|
158 |
-
jQuery('#add_taxes_band').live('click', function(){
|
159 |
-
wpec_taxes_build_band_form();
|
160 |
-
return false;
|
161 |
-
});
|
162 |
-
|
163 |
-
//bind the click function to each new tax_band delete link
|
164 |
-
jQuery('.taxes-bands-delete').live('click', function(){
|
165 |
-
wpec_taxes_delete_tax_band(jQuery(this).attr('id'));
|
166 |
-
return false;
|
167 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wpsc-theme/functions/wpsc-transaction_results_functions.php
CHANGED
@@ -70,12 +70,26 @@ function wpsc_transaction_theme() {
|
|
70 |
$wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array('processed' => $processed_id),array('sessionid'=>$sessionid), array('%f') );
|
71 |
}
|
72 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
}
|
75 |
|
76 |
if(!$dont_show_transaction_results ) {
|
77 |
if ( !empty($sessionid) ){
|
78 |
-
$cart_log_id = $wpdb->get_var( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`=
|
79 |
return transaction_results( $sessionid, true );
|
80 |
}else
|
81 |
printf( __( 'Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
|
@@ -101,14 +115,9 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
101 |
$wpec_taxes_controller = new wpec_taxes_controller();
|
102 |
$is_transaction = false;
|
103 |
$errorcode = 0;
|
104 |
-
$purchase_log = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`=
|
105 |
$order_status = $purchase_log['processed'];
|
106 |
$curgateway = $purchase_log['gateway'];
|
107 |
-
//new variable to check whether function is being called from resen_email
|
108 |
-
if(isset($_GET['email_buyer_id']))
|
109 |
-
$resend_email = true;
|
110 |
-
else
|
111 |
-
$resend_email = false;
|
112 |
|
113 |
if( !is_bool( $display_to_screen ) )
|
114 |
$display_to_screen = true;
|
@@ -134,7 +143,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
134 |
$billing_country = $purchase_log['billing_country'];
|
135 |
$shipping_country = $purchase_log['shipping_country'];
|
136 |
} elseif ( !empty($country) ) {
|
137 |
-
$country = $wpdb->get_var( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id
|
138 |
|
139 |
$billing_country = $country;
|
140 |
$shipping_country = $country;
|
@@ -144,7 +153,7 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
144 |
$previous_download_ids = array( );
|
145 |
$product_list = $product_list_html = $report_product_list = '';
|
146 |
|
147 |
-
$cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` =
|
148 |
if ( ($cart != null) && ($errorcode == 0) ) {
|
149 |
$total_shipping = '';
|
150 |
foreach ( $cart as $row ) {
|
@@ -154,11 +163,11 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
154 |
|
155 |
if ( $is_transaction ) {
|
156 |
|
157 |
-
$download_data = $wpdb->get_results( "SELECT *
|
158 |
FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "`
|
159 |
WHERE `active`='1'
|
160 |
-
AND `purchid
|
161 |
-
AND `cartid` =
|
162 |
|
163 |
if ( count( $download_data ) > 0 ) {
|
164 |
foreach ( $download_data as $single_download ) {
|
@@ -257,15 +266,14 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
257 |
wpsc_decrement_claimed_stock( $purchase_log['id'] );
|
258 |
|
259 |
if ( !empty($purchase_log['discount_data'])) {
|
260 |
-
$coupon_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code=
|
261 |
if ( $coupon_data['use-once'] == 1 ) {
|
262 |
$wpdb->update(WPSC_TABLE_COUPON_CODES, array('active' => '0', 'is-used' => '1'), array('id' => $coupon_data['id']) );
|
263 |
}
|
264 |
}
|
265 |
|
266 |
-
$total_shipping
|
267 |
-
|
268 |
-
$total = $purchase_log['totalprice'];
|
269 |
|
270 |
$total_price_email = '';
|
271 |
$total_price_html = '';
|
@@ -337,20 +345,23 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
337 |
add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
|
338 |
$message = apply_filters('wpsc_email_message', $message, $report_id, $product_list, $total_tax, $total_shipping_email, $total_price_email);
|
339 |
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
342 |
$payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
|
343 |
if(!empty($payment_instructions))
|
344 |
-
$payment_instructions .= "\n\r";
|
345 |
$message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
|
346 |
$message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
|
347 |
|
348 |
// prevent email duplicates
|
349 |
-
|
350 |
wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
|
351 |
set_transient( "{$sessionid}_pending_email_sent", true, 60 * 60 * 12 );
|
352 |
}
|
353 |
-
} elseif ( ! get_transient( "{$sessionid}_receipt_email_sent" ) ) {
|
354 |
wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
|
355 |
set_transient( "{$sessionid}_receipt_email_sent", true, 60 * 60 * 12 );
|
356 |
}
|
@@ -360,12 +371,12 @@ function transaction_results( $sessionid, $display_to_screen = true, $transactio
|
|
360 |
remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
|
361 |
|
362 |
$report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
|
363 |
-
$form_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` =
|
364 |
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
|
365 |
|
366 |
if ( $form_data != null ) {
|
367 |
foreach ( $form_data as $form_field ) {
|
368 |
-
$form_data = $wpdb->get_row( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` =
|
369 |
|
370 |
switch ( $form_data['type'] ) {
|
371 |
case "country":
|
70 |
$wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array('processed' => $processed_id),array('sessionid'=>$sessionid), array('%f') );
|
71 |
}
|
72 |
break;
|
73 |
+
case 'wpsc_merchant_paymentexpress' :
|
74 |
+
// Payment Express sends back there own session id, which is temporarily stored in the Auth field
|
75 |
+
// so just swapping that over here
|
76 |
+
$query = "SELECT `sessionid` FROM `" .WPSC_TABLE_PURCHASE_LOGS. "` WHERE `authcode` ='" . $sessionid . "'";
|
77 |
+
$result = $wpdb->get_var($query);
|
78 |
+
if($result != null){
|
79 |
+
// just in case they are using an older version old gold cart (pre 2.9.5)
|
80 |
+
$sessionid = $result;
|
81 |
+
$dont_show_transaction_results = true;
|
82 |
+
}
|
83 |
+
break;
|
84 |
+
case 'eway_hosted':
|
85 |
+
$sessionid = decrypt_eway_uk_response();
|
86 |
+
break;
|
87 |
}
|
88 |
}
|
89 |
|
90 |
if(!$dont_show_transaction_results ) {
|
91 |
if ( !empty($sessionid) ){
|
92 |
+
$cart_log_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ) );
|
93 |
return transaction_results( $sessionid, true );
|
94 |
}else
|
95 |
printf( __( 'Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc' ), get_option( "shopping_cart_url" ) );
|
115 |
$wpec_taxes_controller = new wpec_taxes_controller();
|
116 |
$is_transaction = false;
|
117 |
$errorcode = 0;
|
118 |
+
$purchase_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid ), ARRAY_A );
|
119 |
$order_status = $purchase_log['processed'];
|
120 |
$curgateway = $purchase_log['gateway'];
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
if( !is_bool( $display_to_screen ) )
|
123 |
$display_to_screen = true;
|
143 |
$billing_country = $purchase_log['billing_country'];
|
144 |
$shipping_country = $purchase_log['shipping_country'];
|
145 |
} elseif ( !empty($country) ) {
|
146 |
+
$country = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase_log['id'], get_option( 'country_form_field' ) ) );
|
147 |
|
148 |
$billing_country = $country;
|
149 |
$shipping_country = $country;
|
153 |
$previous_download_ids = array( );
|
154 |
$product_list = $product_list_html = $report_product_list = '';
|
155 |
|
156 |
+
$cart = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = %d", $purchase_log['id'] ), ARRAY_A );
|
157 |
if ( ($cart != null) && ($errorcode == 0) ) {
|
158 |
$total_shipping = '';
|
159 |
foreach ( $cart as $row ) {
|
163 |
|
164 |
if ( $is_transaction ) {
|
165 |
|
166 |
+
$download_data = $wpdb->get_results( $wpdb->prepare( "SELECT *
|
167 |
FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "`
|
168 |
WHERE `active`='1'
|
169 |
+
AND `purchid` = %d
|
170 |
+
AND `cartid` = %d", $purchase_log['id'], $row['id'] ), ARRAY_A );
|
171 |
|
172 |
if ( count( $download_data ) > 0 ) {
|
173 |
foreach ( $download_data as $single_download ) {
|
266 |
wpsc_decrement_claimed_stock( $purchase_log['id'] );
|
267 |
|
268 |
if ( !empty($purchase_log['discount_data'])) {
|
269 |
+
$coupon_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code = %s LIMIT 1", $purchase_log['discount_data'] ), ARRAY_A );
|
270 |
if ( $coupon_data['use-once'] == 1 ) {
|
271 |
$wpdb->update(WPSC_TABLE_COUPON_CODES, array('active' => '0', 'is-used' => '1'), array('id' => $coupon_data['id']) );
|
272 |
}
|
273 |
}
|
274 |
|
275 |
+
$total_shipping = $wpsc_cart->calculate_total_shipping();
|
276 |
+
$total = $wpsc_cart->calculate_total_price();
|
|
|
277 |
|
278 |
$total_price_email = '';
|
279 |
$total_price_html = '';
|
345 |
add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
|
346 |
$message = apply_filters('wpsc_email_message', $message, $report_id, $product_list, $total_tax, $total_shipping_email, $total_price_email);
|
347 |
|
348 |
+
//new variable to check whether function is being called from wpsc_purchlog_resend_email()
|
349 |
+
$resend_email = isset( $_REQUEST['email_buyer_id'] ) ? true : false;
|
350 |
+
|
351 |
+
if ( ! $is_transaction ) {
|
352 |
+
|
353 |
$payment_instructions = strip_tags( stripslashes( get_option( 'payment_instructions' ) ) );
|
354 |
if(!empty($payment_instructions))
|
355 |
+
$payment_instructions .= "\n\r";
|
356 |
$message = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message;
|
357 |
$message_html = __( 'Thank you, your purchase is pending, you will be sent an email once the order clears.', 'wpsc' ) . "\n\r" . $payment_instructions . $message_html;
|
358 |
|
359 |
// prevent email duplicates
|
360 |
+
if ( ! get_transient( "{$sessionid}_pending_email_sent" ) || $resend_email ) {
|
361 |
wp_mail( $email, __( 'Order Pending: Payment Required', 'wpsc' ), $message );
|
362 |
set_transient( "{$sessionid}_pending_email_sent", true, 60 * 60 * 12 );
|
363 |
}
|
364 |
+
} elseif ( ! get_transient( "{$sessionid}_receipt_email_sent" ) || $resend_email ) {
|
365 |
wp_mail( $email, __( 'Purchase Receipt', 'wpsc' ), $message );
|
366 |
set_transient( "{$sessionid}_receipt_email_sent", true, 60 * 60 * 12 );
|
367 |
}
|
371 |
remove_filter( 'wp_mail_from', 'wpsc_replace_reply_address' );
|
372 |
|
373 |
$report_user = __( 'Customer Details', 'wpsc' ) . "\n\r";
|
374 |
+
$form_sql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d", $purchase_log['id'] );
|
375 |
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
|
376 |
|
377 |
if ( $form_data != null ) {
|
378 |
foreach ( $form_data as $form_field ) {
|
379 |
+
$form_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `id` = %d LIMIT 1", $form_field['form_id'] ), ARRAY_A );
|
380 |
|
381 |
switch ( $form_data['type'] ) {
|
382 |
case "country":
|
wpsc-theme/functions/wpsc-user_log_functions.php
CHANGED
@@ -256,7 +256,7 @@ function wpsc_display_form_fields() {
|
|
256 |
|
257 |
?>
|
258 |
<select name='collected_data["<?php echo esc_attr( $form_field['id'] ); ?>"]'>
|
259 |
-
<option value="-1"><?php
|
260 |
<?php foreach ( $options as $label => $value ): ?>
|
261 |
<option <?php selected( $value, $selected ); ?> value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></option>
|
262 |
<?php endforeach ?>
|
@@ -333,7 +333,7 @@ function wpsc_has_downloads() {
|
|
333 |
} else {
|
334 |
$links[] = site_url() . "/?downloadid=" . $product['uniqueid'];
|
335 |
}
|
336 |
-
$sql = "SELECT * FROM $wpdb->posts WHERE id = "
|
337 |
$file = $wpdb->get_results( $sql, ARRAY_A );
|
338 |
$files[] = $file[0];
|
339 |
}
|
@@ -423,7 +423,7 @@ function wpsc_user_details() {
|
|
423 |
$billing_country = $purchase['billing_country'];
|
424 |
$shipping_country = $purchase['shipping_country'];
|
425 |
} elseif ( !empty($country)) {
|
426 |
-
$country_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` =
|
427 |
$country_data = $wpdb->get_results( $country_sql, ARRAY_A );
|
428 |
$billing_country = $country_data[0]['value'];
|
429 |
$shipping_country = $country_data[0]['value'];
|
@@ -498,7 +498,7 @@ function wpsc_user_details() {
|
|
498 |
//end of written by allen
|
499 |
//cart contents display starts here;
|
500 |
echo " <strong class='form_group'>" . __( 'Order Details', 'wpsc' ) . ":</strong>\n\r";
|
501 |
-
$cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`="
|
502 |
$cart_log = $wpdb->get_results( $cartsql, ARRAY_A );
|
503 |
$j = 0;
|
504 |
// /*
|
@@ -623,7 +623,7 @@ function wpsc_user_details() {
|
|
623 |
echo "<table class='customer_details'>";
|
624 |
|
625 |
|
626 |
-
$usersql = "SELECT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id=
|
627 |
$formfields = $wpdb->get_results($usersql, ARRAY_A);
|
628 |
if ( !empty($formfields) ) {
|
629 |
|
256 |
|
257 |
?>
|
258 |
<select name='collected_data["<?php echo esc_attr( $form_field['id'] ); ?>"]'>
|
259 |
+
<option value="-1"><?php _ex( 'Select an Option', 'Dropdown default on user log page', 'wpsc' ); ?></option>
|
260 |
<?php foreach ( $options as $label => $value ): ?>
|
261 |
<option <?php selected( $value, $selected ); ?> value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></option>
|
262 |
<?php endforeach ?>
|
333 |
} else {
|
334 |
$links[] = site_url() . "/?downloadid=" . $product['uniqueid'];
|
335 |
}
|
336 |
+
$sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE id = %d", $product['fileid'] );
|
337 |
$file = $wpdb->get_results( $sql, ARRAY_A );
|
338 |
$files[] = $file[0];
|
339 |
}
|
423 |
$billing_country = $purchase['billing_country'];
|
424 |
$shipping_country = $purchase['shipping_country'];
|
425 |
} elseif ( !empty($country)) {
|
426 |
+
$country_sql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase['id'] ,get_option( 'country_form_field' ) );
|
427 |
$country_data = $wpdb->get_results( $country_sql, ARRAY_A );
|
428 |
$billing_country = $country_data[0]['value'];
|
429 |
$shipping_country = $country_data[0]['value'];
|
498 |
//end of written by allen
|
499 |
//cart contents display starts here;
|
500 |
echo " <strong class='form_group'>" . __( 'Order Details', 'wpsc' ) . ":</strong>\n\r";
|
501 |
+
$cartsql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`= %d", $purchase['id'] );
|
502 |
$cart_log = $wpdb->get_results( $cartsql, ARRAY_A );
|
503 |
$j = 0;
|
504 |
// /*
|
623 |
echo "<table class='customer_details'>";
|
624 |
|
625 |
|
626 |
+
$usersql = $wpdb->prepare( "SELECT `".WPSC_TABLE_SUBMITED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITED_FORM_DATA."`.log_id = %d OR `".WPSC_TABLE_CHECKOUT_FORMS."`.type = 'heading' ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`", $purchase['id'] );
|
627 |
$formfields = $wpdb->get_results($usersql, ARRAY_A);
|
628 |
if ( !empty($formfields) ) {
|
629 |
|
wpsc-theme/wpsc-cart_widget.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php if(isset($cart_messages) && count($cart_messages) > 0) { ?>
|
2 |
<?php foreach((array)$cart_messages as $cart_message) { ?>
|
3 |
-
<span class="cart_message"><?php echo $cart_message; ?></span>
|
4 |
<?php } ?>
|
5 |
<?php } ?>
|
6 |
|
@@ -18,7 +18,7 @@
|
|
18 |
<tbody>
|
19 |
<?php while(wpsc_have_cart_items()): wpsc_the_cart_item(); ?>
|
20 |
<tr>
|
21 |
-
<td colspan='2' class='product-name'
|
22 |
<td><?php echo wpsc_cart_item_quantity(); ?></td>
|
23 |
<td><?php echo wpsc_cart_item_price(); ?></td>
|
24 |
<td class="cart-widget-remove"><form action="" method="post" class="adjustform">
|
@@ -63,4 +63,4 @@
|
|
63 |
wpsc_google_checkout();
|
64 |
|
65 |
|
66 |
-
?>
|
1 |
<?php if(isset($cart_messages) && count($cart_messages) > 0) { ?>
|
2 |
<?php foreach((array)$cart_messages as $cart_message) { ?>
|
3 |
+
<span class="cart_message"><?php echo esc_html( $cart_message ); ?></span>
|
4 |
<?php } ?>
|
5 |
<?php } ?>
|
6 |
|
18 |
<tbody>
|
19 |
<?php while(wpsc_have_cart_items()): wpsc_the_cart_item(); ?>
|
20 |
<tr>
|
21 |
+
<td colspan='2' class='product-name'><?php do_action ( "wpsc_before_cart_widget_item_name" ); ?><a href="<?php echo wpsc_cart_item_url(); ?>"><?php echo wpsc_cart_item_name(); ?></a><?php do_action ( "wpsc_after_cart_widget_item_name" ); ?></td>
|
22 |
<td><?php echo wpsc_cart_item_quantity(); ?></td>
|
23 |
<td><?php echo wpsc_cart_item_price(); ?></td>
|
24 |
<td class="cart-widget-remove"><form action="" method="post" class="adjustform">
|
63 |
wpsc_google_checkout();
|
64 |
|
65 |
|
66 |
+
?>
|
wpsc-theme/wpsc-shopping_cart_page.php
CHANGED
@@ -31,25 +31,32 @@ endif;
|
|
31 |
?>
|
32 |
<?php //this displays the confirm your order html ?>
|
33 |
|
|
|
34 |
<tr class="product_row product_row_<?php echo wpsc_the_cart_item_key(); ?> <?php echo $alt_class;?>">
|
35 |
|
36 |
<td class="firstcol wpsc_product_image wpsc_product_image_<?php echo wpsc_the_cart_item_key(); ?>">
|
37 |
<?php if('' != wpsc_cart_item_image()): ?>
|
|
|
38 |
<img src="<?php echo wpsc_cart_item_image(); ?>" alt="<?php echo wpsc_cart_item_name(); ?>" title="<?php echo wpsc_cart_item_name(); ?>" class="product_image" />
|
|
|
39 |
<?php else:
|
40 |
/* I dont think this gets used anymore,, but left in for backwards compatibility */
|
41 |
?>
|
42 |
<div class="item_no_image">
|
|
|
43 |
<a href="<?php echo wpsc_the_product_permalink(); ?>">
|
44 |
<span><?php _e('No Image','wpsc'); ?></span>
|
45 |
|
46 |
</a>
|
|
|
47 |
</div>
|
48 |
<?php endif; ?>
|
49 |
</td>
|
50 |
|
51 |
<td class="wpsc_product_name wpsc_product_name_<?php echo wpsc_the_cart_item_key(); ?>">
|
|
|
52 |
<a href="<?php echo wpsc_cart_item_url();?>"><?php echo wpsc_cart_item_name(); ?></a>
|
|
|
53 |
</td>
|
54 |
|
55 |
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
|
@@ -74,6 +81,7 @@ endif;
|
|
74 |
</form>
|
75 |
</td>
|
76 |
</tr>
|
|
|
77 |
<?php endwhile; ?>
|
78 |
<?php //this HTML displays coupons if there are any active coupons to use ?>
|
79 |
|
31 |
?>
|
32 |
<?php //this displays the confirm your order html ?>
|
33 |
|
34 |
+
<?php do_action ( "wpsc_before_checkout_cart_row" ); ?>
|
35 |
<tr class="product_row product_row_<?php echo wpsc_the_cart_item_key(); ?> <?php echo $alt_class;?>">
|
36 |
|
37 |
<td class="firstcol wpsc_product_image wpsc_product_image_<?php echo wpsc_the_cart_item_key(); ?>">
|
38 |
<?php if('' != wpsc_cart_item_image()): ?>
|
39 |
+
<?php do_action ( "wpsc_before_checkout_cart_item_image" ); ?>
|
40 |
<img src="<?php echo wpsc_cart_item_image(); ?>" alt="<?php echo wpsc_cart_item_name(); ?>" title="<?php echo wpsc_cart_item_name(); ?>" class="product_image" />
|
41 |
+
<?php do_action ( "wpsc_after_checkout_cart_item_image" ); ?>
|
42 |
<?php else:
|
43 |
/* I dont think this gets used anymore,, but left in for backwards compatibility */
|
44 |
?>
|
45 |
<div class="item_no_image">
|
46 |
+
<?php do_action ( "wpsc_before_checkout_cart_item_image" ); ?>
|
47 |
<a href="<?php echo wpsc_the_product_permalink(); ?>">
|
48 |
<span><?php _e('No Image','wpsc'); ?></span>
|
49 |
|
50 |
</a>
|
51 |
+
<?php do_action ( "wpsc_after_checkout_cart_item_image" ); ?>
|
52 |
</div>
|
53 |
<?php endif; ?>
|
54 |
</td>
|
55 |
|
56 |
<td class="wpsc_product_name wpsc_product_name_<?php echo wpsc_the_cart_item_key(); ?>">
|
57 |
+
<?php do_action ( "wpsc_before_checkout_cart_item_name" ); ?>
|
58 |
<a href="<?php echo wpsc_cart_item_url();?>"><?php echo wpsc_cart_item_name(); ?></a>
|
59 |
+
<?php do_action ( "wpsc_after_checkout_cart_item_name" ); ?>
|
60 |
</td>
|
61 |
|
62 |
<td class="wpsc_product_quantity wpsc_product_quantity_<?php echo wpsc_the_cart_item_key(); ?>">
|
81 |
</form>
|
82 |
</td>
|
83 |
</tr>
|
84 |
+
<?php do_action ( "wpsc_after_checkout_cart_row" ); ?>
|
85 |
<?php endwhile; ?>
|
86 |
<?php //this HTML displays coupons if there are any active coupons to use ?>
|
87 |
|
wpsc-theme/wpsc-single_product.php
CHANGED
@@ -63,6 +63,7 @@
|
|
63 |
<?php if (wpsc_have_custom_meta()) : ?>
|
64 |
<div class="custom_meta">
|
65 |
<?php while ( wpsc_have_custom_meta() ) : wpsc_the_custom_meta(); ?>
|
|
|
66 |
<strong><?php echo wpsc_custom_meta_name(); ?>: </strong><?php echo wpsc_custom_meta_value(); ?><br />
|
67 |
<?php endwhile; ?>
|
68 |
</div><!--close custom_meta-->
|
63 |
<?php if (wpsc_have_custom_meta()) : ?>
|
64 |
<div class="custom_meta">
|
65 |
<?php while ( wpsc_have_custom_meta() ) : wpsc_the_custom_meta(); ?>
|
66 |
+
<?php if (stripos(wpsc_custom_meta_name(),'g:') !== FALSE) continue; ?>
|
67 |
<strong><?php echo wpsc_custom_meta_name(); ?>: </strong><?php echo wpsc_custom_meta_value(); ?><br />
|
68 |
<?php endwhile; ?>
|
69 |
</div><!--close custom_meta-->
|
wpsc-widgets/admin_menu_widget.php
CHANGED
@@ -32,8 +32,6 @@ class WP_Widget_Admin_Menu extends WP_Widget {
|
|
32 |
*/
|
33 |
function widget( $args, $instance ) {
|
34 |
|
35 |
-
global $wpdb, $table_prefix;
|
36 |
-
|
37 |
extract( $args );
|
38 |
|
39 |
if ( current_user_can( 'manage_options' ) ) {
|
@@ -72,8 +70,6 @@ class WP_Widget_Admin_Menu extends WP_Widget {
|
|
72 |
*/
|
73 |
function form( $instance ) {
|
74 |
|
75 |
-
global $wpdb;
|
76 |
-
|
77 |
// Defaults
|
78 |
$instance = wp_parse_args( (array)$instance, array( 'title' => '' ) );
|
79 |
|
32 |
*/
|
33 |
function widget( $args, $instance ) {
|
34 |
|
|
|
|
|
35 |
extract( $args );
|
36 |
|
37 |
if ( current_user_can( 'manage_options' ) ) {
|
70 |
*/
|
71 |
function form( $instance ) {
|
72 |
|
|
|
|
|
73 |
// Defaults
|
74 |
$instance = wp_parse_args( (array)$instance, array( 'title' => '' ) );
|
75 |
|
wpsc-widgets/price_range_widget.php
CHANGED
@@ -140,10 +140,15 @@ function wpsc_price_range( $args = null ) {
|
|
140 |
}
|
141 |
|
142 |
if(isset($_GET['range'])){
|
143 |
-
add_filter( 'posts_where', '
|
144 |
}
|
145 |
-
|
146 |
function wpsc_rage_where( $where ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
global $wpdb, $wp_query;
|
148 |
$range = explode('-', $_GET['range']);
|
149 |
if(!strpos($where,'wpsc-product'))
|
140 |
}
|
141 |
|
142 |
if(isset($_GET['range'])){
|
143 |
+
add_filter( 'posts_where', 'wpsc_range_where' );
|
144 |
}
|
|
|
145 |
function wpsc_rage_where( $where ) {
|
146 |
+
_deprecated_function( __FUNCTION__, '3.8.8', 'wpsc_range_where()' );
|
147 |
+
|
148 |
+
return wpsc_range_where( $where );
|
149 |
+
|
150 |
+
}
|
151 |
+
function wpsc_range_where( $where ) {
|
152 |
global $wpdb, $wp_query;
|
153 |
$range = explode('-', $_GET['range']);
|
154 |
if(!strpos($where,'wpsc-product'))
|