Version Description
[2017-2-04] =
- Fix: Our extension page had some dated code which, in a bizarre turn of events, caused bulk select to break for all list tables. Mystery of mysteries, solved.
- Fix: Fix PHPMailer issue for emails failing to send when admin email is empty.
- Enhancement: Addition of In-Context Checkout for PayPal Express (3.0)
- Enhancement: Addition of Order Notes API
- Enhancement: Addition of Refund API (including partial refunds)
- Enhancement: Addition of ability to edit pending orders.
3.11.4 [2016-11-11]
- Security Fix: Under specific conditions (Gold Cart enabled, using eWay as a payment processor, and using the yet-to-be-released 2.0 Theme Engine) - a SQL vulnerability has been patched.
Download this release
Release Info
Developer | JustinSainton |
Plugin | WP eCommerce |
Version | 3.11.5 |
Comparing to | |
See all releases |
Code changes from version 3.11.4 to 3.11.5
- CONTRIBUTING.md +0 -24
- readme.txt +13 -4
- trunk/bin/install-wp-tests.sh +78 -0
- trunk/images/cc.gif +0 -0
- trunk/images/cc.png +0 -0
- trunk/images/icon_window_collapse.gif +0 -0
- trunk/images/icon_window_expand.gif +0 -0
- trunk/images/indicator.gif +0 -0
- trunk/images/paypal.gif +0 -0
- trunk/license.txt +281 -0
- trunk/readme.txt +908 -0
- trunk/screenshot-1.png +0 -0
- trunk/screenshot-2.png +0 -0
- trunk/screenshot-3.png +0 -0
- trunk/screenshot-4.png +0 -0
- trunk/wp-shopping-cart.php +352 -0
- trunk/wpsc-admin/admin-form-functions.php +265 -0
- trunk/wpsc-admin/admin.php +1581 -0
- trunk/wpsc-admin/ajax-and-init.php +221 -0
- trunk/wpsc-admin/ajax.php +1342 -0
- trunk/wpsc-admin/css/admin.css +2677 -0
- trunk/wpsc-admin/css/arrows.png +0 -0
- trunk/wpsc-admin/css/jquery.ui.datepicker-classic.css +579 -0
- trunk/wpsc-admin/css/jquery.ui.datepicker-fresh.css +579 -0
- trunk/wpsc-admin/css/jquery.ui.tabs.css +152 -0
- trunk/wpsc-admin/css/loading-small.gif +0 -0
- trunk/wpsc-admin/css/media.css +26 -0
- trunk/wpsc-admin/css/settingspage.css +472 -0
- trunk/wpsc-admin/css/ui-images/ui-icons_21759b_256x240.png +0 -0
- trunk/wpsc-admin/css/ui-images/ui-icons_333333_256x240.png +0 -0
- trunk/wpsc-admin/css/ui-images/ui-icons_999999_256x240.png +0 -0
- trunk/wpsc-admin/css/ui-images/ui-icons_cc0000_256x240.png +0 -0
- trunk/wpsc-admin/css/xit.gif +0 -0
- trunk/wpsc-admin/db-upgrades/routines/1.php +142 -0
- trunk/wpsc-admin/db-upgrades/routines/10.php +134 -0
- trunk/wpsc-admin/db-upgrades/routines/11.php +83 -0
- trunk/wpsc-admin/db-upgrades/routines/12.php +55 -0
- trunk/wpsc-admin/db-upgrades/routines/13.php +54 -0
- trunk/wpsc-admin/db-upgrades/routines/14.php +28 -0
- trunk/wpsc-admin/db-upgrades/routines/2.php +430 -0
- trunk/wpsc-admin/db-upgrades/routines/3.php +18 -0
- trunk/wpsc-admin/db-upgrades/routines/4.php +53 -0
- trunk/wpsc-admin/db-upgrades/routines/5.php +49 -0
- trunk/wpsc-admin/db-upgrades/routines/6.php +12 -0
- trunk/wpsc-admin/db-upgrades/routines/7.php +36 -0
- trunk/wpsc-admin/db-upgrades/routines/8.php +12 -0
- trunk/wpsc-admin/db-upgrades/routines/9.php +13 -0
- trunk/wpsc-admin/db-upgrades/upgrade.php +155 -0
- trunk/wpsc-admin/db-upgrades/views/main.php +11 -0
- trunk/wpsc-admin/display-coupon-add.php +133 -0
- trunk/wpsc-admin/display-coupon-edit.php +183 -0
- trunk/wpsc-admin/display-coupons.php +140 -0
- trunk/wpsc-admin/display-items.page.php +586 -0
- trunk/wpsc-admin/display-options-settings.page.php +72 -0
- trunk/wpsc-admin/display-sales-logs.php +812 -0
- trunk/wpsc-admin/display-update.page.php +122 -0
- trunk/wpsc-admin/display-upgrades.page.php +217 -0
- trunk/wpsc-admin/includes/coupon-list-table-class.php +484 -0
- trunk/wpsc-admin/includes/display-items-functions.php +1710 -0
- trunk/wpsc-admin/includes/duplicate-product-class.php +447 -0
- trunk/wpsc-admin/includes/product-functions.php +1233 -0
- trunk/wpsc-admin/includes/product-variation-list-table.class.php +678 -0
- trunk/wpsc-admin/includes/product-variations-manage.page.php +13 -0
- trunk/wpsc-admin/includes/product-variations-page.class.php +437 -0
- trunk/wpsc-admin/includes/product-variations-setup.page.php +40 -0
- trunk/wpsc-admin/includes/product-variations.page.php +59 -0
- trunk/wpsc-admin/includes/products.php +0 -0
- trunk/wpsc-admin/includes/purchase-log-action-links.php +482 -0
- trunk/wpsc-admin/includes/purchase-log-list-table-class.php +872 -0
- trunk/wpsc-admin/includes/purchase-logs-page/bulk-delete-confirm.php +9 -0
- trunk/wpsc-admin/includes/purchase-logs-page/item-details.php +117 -0
- trunk/wpsc-admin/includes/purchase-logs-page/list-table.php +83 -0
- trunk/wpsc-admin/includes/purchase-logs-page/packing-slip.php +162 -0
- trunk/wpsc-admin/includes/purchase-logs-page/upgrade.php +45 -0
- trunk/wpsc-admin/includes/save-data.functions.php +577 -0
- trunk/wpsc-admin/includes/settings-tabs/admin.php +153 -0
- trunk/wpsc-admin/includes/settings-tabs/checkout.php +525 -0
- trunk/wpsc-admin/includes/settings-tabs/gateway.php +168 -0
- trunk/wpsc-admin/includes/settings-tabs/general.php +240 -0
- trunk/wpsc-admin/includes/settings-tabs/import.php +367 -0
- trunk/wpsc-admin/includes/settings-tabs/marketing.php +210 -0
- trunk/wpsc-admin/includes/settings-tabs/shipping.php +344 -0
- trunk/wpsc-admin/includes/settings-tabs/taxes.php +221 -0
- trunk/wpsc-admin/includes/tax_and_shipping.php +67 -0
- trunk/wpsc-admin/includes/updating-functions.php +898 -0
- trunk/wpsc-admin/includes/walker-variation-checklist.php +57 -0
- trunk/wpsc-admin/init.php +893 -0
- trunk/wpsc-admin/js/admin-legacy.js +1066 -0
- trunk/wpsc-admin/js/admin.js +669 -0
- trunk/wpsc-admin/js/media.js +401 -0
- trunk/wpsc-admin/js/product-variations.js +249 -0
- trunk/wpsc-admin/js/purchase-log-action-links.js +126 -0
- trunk/wpsc-admin/js/purchase-logs.js +660 -0
- trunk/wpsc-admin/js/quick-edit.js +40 -0
- trunk/wpsc-admin/js/set-post-thumbnail.js +5 -0
CONTRIBUTING.md
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
# Contributing to WP eCommerce
|
2 |
-
|
3 |
-
Howdy! We're glad you're interested in contributing to WP eCommerce. Read on to make sure you follow all the steps required to successfully submit an issue or patch to the repository.
|
4 |
-
|
5 |
-
*This is not a place to submit support requests, this is a code repository to submit code bugs and code patches. Support tickets can be created here: https://wordpress.org/support/plugin/wp-e-commerce*
|
6 |
-
|
7 |
-
Before you submit an issue
|
8 |
-
---
|
9 |
-
1. Check for duplicate issues in the repo
|
10 |
-
2. Make sure you have the latest version of WP eCommerce running in your local enviroment
|
11 |
-
3. Fork the WP eCommerce repo in order to create Pull Requests.
|
12 |
-
|
13 |
-
Reporting a bug
|
14 |
-
---
|
15 |
-
1. Specify the version number for both WordPress and WP eCommerce
|
16 |
-
2. Describe the issue with great detail, be specific about the problem you see.
|
17 |
-
3. If this is a browser issue, make sure to mention which browser you have trouble on.
|
18 |
-
4. If this is a visual bug, please make sure to add a screenshot.
|
19 |
-
5. if you create a Pull Request for this issue, make sure to attach the Pull Request created to the issue.
|
20 |
-
|
21 |
-
Resources
|
22 |
-
---
|
23 |
-
[Labels and Workflow](https://github.com/wp-e-commerce/WP-e-Commerce/wiki/Issue-Labels-and-Workflow)
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: JustinSainton
|
3 |
Donate link: https://wpecommerce.org
|
4 |
Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 4.7
|
7 |
-
Stable tag: 3.11.
|
8 |
|
9 |
WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
|
10 |
|
@@ -36,7 +36,16 @@ After upgrading from earlier versions look for link "Update Store". This will up
|
|
36 |
|
37 |
== Changelog ==
|
38 |
|
39 |
-
= 3.11.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
* Security Fix: Under specific conditions (Gold Cart enabled, using eWay as a payment processor, and using the yet-to-be-released 2.0 Theme Engine) - a SQL vulnerability has been patched.
|
42 |
|
2 |
Contributors: JustinSainton
|
3 |
Donate link: https://wpecommerce.org
|
4 |
Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
|
5 |
+
Requires at least: 4.5
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 3.11.5
|
8 |
|
9 |
WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
|
10 |
|
36 |
|
37 |
== Changelog ==
|
38 |
|
39 |
+
= 3.11.5 [2017-2-04] =
|
40 |
+
|
41 |
+
* Fix: Our extension page had some dated code which, in a bizarre turn of events, caused bulk select to break for all list tables. Mystery of mysteries, solved.
|
42 |
+
* Fix: Fix PHPMailer issue for emails failing to send when admin email is empty.
|
43 |
+
* Enhancement: Addition of In-Context Checkout for PayPal Express (3.0)
|
44 |
+
* Enhancement: Addition of Order Notes API
|
45 |
+
* Enhancement: Addition of Refund API (including partial refunds)
|
46 |
+
* Enhancement: Addition of ability to edit pending orders.
|
47 |
+
|
48 |
+
3.11.4 [2016-11-11]
|
49 |
|
50 |
* Security Fix: Under specific conditions (Gold Cart enabled, using eWay as a payment processor, and using the yet-to-be-released 2.0 Theme Engine) - a SQL vulnerability has been patched.
|
51 |
|
trunk/bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
if [ $# -lt 3 ]; then
|
4 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
DB_NAME=$1
|
9 |
+
DB_USER=$2
|
10 |
+
DB_PASS=$3
|
11 |
+
DB_HOST=${4-localhost}
|
12 |
+
WP_VERSION=${5-latest}
|
13 |
+
|
14 |
+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
15 |
+
WP_CORE_DIR=/tmp/wordpress/
|
16 |
+
|
17 |
+
set -ex
|
18 |
+
|
19 |
+
install_wp() {
|
20 |
+
mkdir -p $WP_CORE_DIR
|
21 |
+
|
22 |
+
if [ $WP_VERSION == 'latest' ]; then
|
23 |
+
local ARCHIVE_NAME='latest'
|
24 |
+
else
|
25 |
+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
26 |
+
fi
|
27 |
+
|
28 |
+
wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
|
29 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
30 |
+
|
31 |
+
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
|
32 |
+
}
|
33 |
+
|
34 |
+
install_test_suite() {
|
35 |
+
# portable in-place argument for both GNU sed and Mac OSX sed
|
36 |
+
if [[ $(uname -s) == 'Darwin' ]]; then
|
37 |
+
local ioption='-i .bak'
|
38 |
+
else
|
39 |
+
local ioption='-i'
|
40 |
+
fi
|
41 |
+
|
42 |
+
# set up testing suite
|
43 |
+
mkdir -p $WP_TESTS_DIR
|
44 |
+
cd $WP_TESTS_DIR
|
45 |
+
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
46 |
+
|
47 |
+
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
|
48 |
+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
49 |
+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
50 |
+
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
51 |
+
sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
|
52 |
+
sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
|
53 |
+
}
|
54 |
+
|
55 |
+
install_db() {
|
56 |
+
# parse DB_HOST for port or socket references
|
57 |
+
local PARTS=(${DB_HOST//\:/ })
|
58 |
+
local DB_HOSTNAME=${PARTS[0]};
|
59 |
+
local DB_SOCK_OR_PORT=${PARTS[1]};
|
60 |
+
local EXTRA=""
|
61 |
+
|
62 |
+
if ! [ -z $DB_HOSTNAME ] ; then
|
63 |
+
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
|
64 |
+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
65 |
+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
66 |
+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
67 |
+
elif ! [ -z $DB_HOSTNAME ] ; then
|
68 |
+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
69 |
+
fi
|
70 |
+
fi
|
71 |
+
|
72 |
+
# create database
|
73 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
74 |
+
}
|
75 |
+
|
76 |
+
install_wp
|
77 |
+
install_test_suite
|
78 |
+
install_db
|
trunk/images/cc.gif
ADDED
Binary file
|
trunk/images/cc.png
ADDED
Binary file
|
trunk/images/icon_window_collapse.gif
ADDED
Binary file
|
trunk/images/icon_window_expand.gif
ADDED
Binary file
|
trunk/images/indicator.gif
ADDED
Binary file
|
trunk/images/paypal.gif
ADDED
Binary file
|
trunk/license.txt
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5 |
+
51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
6 |
+
|
7 |
+
Everyone is permitted to copy and distribute verbatim copies
|
8 |
+
of this license document, but changing it is not allowed.
|
9 |
+
|
10 |
+
Preamble
|
11 |
+
|
12 |
+
The licenses for most software are designed to take away your
|
13 |
+
freedom to share and change it. By contrast, the GNU General Public
|
14 |
+
License is intended to guarantee your freedom to share and change free
|
15 |
+
software--to make sure the software is free for all its users. This
|
16 |
+
General Public License applies to most of the Free Software
|
17 |
+
Foundation's software and to any other program whose authors commit to
|
18 |
+
using it. (Some other Free Software Foundation software is covered by
|
19 |
+
the GNU Library General Public License instead.) You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
this service if you wish), that you receive source code or can get it
|
26 |
+
if you want it, that you can change the software or use pieces of it
|
27 |
+
in new free programs; and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to make restrictions that forbid
|
30 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
31 |
+
These restrictions translate to certain responsibilities for you if you
|
32 |
+
distribute copies of the software, or if you modify it.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must give the recipients all the rights that
|
36 |
+
you have. You must make sure that they, too, receive or can get the
|
37 |
+
source code. And you must show them these terms so they know their
|
38 |
+
rights.
|
39 |
+
|
40 |
+
We protect your rights with two steps: (1) copyright the software, and
|
41 |
+
(2) offer you this license which gives you legal permission to copy,
|
42 |
+
distribute and/or modify the software.
|
43 |
+
|
44 |
+
Also, for each author's protection and ours, we want to make certain
|
45 |
+
that everyone understands that there is no warranty for this free
|
46 |
+
software. If the software is modified by someone else and passed on, we
|
47 |
+
want its recipients to know that what they have is not the original, so
|
48 |
+
that any problems introduced by others will not reflect on the original
|
49 |
+
authors' reputations.
|
50 |
+
|
51 |
+
Finally, any free program is threatened constantly by software
|
52 |
+
patents. We wish to avoid the danger that redistributors of a free
|
53 |
+
program will individually obtain patent licenses, in effect making the
|
54 |
+
program proprietary. To prevent this, we have made it clear that any
|
55 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
56 |
+
|
57 |
+
The precise terms and conditions for copying, distribution and
|
58 |
+
modification follow.
|
59 |
+
|
60 |
+
GNU GENERAL PUBLIC LICENSE
|
61 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
62 |
+
|
63 |
+
0. This License applies to any program or other work which contains
|
64 |
+
a notice placed by the copyright holder saying it may be distributed
|
65 |
+
under the terms of this General Public License. The "Program", below,
|
66 |
+
refers to any such program or work, and a "work based on the Program"
|
67 |
+
means either the Program or any derivative work under copyright law:
|
68 |
+
that is to say, a work containing the Program or a portion of it,
|
69 |
+
either verbatim or with modifications and/or translated into another
|
70 |
+
language. (Hereinafter, translation is included without limitation in
|
71 |
+
the term "modification".) Each licensee is addressed as "you".
|
72 |
+
|
73 |
+
Activities other than copying, distribution and modification are not
|
74 |
+
covered by this License; they are outside its scope. The act of
|
75 |
+
running the Program is not restricted, and the output from the Program
|
76 |
+
is covered only if its contents constitute a work based on the
|
77 |
+
Program (independent of having been made by running the Program).
|
78 |
+
Whether that is true depends on what the Program does.
|
79 |
+
|
80 |
+
1. You may copy and distribute verbatim copies of the Program's
|
81 |
+
source code as you receive it, in any medium, provided that you
|
82 |
+
conspicuously and appropriately publish on each copy an appropriate
|
83 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
84 |
+
notices that refer to this License and to the absence of any warranty;
|
85 |
+
and give any other recipients of the Program a copy of this License
|
86 |
+
along with the Program.
|
87 |
+
|
88 |
+
You may charge a fee for the physical act of transferring a copy, and
|
89 |
+
you may at your option offer warranty protection in exchange for a fee.
|
90 |
+
|
91 |
+
2. You may modify your copy or copies of the Program or any portion
|
92 |
+
of it, thus forming a work based on the Program, and copy and
|
93 |
+
distribute such modifications or work under the terms of Section 1
|
94 |
+
above, provided that you also meet all of these conditions:
|
95 |
+
|
96 |
+
a) You must cause the modified files to carry prominent notices
|
97 |
+
stating that you changed the files and the date of any change.
|
98 |
+
|
99 |
+
b) You must cause any work that you distribute or publish, that in
|
100 |
+
whole or in part contains or is derived from the Program or any
|
101 |
+
part thereof, to be licensed as a whole at no charge to all third
|
102 |
+
parties under the terms of this License.
|
103 |
+
|
104 |
+
c) If the modified program normally reads commands interactively
|
105 |
+
when run, you must cause it, when started running for such
|
106 |
+
interactive use in the most ordinary way, to print or display an
|
107 |
+
announcement including an appropriate copyright notice and a
|
108 |
+
notice that there is no warranty (or else, saying that you provide
|
109 |
+
a warranty) and that users may redistribute the program under
|
110 |
+
these conditions, and telling the user how to view a copy of this
|
111 |
+
License. (Exception: if the Program itself is interactive but
|
112 |
+
does not normally print such an announcement, your work based on
|
113 |
+
the Program is not required to print an announcement.)
|
114 |
+
|
115 |
+
These requirements apply to the modified work as a whole. If
|
116 |
+
identifiable sections of that work are not derived from the Program,
|
117 |
+
and can be reasonably considered independent and separate works in
|
118 |
+
themselves, then this License, and its terms, do not apply to those
|
119 |
+
sections when you distribute them as separate works. But when you
|
120 |
+
distribute the same sections as part of a whole which is a work based
|
121 |
+
on the Program, the distribution of the whole must be on the terms of
|
122 |
+
this License, whose permissions for other licensees extend to the
|
123 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
trunk/readme.txt
ADDED
@@ -0,0 +1,908 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP eCommerce ===
|
2 |
+
Contributors: JustinSainton
|
3 |
+
Donate link: https://wpecommerce.org
|
4 |
+
Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
|
5 |
+
Requires at least: 4.5
|
6 |
+
Tested up to: 4.7.2
|
7 |
+
Stable tag: 3.11.5
|
8 |
+
|
9 |
+
WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Since 2006, we've been helping entrepreneurs just like you realize their goal of selling online. Whether you're hoping to sell digital downloads, physical inventory, or subscriptions and memberships - with WP eCommerce, you're only minutes away from your next sale.
|
14 |
+
|
15 |
+
* Make the plugin your own with CSS and HTML customizations
|
16 |
+
* Learn quickly with our [video tutorials](http://docs.wpecommerce.org/category/resources/videos/)
|
17 |
+
* Integration with [dozens of different payment gateways](http://wpecommerce.org/store/premium-plugins/)
|
18 |
+
* Integrate with many popular WordPress plugins
|
19 |
+
* Use built-in marketing tools to sell more
|
20 |
+
* Shipping is easy with built in shipping tools and integration with popular couriers
|
21 |
+
* Secure check-out with SSL
|
22 |
+
* Manage your orders and catalogues with powerful built-in tools
|
23 |
+
* Extend your eCommerce site with [additional modules](http://wpecommerce.org/store/premium-plugins/)
|
24 |
+
* Integrate with WordPress multisite
|
25 |
+
* With hundreds of available hooks, developers can make WP eCommerce do anything you can imagine
|
26 |
+
|
27 |
+
== Installation ==
|
28 |
+
|
29 |
+
1. Upload the folder 'wp-e-commerce' to the '/wp-content/plugins/' directory
|
30 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
31 |
+
|
32 |
+
= Updating =
|
33 |
+
|
34 |
+
Before updating please make a backup of your existing files and database. Just in case.
|
35 |
+
After upgrading from earlier versions look for link "Update Store". This will update your database structure to work with new version.
|
36 |
+
|
37 |
+
== Changelog ==
|
38 |
+
|
39 |
+
= 3.11.5 [2017-2-04] =
|
40 |
+
|
41 |
+
* Fix: Our extension page had some dated code which, in a bizarre turn of events, caused bulk select to break for all list tables. Mystery of mysteries, solved.
|
42 |
+
* Fix: Fix PHPMailer issue for emails failing to send when admin email is empty.
|
43 |
+
* Enhancement: Addition of In-Context Checkout for PayPal Express (3.0)
|
44 |
+
* Enhancement: Addition of Order Notes API
|
45 |
+
* Enhancement: Addition of Refund API (including partial refunds)
|
46 |
+
* Enhancement: Addition of ability to edit pending orders.
|
47 |
+
|
48 |
+
3.11.4 [2016-11-11]
|
49 |
+
|
50 |
+
* Security Fix: Under specific conditions (Gold Cart enabled, using eWay as a payment processor, and using the yet-to-be-released 2.0 Theme Engine) - a SQL vulnerability has been patched.
|
51 |
+
|
52 |
+
= 3.11.3 [2016-5-23] =
|
53 |
+
|
54 |
+
* Fix: WordPress 4.4 introduced changes to the WPDB class that caused loosely typed data to fail upon insert, causing empty cart contents entries when taxes were applied and coupons not being created.
|
55 |
+
* Fix: Pagination on purchase logs was broken. Now, it's not.
|
56 |
+
* Fix: Now, you can upload category images when editing product categories, not just when adding them.
|
57 |
+
* Fix: A random and quite awful bug was causing the "collapse menu" toggle to be perpetually collapsed if you collapsed it even once. No more!
|
58 |
+
* Enhancement: Addition of premium product license activation functionality on licensing page.
|
59 |
+
|
60 |
+
= 3.11.2 =
|
61 |
+
|
62 |
+
* Fix: WordPress 4.4 introduced changes to the WPDB class that caused loosely typed data to fail upon insert, causing empty purchase logs.
|
63 |
+
|
64 |
+
= 3.11.1 =
|
65 |
+
|
66 |
+
* Fix: Amazon Payments caused fatal errors on PHP 5.2. See [#2026](https://github.com/wp-e-commerce/WP-e-Commerce/issues/2026).
|
67 |
+
* Fix: Our translation update was too fast, too furious. We accidentally replaced a string we didn't intend to replace. This broke pagination for products. We feel pretty bad about that.
|
68 |
+
|
69 |
+
= 3.11.0 =
|
70 |
+
|
71 |
+
* _Potentially breaking change_: wpsc_add_to_cart() now checks the `$_REQUEST` super global, rather than `$_POST`. This allows for future features, such as populating carts from a URL token, etc. Anywhere you may have code that checks for $_POST, in this context, it should now check $_REQUEST. See [#1852](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1852).
|
72 |
+
* Fix: Improvements to internationalization across the board, including updates to introduce compatibility for translate.wordpress.org.
|
73 |
+
* Fix: Show admin notice if administrator has not set any target markets. See [#711](https://github.com/wp-e-commerce/WP-e-Commerce/issues/711).
|
74 |
+
* Fix: Check post_status more stringently in single page template controller. See [#844](https://github.com/wp-e-commerce/WP-e-Commerce/issues/844).
|
75 |
+
* Fix: The Google Analytics integration was calculating products once, not once per quantity in the cart. See [#1718](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1718).
|
76 |
+
* Fix: The Google Analytics integration was incompatible with the Yoast Analytics plugin. See [#1736](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1736).
|
77 |
+
* Fix: Resolve scenarios where variation combinations for products that were unavailable could still allow for cart addition (adding the parent product, rather than the variation). See [#1373](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1373).
|
78 |
+
* Fix: Order totals on sales log page did not count Closed Orders, but did Orders Received. This has been reversed, as that is the paradigm used throughout the rest of the project. See [#1728](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1728).
|
79 |
+
* Fix: Deleting a purchase log now also deletes the purchase meta associated with that log. See [#1877](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1877).
|
80 |
+
* Fix: Deleting a purchase log now also deletes the download status entries for that log. See [#1964](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1964).
|
81 |
+
* Fix: In the rare occurrence that an insert for a purchase log entry fails, we now return an error saying so. See [#1892](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1892).
|
82 |
+
* Fix: When creating a variation, you should be limited to selecting only variation sets as parents, not other variations. See [#1893](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1893).
|
83 |
+
* Enhancement: General performance improvements surrounding meta retreival, especially for countries. Including caching, cache invalidation, etc. See [#1894](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1894).
|
84 |
+
* Enhancement: New 3.0 Payment Gateway API now has a method that checks for currencies that don't use fractions. Our code formally had several areas these currencies were hard-coded, and egregiously incomplete. See [#1917](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1917).
|
85 |
+
* Enhancement: Mass improvements to 2.0 theme engine. Bug fixes, rich markup support, and much more. Want to test it out before 4.0? We have a filter for that.
|
86 |
+
* Enhancement: Filter bulk messages to reflect that users are updating products, not posts. See [#844](https://github.com/wp-e-commerce/WP-e-Commerce/issues/844).
|
87 |
+
* Enhancement: Improvements to code for Australia Post. See [#1337](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1337).
|
88 |
+
* Enhancement: Standardize on a single, filterable method for checking the completion status of an order. See [#1360](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1360).
|
89 |
+
* Enhancement: Significant improvements to how digital downloads are handled and made available. See [#37](https://github.com/wp-e-commerce/WP-e-Commerce/issues/37).
|
90 |
+
* Enhancement: Improve admin performance for sorted product categories. See [#1389](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1389).
|
91 |
+
* Enhancement: Regions are now filtered. See [#1930](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1930).
|
92 |
+
* Enhancement: Improve flexibility of product duplication functionality. Ensures that post meta tied to specific IDs have the available filters to update those IDs. See [#1672](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1672).
|
93 |
+
* Enhancement: All front-end AJAX responses are now filtered. See [#1698](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1698).
|
94 |
+
* New: Introducing Amazon Payments as an available payment gateway.
|
95 |
+
* New: Introduced better filtering mechanisms for custom purchase statuses and related bulk actions and labels for those statuses. See [#1525](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1525) and related issues/PRs.
|
96 |
+
* New: Introduced a new filter, `wpsc_checkout_get_fields`, allowing you to add, remove, and modify checkout form fields. See [#1837](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1837).
|
97 |
+
|
98 |
+
|
99 |
+
= 3.10.1 =
|
100 |
+
|
101 |
+
* Fix: Uses version_compare() for comparing wpsc_version constant in legacy code (from 5 years ago). Using comparators was causing 3.10.0 to be "less than" 3.8, resulting in an unnecessary admin notice.
|
102 |
+
* Fix: Changes internal mechanism for detecting which theme engine is in use. The way we were checking for it before caused many core actions to be unhooked, leading to unsavory results, like Fancy Notifications no longer working.
|
103 |
+
* Fix: Patched in a few fixes for incorrect usage of esc_url(). This resolves scenarios like the selecting a custom checkout form in the Dashboard failing because of double-encoded ampersands.
|
104 |
+
|
105 |
+
= 3.10.0 =
|
106 |
+
|
107 |
+
* Enhancement: Added updated PayPal gateways. We now support Digital Goods and Pro Hosted, and have updated the Express Checkout gateway. We now recommend all existing users of the 2.0 Express Checkout gateway update to the 3.0 version.
|
108 |
+
|
109 |
+
= 3.9.5 =
|
110 |
+
|
111 |
+
* Fix: 4.3 Compatibility w/ WP_Widget constructors.
|
112 |
+
|
113 |
+
= 3.9.4 =
|
114 |
+
|
115 |
+
* Security Fix: Harden several instances of $_POST input that were not sanitized properly. Specifically, PayPal settings and Quick Edit fields for products.
|
116 |
+
* Security Fix: Do not return visitor meta if WP eCommerce presumes a user to be a bot.
|
117 |
+
* Enhancement: Provide a notice for users to repair their WP eCommerce tables if visitor and visitor meta tables are in need of repair. See [#1901](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1901).
|
118 |
+
* Fix: Notices on stats saving for products.
|
119 |
+
|
120 |
+
= 3.9.3 =
|
121 |
+
|
122 |
+
* Fix: Fix potential reflexive XSS issue with add_query_arg() and remove_query_arg() usage. Update is _highly_ recommended.
|
123 |
+
|
124 |
+
= 3.9.2 =
|
125 |
+
|
126 |
+
* Fix: Reverted pre_get_posts hook. See [#1444](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1444). This was causing issues with template redirection and selection on search templates.
|
127 |
+
* Fix: Shipping conflict with target market restrictions on specific categories. See [#1711](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1711).
|
128 |
+
* Fix: Taxes were broken following some refactoring of the admin saving callbacks.
|
129 |
+
* Fix: Quick edit was overwriting variation SKUs and sale prices.
|
130 |
+
* Fix: RSS Feed error.
|
131 |
+
|
132 |
+
= 3.9.1 =
|
133 |
+
|
134 |
+
* Fix: Disable 3.0 payment gateway API gateways. Will be re-enabled after more vigorous testing.
|
135 |
+
* Fix: Check that $wpsc_cart->cart_items is an array, not an object.
|
136 |
+
* Fix: Improve shipping method property checks in wpsc_cart class. See [#1683](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1683).
|
137 |
+
* Fix: Add asterix class to required fields for PayPal Pro 2.0.
|
138 |
+
* Fix: Ensure taxable checkbox can be unchecked. 3.9 regression. See [#1685](https://github.com/wp-e-commerce/WP-e-Commerce/issues/1685).
|
139 |
+
* Fix: Only show completed purchases in the user account area.
|
140 |
+
* Fix: Use is_email(), rather than a faulty regex, for checkout email field validation.
|
141 |
+
* Fix: More than a [handful of faulty variables](https://github.com/wp-e-commerce/WP-e-Commerce/commit/58f2d3ad9698ef496a27a701e5a926e412d55c05) were referenced in wpsc_coupons.
|
142 |
+
* Fix: Function `wpsc_string_to_boolean` was essentially non functional.
|
143 |
+
* Fix: Send country and state through to PayPal only if they actually exist.
|
144 |
+
* Fix: Broken theme-engine activation routine. Would always fail, running 1.0 engine.
|
145 |
+
|
146 |
+
= 3.9 =
|
147 |
+
|
148 |
+
* Fix: Eliminate most usage of number-based inputs in product UI.
|
149 |
+
* Fix: Fall back to product ID if SKU is not set for Google Analytics reporting.
|
150 |
+
* Fix: Restored inadvertently removed filter, `wpsc_add_advanced_options`.
|
151 |
+
* Fix: Ensure price entered for "Free Shipping" threshold is locale-aware.
|
152 |
+
* Fix: Generally improved metadata saving routines for quick/bulk edit areas.
|
153 |
+
* Fix: Ensure "Combination of product variants is not available" message is hidden from Grid View.
|
154 |
+
* Fix: Don't require a shipping method to be selected if you qualify for free shipping.
|
155 |
+
* Fix: When "Buy Now" button is used, it is now disabled if item is out of stock.
|
156 |
+
* New: Introduced `wpsc_get_countries` and `wpsc_get_countries_array` filters.
|
157 |
+
* New: Introduced `wpsc_google_analytics_pushed_product` filter.
|
158 |
+
* New: Introduced `wpsc_get_downloadable_links` filter.
|
159 |
+
* New: Added screen option for number of purchase logs to show on a page.
|
160 |
+
* New: Introduced WPSC_Logging class. Based on WP_Logging.
|
161 |
+
* New: Customers may now checkout with carts that have a value of $0.
|
162 |
+
* New: Introduces `wpsc_is_free_cart` filter.
|
163 |
+
* New: Added 2.0 theme engine component. Defaults off until the 4.0 release, but can be enabled via filter for testing.
|
164 |
+
* New: Added marketplace component.
|
165 |
+
* New: Added 3.0 payment gateway API component.
|
166 |
+
* New: PayPal Digital Goods gateway, updated PayPal Express Checkout, PayPal Pro and Manual Payment gateways.
|
167 |
+
* New: Product Tags now have proper body classes.
|
168 |
+
* New: Meta updates, kind of a big deal: We're now using X.X.Y versioning (like WordPress) and we now have unit tests.
|
169 |
+
* New: Introduce attachments method and filter for WPSC_Purchase_Log_Notification class.
|
170 |
+
* New: Single Product pages now have ID-based body classes.
|
171 |
+
* New: Supports Universal Analytics in Google Analytics.
|
172 |
+
* New: Added `wpsc_checkout_fields` filter for filtering checkout form fields.
|
173 |
+
* Change: Dates are now optional on coupons. Expiration, specifically, is no longer required. Validation is filterable via `wpsc_coupons_validate_coupon`.
|
174 |
+
* Change: Refactored purchase log action links, introduced new API for adding links.
|
175 |
+
* Change: Product page shortcodes, e.g. [productspage], are now stripped from the_excerpt(). Helpful for cleaner looking search results.
|
176 |
+
* Change: Limit Google Product ID to 50 characters in Google Product Feed. Introduced `wpsc_google_product_feed_product_id`.
|
177 |
+
* Change: When only one shipping rate is available, it will automatically be selected as the default rate.
|
178 |
+
|
179 |
+
= 3.8.14.4 =
|
180 |
+
|
181 |
+
* Fix: Significant security vulnerability whereby some admin actions were exploitable by unauthorized users. Props to Sucuri for the responsible disclosure.
|
182 |
+
* Fix: Other less significant security hardening and minor code maintenance.
|
183 |
+
|
184 |
+
= 3.8.14.3 =
|
185 |
+
|
186 |
+
* Fix: Resolve PHP warning in stats logging class.
|
187 |
+
|
188 |
+
= 3.8.14.2 =
|
189 |
+
|
190 |
+
* Fix: Clear country cache automatically.
|
191 |
+
* Fix: Fixed notices when using quick edit.
|
192 |
+
* Fix: Fixed html in checkout form.
|
193 |
+
* Fix: Fixed shipping results not being displayed.
|
194 |
+
* Fix: Does not show errors when deprecated google checkout is used.
|
195 |
+
* Fix: Makes sure countries are validated if mandatory.
|
196 |
+
* Fix: Makes sure the payment gateway checks for first and last name.
|
197 |
+
* Fix: Only output html for shipping error page.
|
198 |
+
* Fix: Updated shipping calculator to check for new checkout information and made the calculator more efficient.
|
199 |
+
* Fix: USPS shipping now works for servers that don't support curl.
|
200 |
+
* Fix: Personalization forms are correctly initialized in database.
|
201 |
+
* Fix: Display of products in admin product gallery will display in the order admins want them to.
|
202 |
+
* New: Updated Polish and Russian language files.
|
203 |
+
* New: Added filter wpsc_uncategorized_product_category to change uncategorized section.
|
204 |
+
* New: New hook - wpsc_coupon_add_top and wpsc_coupon_add_bottom for the add coupon section.
|
205 |
+
* New: New hook - wpsc_element_is_visible to check and see if an element is visible.
|
206 |
+
* Change: Show region on shipping calculator.
|
207 |
+
* Change: Billing was accidentally referred to as shipping when billing state and region was a drop down.
|
208 |
+
|
209 |
+
= 3.8.14.1 =
|
210 |
+
|
211 |
+
* Fix: For users with older (3.7.x and older) templates copied into their theme directory, we inadvertently broke the visibility of the shipping calculator.
|
212 |
+
* Fix: Under similar circumstances, taxes would not properly calculate.
|
213 |
+
* Fix: Ensured compatibility with the popular "Weight and Destination" shipping module. Note: You may need to go to your Target Markets and re-save the values there to properly flush the cache for this compatibility.
|
214 |
+
* Fix: Edge case where $0.00 could be returned for a shipping rate.
|
215 |
+
* Fix: Race condition on AJAX save while submitting purchase.
|
216 |
+
* Fix: Restored proper functionality on digital downloads.
|
217 |
+
* Fix: Ensure that UPS and USPS always return proper and expected values. Incrementally improved error handling here.
|
218 |
+
* Fix: Ensure that shipping method is properly retained if checkout page is refreshed.
|
219 |
+
* Change: Added "County" as the region label for the UK.
|
220 |
+
|
221 |
+
= 3.8.14 =
|
222 |
+
* Fix: Improved visitor profiles performance, new infrastructure does not use WordPress Users.
|
223 |
+
* Fix: When page caching is being used, probability of empty or superfluous visitor profiles being created drastically diminished.
|
224 |
+
* Fix: Send appropriate addresses to PayPal via PayPal Standard.
|
225 |
+
* Fix: Ensure that sales tax is not added to non-tax items when using a coupon.
|
226 |
+
* Fix: Ensure state text field is not visible at the same time as state dropdown.
|
227 |
+
* Fix: Ensure shortcodes respect display type as overridden by categories. Note: Requires latest Gold Cart release.
|
228 |
+
* Fix: Ensure that adding a new item to the cart after a coupon code properly reflects that coupon code.
|
229 |
+
* Fix: Don't create cron events for unknown schedules.
|
230 |
+
* Fix: Shipping options were disappearing when "same as billing address" were selected.
|
231 |
+
* Fix: Protect against "Price From: " being zero if a sales price was set without a normal price.
|
232 |
+
* Fix: Added programmatic and UX checks for conflict where grid/list view could show products with variations without the variation drop-downs, adding an improper product to the cart.
|
233 |
+
* Fix: Improved shipping rate quote retrieval performance.
|
234 |
+
* Fix: Sends proper tax amount to PayPal Standard when carts are aggregated.
|
235 |
+
* Fix: Fixed pagination bug where improper number of paged links were returned.
|
236 |
+
* Fix: Ensure UPS Environment test mode works.
|
237 |
+
* Fix: Downloadable products were not being properly added as attachments.
|
238 |
+
* Fix: "Shipping Same as Billing" could cause products to be shipped to countries which are not allowed.
|
239 |
+
* Fix: Eliminate undefined index errors on sales log page when checkout fields are removed.
|
240 |
+
* Fix: Address edge case where purchase notifications are not sent when there are multiple email fields in different checkout form sets.
|
241 |
+
* Fix: Improved bbPress compatibility.
|
242 |
+
* Fix: Ensure User Account pages are properly overridable in the template stack.
|
243 |
+
* Fix: Properly escape classes for Buy Now button classes.
|
244 |
+
* Fix: Fix IE8 javascript conflicts.
|
245 |
+
* Fix: Shored up backwards compatibility for Session usage
|
246 |
+
* Fix: Ensure cart items with variations that are out of stock (and stock limited) don't return a fatal error.
|
247 |
+
* Fix: Address malformed XML output for shipping quotes from UPS and USPS.
|
248 |
+
* Fix: Ensure PayPal Express does not show coupons as an empty line item when discounts are not used.
|
249 |
+
* Fix: A redirection error on our wpsc_scale_image fallback was resolved.
|
250 |
+
* Fix: Ensure only available countries are shown as available in PayPal Express.
|
251 |
+
* Fix: Resolved issue whereby amounts over 1,000 (in a given currency) would be incorrectly sent to Google Analytics.
|
252 |
+
* Fix: Shipping calculator uses information set in user account profile, if set.
|
253 |
+
* Fix: When PATHINFO Permalinks ("Almost Pretty"), product pages would 404.
|
254 |
+
* Fix: Ensure 3.7.x -> 3.8.x upgrade routine uses wpdb::prepare() properly.
|
255 |
+
* New: AJAX API to get and set information about customers.
|
256 |
+
* New: Visitor API to get and set information about current and past visits.
|
257 |
+
* New: Introduced WPSC_Claimed_Stock class.
|
258 |
+
* New: Introduced WPSC_Stats class.
|
259 |
+
* New: Introduced WPSC_Product/WPSC_Products class.
|
260 |
+
* New: Introduced WPSC_Countries / WPSC_Region class.
|
261 |
+
* New: Totally revamped product editing and adding user interface.
|
262 |
+
* New: Added new Purchase Meta API.
|
263 |
+
* New: Some compatibility fixes for WordPress 3.9.
|
264 |
+
* New: Improved extendibility of the Import Settings area.
|
265 |
+
* New: Improved extendibility for our conditional coupon callbacks.
|
266 |
+
* Change: Iterated upon WPSC_Country class.
|
267 |
+
* Change: Improved UK Country Display.
|
268 |
+
* Change: Improved upgrade routines for currencies and countries.
|
269 |
+
* Change: Introduced filter for themeable packing slips.
|
270 |
+
* Change: Modified calculation for total price to ensure coupons don't reduce shipping and tax.
|
271 |
+
* Change: Improved Checkout workflow and UI.
|
272 |
+
* Change: Fully remove Google Checkout from WP eCommerce, as it has been deprecated.
|
273 |
+
* Change: Don't show transaction results to anyone but the purchaser
|
274 |
+
* Change: Eliminated usage of dynamic CSS and javascript in front-end and admin.
|
275 |
+
* Change: Couldn't use decimals in product's variation sale price.
|
276 |
+
* Change: Tons of performance improvements to USPS and UPS.
|
277 |
+
* Change: Add condition as parameter to wpsc_coupon_rule_property_options action.
|
278 |
+
* Change: Improved security for our customer cookie hash.
|
279 |
+
* Change: Don't default to base country of store in checkout fields.
|
280 |
+
* Change: Taxes class previously regarded regions as unique, when they are not. We now check both region and country where applicable.
|
281 |
+
* Change: By default, quantity boxes will be shown on new installs.
|
282 |
+
|
283 |
+
= 3.8.13.3 =
|
284 |
+
* Fix: Users disappear in Network Admin -> Users page (for multisite).
|
285 |
+
* Fix: User counts are incorrect when there are thousands separators.
|
286 |
+
* Fix: "Save Product Files" button doesn't like being clicked on.
|
287 |
+
|
288 |
+
|
289 |
+
= 3.8.13.2 =
|
290 |
+
* Fix: Anonymous customers should not be visible in admin UI.
|
291 |
+
* Fix: Cronjob to purge anonymous customers doesn't work due to memory issues.
|
292 |
+
* Fix: Anonymous cart items will be lost after signing in.
|
293 |
+
|
294 |
+
= 3.8.13.1 =
|
295 |
+
* Security and maintenance release
|
296 |
+
|
297 |
+
= 3.8.13 =
|
298 |
+
|
299 |
+
* New: Product Media UI.
|
300 |
+
* New: Cart Item Meta API
|
301 |
+
* New: 'wpsc_after_checkout_cart_rows' action.
|
302 |
+
* New: Add 'wpsc_default_dimension_unit' and 'wpsc_default_weight_unit' filters.
|
303 |
+
* New: Add 'wpsc_save_product_order' action and use it to save category product order in the term_relationships table.
|
304 |
+
* New: Add logic filter for coupons. We currently have one for properties, this should sufficiently round out the extensibility for the UI.
|
305 |
+
* New: Allow gateway images to be filtered.
|
306 |
+
* New: Allow multiple comma-separated categories in coupon conditions.
|
307 |
+
* New: Product Gallery metabox.
|
308 |
+
* Change: Better Customer API.
|
309 |
+
* Change: Prepend (WPEC) to widget names in wp-admin
|
310 |
+
* Change: Replace default noimage.png with a better image.
|
311 |
+
* Change: Updated NL language
|
312 |
+
* Change: Updated german language strings
|
313 |
+
* Change: Use new spinner image in WordPress 3.8
|
314 |
+
* Fix: Add preg_quote() to coupon regexes that intend to parse strings. Fixes issue where unexpected results occur when strings contain slashes, or really, any regex-oriented characters.
|
315 |
+
* Fix: Change wpsc_get_remaining_quantity() to call the method dynamically, rather than statically. The previous behaviour caused a strict standards warning.
|
316 |
+
* Fix: Database Upgrade Routine to rename old _wpsc_* product metadata array keys so they no longer include the '_wpsc_' prefix
|
317 |
+
* Fix: In Purchase log admin screen, item count is sum of quantity field rather than count of rows
|
318 |
+
* Fix: Invert logic on shipping ZIP code check in core theme files.
|
319 |
+
* Fix: Modify behavior in Download CSV functionality to properly convert region IDs to regions.
|
320 |
+
* Fix: Modify wpsc_update_item_quantity() to listen for wpsc_quantity_update, reverting to $_POST['quantity'] only if it exists.
|
321 |
+
* Fix: PHP strict warnings.
|
322 |
+
* Fix: Properly quote SKUs in CSV file.
|
323 |
+
* Fix: Rename generically named function.
|
324 |
+
* Fix: Stock and sale price empty values should be preserved.
|
325 |
+
* Fix: Variation thumbnail size in admin screen.
|
326 |
+
* Fix: cart is not initialized when some shipping modules are triggered
|
327 |
+
* Fix: redundant product thumbnail is displayed on category / single product list.
|
328 |
+
* Fix: variation checkbox column width in WP 3.7.
|
329 |
+
* Fix: Out of stock message for variations now correctly shows variation of product for the title, rather than main product.
|
330 |
+
* Fix: Use proper link in checkout for variation products.
|
331 |
+
* Fix: Return tax information in switchmethod() JS function.
|
332 |
+
* Fix: Resolve conflict with Advanced Custom Fields on save_post hook for products.
|
333 |
+
* Fix: Update Bulgarian Currency symbol.
|
334 |
+
* Fix: Resolve issue where updating pages causes rewrite rule conflicts when pretty permalinks are enabled.
|
335 |
+
|
336 |
+
= 3.8.12.1 =
|
337 |
+
* Fix: Fatal error in wpsc_product_list_exclude_child_categories() due to other themes
|
338 |
+
or plugins calling get_posts() before the main query is set up
|
339 |
+
|
340 |
+
= 3.8.12 =
|
341 |
+
* New: Filter to hide drafts on the front-end: "wpsc_product_display_status"
|
342 |
+
* New: Shipwire staging / production option
|
343 |
+
* Change: Remove deprecated and unused javascript (and by extension, CSS) from core
|
344 |
+
* Change: Remove nusoap
|
345 |
+
* Change: Improvements to Marketing admin panel
|
346 |
+
* Change: Improvements to Products List Admin Page
|
347 |
+
* Fix: WP eCommerce pagination breaks WordPress pagination
|
348 |
+
* Fix: Wrong thumbnail size in Product Specials widget
|
349 |
+
* Fix: Filtering by a category also shows all products in subcategories
|
350 |
+
* Fix: admin.js throwing a Parse Error in Safari
|
351 |
+
* Fix: Product Image Links not working when over HTTPS
|
352 |
+
* Fix: If AJAX_URL returns HTTPS and Add to Cart is on HTTP, errors
|
353 |
+
* Fix: Add to Cart button doesn't work
|
354 |
+
* Fix: Can no longer upload customer attachments
|
355 |
+
* Fix: Deprecated warning for wp_convert_bytes_to_hr() function in WordPress 3.6
|
356 |
+
|
357 |
+
|
358 |
+
= 3.8.11.1 =
|
359 |
+
* Fix: Some users had theme compatibilities and other configurations that caused "Add to Cart" to no longer function as expected.
|
360 |
+
* Fix: Customer uploads for products broke with JS overhaul
|
361 |
+
* Fix: Product image links broke.
|
362 |
+
|
363 |
+
= 3.8.11 =
|
364 |
+
* New: Payment Gateway UI is revamped.
|
365 |
+
* New: Sales Log UI is revamped.
|
366 |
+
* New: wpsc_single_purchase_log_date_time_format and wpsc_single_purchase_log_date_format (Used in new Sales Log UI).
|
367 |
+
* New: Added 'wpsc_usps_domestic_rate' and 'wpsc_usps_intl_rate' filters.
|
368 |
+
* New: 'wpsc_country_get_property' filter.
|
369 |
+
* New: WPSC_Country::get_data() method and 'wpsc_country_get_data' filter.
|
370 |
+
* New: Added generic 'wpsc_save_' . $this->current_tab_id . '_settings' action.
|
371 |
+
* New: 'wpsc_shipping_module_settings_form' filter on admin shipping module form output.
|
372 |
+
* New: Choose either AND or OR for coupon conditions logic.
|
373 |
+
* Change: Reduced internal usage of get_option( 'siteurl' ) in favor of home_url().
|
374 |
+
* Change: Updated Colorbox.js to v.1.4.15.
|
375 |
+
* Change: Eliminated internal usage of 'index.php' as an AJAX callback URL. Nginx users, rejoice.
|
376 |
+
* Change: Eliminated internal usage of eval() in javascript.
|
377 |
+
* Change: wpsc_get_country() uses WPSC_Country now.
|
378 |
+
* Change: .on() is now used in place of .livequery(), .bind(), .live() and .delegate().
|
379 |
+
* Change: Minor cleanup of Marketing settings tab UI.
|
380 |
+
* Change: wpsc_the_product_image() optimized to utilize the product thumbnail earlier in the function.
|
381 |
+
* Change: wpsc_the_variation_price() output is now filtered through wpsc_do_convert_price filter.
|
382 |
+
* Change: Submitted_Form_Data table now has a value field with a LONGTEXT data type, rather than varchar(255).
|
383 |
+
* Change: Continued internal cleanup of coding standards and documentation.
|
384 |
+
* Fix: Properly substitute placeholder in "Out of stock" email to administrator.
|
385 |
+
* Fix: Fixed PHP notices when accessing Dashboard as subscriber.
|
386 |
+
* Fix: Coupon logic improvements (edge case of using 'not_contains" logic with item_quantity).
|
387 |
+
* Fix: Automated fix when possible, and nag when not, for 3.8.10 regression in User Management templates.
|
388 |
+
* Fix: Error notices on category functions.
|
389 |
+
* Fix: fetch_feed() error on GetShopped news.
|
390 |
+
* Fix: Variation terms were not being applied to the parent product.
|
391 |
+
* Fix: If you emptied variation sale price, the stock levels would not work any more.
|
392 |
+
* Fix: A notice was thrown if you had UPS selected but had not saved settings for it.
|
393 |
+
* Fix: USPS Shipping Module now correctly respects testing environement settings.
|
394 |
+
* Fix: Correcting casting price value to float instead of integer in coupon logic conditions for sub_total.
|
395 |
+
* Fix: 'wpsc_transaction_result_content' now returns the $cart_item as an array instead of an object (which was a regression).
|
396 |
+
|
397 |
+
= 3.8.10 =
|
398 |
+
* New: Coupon UI is revamped.
|
399 |
+
* New: [Shipwire] Addition of Shipping Services, Economy, Plus & Premium.
|
400 |
+
* Change: After filling out a registration form, the user is logged in.
|
401 |
+
* Change: Limit quantity of individual products that can be added to the cart. Default value is filterable.
|
402 |
+
* Change: Remove FPDF which is not used any more.
|
403 |
+
* Change: Return cart item messages as key => value array rather than HTML.
|
404 |
+
* Change: Variation table class orderby to 'menu_order title'
|
405 |
+
* Change: When displaying packing slip, form data should be output in the same order as that of checkout page.
|
406 |
+
* Fix: "you save" prices are not correct on variations with a value over 1000
|
407 |
+
* Fix: Cart widget missing closing </div> tag.
|
408 |
+
* Fix: Display the "You save" price as a currency, not just a raw unformatted number
|
409 |
+
* Fix: Ensure all variations are deleted when deleting a product.
|
410 |
+
* Fix: Foreign characters are not displayed correctly in packing slip.
|
411 |
+
* Fix: Improved performance with variations.
|
412 |
+
* Fix: JavaScript error when no variations exist in admin.
|
413 |
+
* Fix: Make sure Add / Edit Product page respects decimal and thousands separators set in Settings->Store->General.
|
414 |
+
* Fix: Manual / Test Payment instructions don't appear on transaction results page and email.
|
415 |
+
* Fix: Only print Google Analytics scripts on transaction results footer
|
416 |
+
* Fix: PHP Warnings when bulk editing variations.
|
417 |
+
* Fix: Prevent old paypal express from hijacking new paypal express callback.
|
418 |
+
* Fix: Product category pages don't respect pagination and sort order settings.
|
419 |
+
* Fix: Re-generate products pages' IDs after plugin reactivation.
|
420 |
+
* Fix: Refactor user account page
|
421 |
+
* Fix: SQL IN error in wpsc_populate_also_bought_list().
|
422 |
+
* Fix: Switching a purchase log status to "Closed Order" doesn't reduce stocks.
|
423 |
+
* Fix: WPML compatibility
|
424 |
+
* Fix: Wrong cache set for checkout form data.
|
425 |
+
* Fix: split() deprecation notice in PHP 5.3+
|
426 |
+
* Fix: stripslashes issues when duplicating products.
|
427 |
+
|
428 |
+
= 3.8.9.5 =
|
429 |
+
* New: Polish translation.
|
430 |
+
* Fix: Attempt to regenerate customer ID if it's invalid to avoid fatal errors.
|
431 |
+
* Fix: Australia Post doesn't return any quotes if the products' dimensions are not specified.
|
432 |
+
* Fix: Billing state is set to shipping state upon checkout.
|
433 |
+
* Fix: Cannot resent purchase receipt any more.
|
434 |
+
* Fix: Custom Cart Messages on Sales Log need stripslashes.
|
435 |
+
* Fix: Error message when changing purchase log status via AJAX.
|
436 |
+
* Fix: Fatal error in merchant.class.php.
|
437 |
+
* Fix: Giving stock or price of a product a 4 figure number will screw it up when the product is updated again.
|
438 |
+
* Fix: Invalid zipcode is displayed even when the zipcode is not specified yet.
|
439 |
+
* Fix: Quick editing a product doesn't work.
|
440 |
+
* Fix: Transaction result emails are sent when an order is closed.
|
441 |
+
* Fix: More native css support for product variations in WP 3.5+.
|
442 |
+
|
443 |
+
= 3.8.9.4 =
|
444 |
+
* Fix: "No shipping quotes" error is displayed when selecting "Shipping same as billing".
|
445 |
+
* Fix: Avoid flooding transient data when site's feed is being visited by bots.
|
446 |
+
* Fix: Blank Checkout page for some certain installation when Shipping is enabled.
|
447 |
+
* Fix: Can't add to cart on some server.
|
448 |
+
* Fix: Fatal error when viewing product variation iframe, because _wp_admin_html_begin() does not exist on older WordPress versions.
|
449 |
+
* Fix: MySQL error/warning in _wpsc_filter_special_widget_where().
|
450 |
+
* Fix: Only show attachment fields when viewed on an edit product page.
|
451 |
+
* Fix: PHP Notice in cart.class.php.
|
452 |
+
* Fix: Properly escape columns in admin products page.
|
453 |
+
* Fix: Purchase log's item names are not translatable via qTranslate.
|
454 |
+
* Fix: Shipping same as billing saves "State" field label as the shipping region.
|
455 |
+
* Fix: Shipwire settings are not updated.
|
456 |
+
* Fix: Shipwire syncing doesn't take into consideration products in trash, or multiple products using the same SKUs (as in WPML)
|
457 |
+
* Fix: Specials widget is empty when there are no product with variation sales.
|
458 |
+
* Fix: Variation sets are not being sorted on the front-end.
|
459 |
+
* Fix: WPEC doesn't cooperate with WP 3.5 media UI.
|
460 |
+
* Fix: wpsc_pre_transaction_results filter is ignored.
|
461 |
+
* Make sure admin styles are enqueued for product variations iframe in older version of WordPress.
|
462 |
+
|
463 |
+
= 3.8.9.3 =
|
464 |
+
* New: Add support for quantity field in default grid view template.
|
465 |
+
* New: Let plugins add new column to product variation list table via filter 'wpsc_manage_product_variations_custom_column'.
|
466 |
+
* Fix: Blank transaction results page when using paypal gateways.
|
467 |
+
* Fix: Comment form is displayed even though comment is closed on products page.
|
468 |
+
* Fix: Fatal error in formatting.php for some sites.
|
469 |
+
* Fix: New countries in 3.8.9 automatically added to target market list.
|
470 |
+
* Fix: PayPal Standard doesnt' take care of coupons.
|
471 |
+
* Fix: Punctuation in pending transaction email.
|
472 |
+
|
473 |
+
= 3.8.9.2 =
|
474 |
+
* Fix: Admin cannot download file from product edit page.
|
475 |
+
* Fix: Compatibility issues with Jetpack.
|
476 |
+
* Fix: Google Analytics is printed out even when it's not active. Also, PHP notice when the product doesn't have a category.
|
477 |
+
* Fix: Make sure PayPal Standard works with 100% discount.
|
478 |
+
* Fix: Product page title is not properly replaced with the category or tag title in WP 3.5.
|
479 |
+
* Fix: Products are sometimes displayed even when products page is set to only display list of categories.
|
480 |
+
* Fix: Products thumbnail sizes are inconsistent with the settings.
|
481 |
+
* Fix: Properly flush outdated customer meta from the transient table.
|
482 |
+
* Fix: Typo in wpsc_cart::update_location().
|
483 |
+
* Fix: Wrong class attribute for price display.
|
484 |
+
|
485 |
+
= 3.8.9.1 =
|
486 |
+
* Fix: Fatal error in Shipwire.
|
487 |
+
* Fix: Fatal error with customer meta on multisite.
|
488 |
+
* Fix: Fatal error with get_the_product_tags().
|
489 |
+
* Fix: Pagination in admin product list doesn't work.
|
490 |
+
* Fix: Permalinks are incorrect when products page is set as home page and permalink scheme is set to %post_name%.
|
491 |
+
* Fix: Rewrite rules are not regenerated correctly when switching from "Default" to "Post name".
|
492 |
+
* Fix: Shipwire and Google Analytics are not working properly.
|
493 |
+
* Fix: Shipwire request is sent even when Shipwire is not active.
|
494 |
+
* Fix: States are displayed as numbers in admin purchase report.
|
495 |
+
* Fix: Transaction results displaying cart content twice as well as "Oops, there is nothing in your cart".
|
496 |
+
* Fix: Use customer meta instead of $_SESSION for eway and payflow message.
|
497 |
+
* Fix: Variation pagination doesn't work.
|
498 |
+
|
499 |
+
= 3.8.9 =
|
500 |
+
* New: Additional columns can now be added to Store Sales page via filter hook.
|
501 |
+
* New: Additional filters for purchase log notification classes.
|
502 |
+
* New: Allow devs to filter the list of accepted credit cards in PayPal Pro.
|
503 |
+
* New: Filters to enable image scaling (versus cropping).
|
504 |
+
* New: Hook to modify the product table on transaction results and purchase receipts.
|
505 |
+
* New: Make buy now button's html output filterable.
|
506 |
+
* New: More flexibility in role management.
|
507 |
+
* New: New Hook for cancelling subscriptions with Memebers Access.
|
508 |
+
* New: Pagination UI for product variations.
|
509 |
+
* New: Users can bulk edit products' stock, price, sales price etc.
|
510 |
+
* New: Users can now choose to "Notify site owner" and "Unpublish product" separately when stock runs out.
|
511 |
+
* New: Users can now delete checkout form sets.
|
512 |
+
* New: Users can now set product sorting direction in Settings->Presentation.
|
513 |
+
* New: Variation UI enhancements.
|
514 |
+
* Change: "Registration required" and "Anyone can register" are now synchronized.
|
515 |
+
* Change: Default checkout shipping option to lowest shipping cost of all choices.
|
516 |
+
* Fix: "Variation Controls" anchor in metabox leads nowhere.
|
517 |
+
* Fix: AJAX code audit (security)
|
518 |
+
* Fix: Activating WP eCommerce on a vanilla WordPress installation with pretty permalinks enabled messes up the rewrite rules.
|
519 |
+
* Fix: Add a space after tilde character to avoid confusion in admin product list.
|
520 |
+
* Fix: Add new variation sets and terms from Edit Product page doesn't work properly.
|
521 |
+
* Fix: Additional description is double escaped in product edit page.
|
522 |
+
* Fix: Alignment of checkboxes and radios in product category edit page is a bit off.
|
523 |
+
* Fix: Avoid using query_posts() which could break themes.
|
524 |
+
* Fix: Backslashes are sometimes added to UPS and USPS settings.
|
525 |
+
* Fix: Base_region option remains set if base country is switched.
|
526 |
+
* Fix: Billing phone number not accessible via wpsc_merchant::$cart_data.
|
527 |
+
* Fix: Buy Now feature doesn't properly create and update sales log.
|
528 |
+
* Fix: Can't add variations on new products.
|
529 |
+
* Fix: Can't delete coupon conditions.
|
530 |
+
* Fix: Can't order products properly in Products admin page.
|
531 |
+
* Fix: Can't upload product category image when adding a new category.
|
532 |
+
* Fix: Cannot set thumbnail for variations.
|
533 |
+
* Fix: Cart item name is not updated when corresponding variation name is changed.
|
534 |
+
* Fix: Cart items are not translated for qTranslate.
|
535 |
+
* Fix: Cart mix up when multisite is enabled.
|
536 |
+
* Fix: Category image size metadata are not used properly on templates.
|
537 |
+
* Fix: Category title is replaced with the first product's title, and pagination does not work correctly on Category page.
|
538 |
+
* Fix: Changing an order status in Sales Log page incorrectly updates the views and pagination links.
|
539 |
+
* Fix: Changing checkout field sort order doesn't work.
|
540 |
+
* Fix: Checkout- Parent Product Thumbnail Displayed Instead of Product Variation Thumbnail.
|
541 |
+
* Fix: Claimed stock cronjob doesn't take into consideration timezone.
|
542 |
+
* Fix: Collapse product variation sets by default on Manage tab.
|
543 |
+
* Fix: Colorbox Gallery doesn't work.
|
544 |
+
* Fix: Country dropdown lists disregard Target Market option.
|
545 |
+
* Fix: Coupon is not invalid is displayed even when there's no coupon applied.
|
546 |
+
* Fix: Coupon start and expiry date don't take into account local timezone.
|
547 |
+
* Fix: Currency converter doesn't work for some particular currencies.
|
548 |
+
* Fix: Custom fields are missing in purchase log if they have the same name as other fields.
|
549 |
+
* Fix: Customers are able able to purchase scheduled but unpublished products.
|
550 |
+
* Fix: Database upgrade routines.
|
551 |
+
* Fix: Division by zero in product-template.php.
|
552 |
+
* Fix: Dollar signs are used in flat rate settings regardless of the main currency.
|
553 |
+
* Fix: Duplicating a Product doesn't duplicate the images correctly.
|
554 |
+
* Fix: Email information in "Admin" settings tab is not displayed properly.
|
555 |
+
* Fix: Enabling shipping but not selecting any shipping methods causes frustrating unexpected issues.
|
556 |
+
* Fix: Fatal error in PayPal Pro settings page.
|
557 |
+
* Fix: Fatal error in checkout page form validation.
|
558 |
+
* Fix: Fatal error when quick editing products.
|
559 |
+
* Fix: Fatal error when upgrading from 3.7.x.
|
560 |
+
* Fix: Final breadcrumb id tag is not W3C Compliant.
|
561 |
+
* Fix: Free shipping discount is not updated when shipping method is changed.
|
562 |
+
* Fix: Free shipping doesn't reset individual cart items' shipping amounts when submitted to PayPal.
|
563 |
+
* Fix: Free-shipping doesn't work on PayPal Pro if the discount amount > item total.
|
564 |
+
* Fix: Google Analytics is now tracking correctly.
|
565 |
+
* Fix: Great Britain is redundant in country list (we already have U.K. and North Ireland).
|
566 |
+
* Fix: Improper escaping of user input.
|
567 |
+
* Fix: Inaccurate dimension calculation in Australia Post.
|
568 |
+
* Fix: Incompatibility with $_SESSION.
|
569 |
+
* Fix: Incorrect i18n in Presentation tab.
|
570 |
+
* Fix: Increase gateway timeout settings across the board.
|
571 |
+
* Fix: Inefficient pinging when product is updated.
|
572 |
+
* Fix: Infinite loop on single product page.
|
573 |
+
* Fix: Infinite loop when using PayPal Pro.
|
574 |
+
* Fix: Issue with SSL and Share This URL.
|
575 |
+
* Fix: Latest product widget doesn't show image.
|
576 |
+
* Fix: Logic error in function wpsc_product_has_stock.
|
577 |
+
* Fix: Make it clear that the sidebar widget doesn't include discount.
|
578 |
+
* Fix: More flexibility in role management.
|
579 |
+
* Fix: New coupon conditions are added below the first condition instead of the last.
|
580 |
+
* Fix: Number of products per page field in shortcode generator doesn't work.
|
581 |
+
* Fix: On user details page, switching country to a country without region won't display the State (Region) text field.
|
582 |
+
* Fix: Only display permalink double save warning if WordPress version is earlier than 3.3.
|
583 |
+
* Fix: Outdated country codes and currency codes.
|
584 |
+
* Fix: Pagination does not work with price range widget.
|
585 |
+
* Fix: Pagination for category short codes does not work.
|
586 |
+
* Fix: Pagination for tags does not work.
|
587 |
+
* Fix: Pagination links generated with unnecessary "page/" portion for WP 3.4.
|
588 |
+
* Fix: Pagination links in Category shortcode page are not consistent.
|
589 |
+
* Fix: Parent product is still treated as if it had variations even though all its variations have been moved to trash or hidden (set to draft).
|
590 |
+
* Fix: PayPal Express Checkout doesn't take into account free shipping.
|
591 |
+
* Fix: PayPal Standard Subscriptions produce unexpected product title in PayPal cart and receipts.
|
592 |
+
* Fix: Performance improvement for dynamic stylesheet.
|
593 |
+
* Fix: Placeholder image is missing for products without thumbnails.
|
594 |
+
* Fix: Potential height issue with variation edit iframe (parent hidden overflow, expand/collapse checkboxes).
|
595 |
+
* Fix: Prevent segmentation fault when using wpsc-products shortcode.
|
596 |
+
* Fix: Product Specials Widget does not work with product variations on sale.
|
597 |
+
* Fix: Product page URLs are sometimes not updated properly.
|
598 |
+
* Fix: Product permalinks in single product view are not using current category path.
|
599 |
+
* Fix: Products page pagination fails if the products page is set as the homepage.
|
600 |
+
* Fix: Products with variations on sale does not display the prices correctly.
|
601 |
+
* Fix: Purchase logs list table doesn't have Total line as before 3.8.8.
|
602 |
+
* Fix: Refactor purchase log notifications to fix various issues:
|
603 |
+
* Fix: Region field is not consistently updated or displayed when selecting a country without regions on checkout form.
|
604 |
+
* Fix: SKU should be sent to PayPal Standard instead of Product ID if that's available.
|
605 |
+
* Fix: Shipping error is reported when "Shipping same as billing" is selected on the checkout page, even when shipping is disabled.
|
606 |
+
* Fix: Shipping location error message is displayed before the customer has a chance to specify state and zip code.
|
607 |
+
* Fix: Shipping method and option are not displayed on Sales Log single page if there is no shipping form fields.
|
608 |
+
* Fix: Shipping options not refreshed when "shipping same as billing" causes new quotes.
|
609 |
+
* Fix: Shipping rate choice not correctly encoded during checkout.
|
610 |
+
* Fix: Shipwire settings are broken.
|
611 |
+
* Fix: Shortcode button doesn't work in visual mode if WP folder configuration is different from default.
|
612 |
+
* Fix: Table rate shipping doesn't accept $0 amount.
|
613 |
+
* Fix: Target makret restrictions for product categories is broken.
|
614 |
+
* Fix: Tax bands not working.
|
615 |
+
* Fix: Template tags for product tags don't work.
|
616 |
+
* Fix: Terms & Conditions validation code is broken.
|
617 |
+
* Fix: Total Price not properly reflective of the total after $1,000.
|
618 |
+
* Fix: Transaction results refactor.
|
619 |
+
* Fix: Updating purchase log status doesn't update pagination count
|
620 |
+
* Fix: Unnecessary thumbnail regeneration on product single page.
|
621 |
+
* Fix: Update message is displayed even when the db has bene updated.
|
622 |
+
* Fix: Updating region when "Same shipping as billing" is checked doesn't update the shipping quote.
|
623 |
+
* Fix: Use $cart_item->get_title() instead of $cart_item->product_name.
|
624 |
+
* Fix: Use array instead of strings when calling WP_Query in wpsc_the_variation_price.
|
625 |
+
* Fix: Users are now warned that setting products per row for grid view to 0 would probably lead to layout breakage.
|
626 |
+
* Fix: Using 2 checkout sets shows incorrect order on Purchase History and Your details pages.
|
627 |
+
* Fix: Valid checkout fields are not preserved when there are invalid fields.
|
628 |
+
* Fix: Variation drag'n'drop sorting is not working.
|
629 |
+
* Fix: Various bugs and inconsistencies with coupon conditions.
|
630 |
+
* Fix: WPEC loads product image then scales to thumbnail size in the backend products list.
|
631 |
+
* Fix: Weird Taxable Amount column.
|
632 |
+
* Fix: When "Free Shipping" is enabled in Settings->Shipping, shipping is always set to 0 even when shipping discount value is set to 0 or empty.
|
633 |
+
* Fix: Wrong alternate row class for variation inline shipping editor.
|
634 |
+
* Fix: Wrong documentation link for Chronopay.
|
635 |
+
* Fix: Wrong logic in deprecated function nzshpcrt_currency_display().
|
636 |
+
* Fix: _wpsc_process_transaction_coupon() contains typos.
|
637 |
+
* Fix: also bought image path is supposed to be fixed already.
|
638 |
+
* Fix: i18n audit.
|
639 |
+
* Fix: improper escaping in Price metabox.
|
640 |
+
* Fix: post_status is not formatted correctly in wpsc_start_the_query().
|
641 |
+
* Fix: private products are listed on the /products/ page.
|
642 |
+
* Fix: wpsc_list_dir() should return empty array if directory is empty.
|
643 |
+
* Fix: wpsc_shopping_cart() function call doesn't work.
|
644 |
+
* Fix: wpsc_the_product_thumbnail() ignores custom width and height.
|
645 |
+
|
646 |
+
= 3.8.8.5 =
|
647 |
+
* Fix: Order Closed status does not count in the sales log totals on dashboard widget.
|
648 |
+
* Fix: PHP preg_replace warning.
|
649 |
+
|
650 |
+
= 3.8.8.4 =
|
651 |
+
* Fix: Also bought product image doesn't display correctly.
|
652 |
+
* Fix: Pagination fails when hierarchical category URL is enabled.
|
653 |
+
* Fix: Product Specials Widget causes 404 errors. Props Chris Jean.
|
654 |
+
* Fix: Product category slug beginning with a digit doesn't work.
|
655 |
+
* Updated localization.
|
656 |
+
|
657 |
+
= 3.8.8.3 =
|
658 |
+
* Fix: Incompatibility between WPEC products page pagination and WordPress 3.4.
|
659 |
+
|
660 |
+
= 3.8.8.2 =
|
661 |
+
* Change: CSV sales export now puts the item quanity in a separate column from the product title.
|
662 |
+
* Fix: Core checkout fields cannot be restored if they were deleted before upgrading to 3.8.8.
|
663 |
+
* Fix: Insecure SSL resources when WordPress is using SSL, or "Force SSL Checkout" is enabled.
|
664 |
+
* Fix: Issue with WPML and Variations.
|
665 |
+
* Fix: Shipping & Total Order values are wrong on Sales Log page.
|
666 |
+
* Fix: Terms and Conditions - Checkout page breaks if you read the terms and conditions.
|
667 |
+
* Fix: Total shipping value and total price incorrect in transaction results.
|
668 |
+
* Fix: Variation sales prices are inaccurate in Product Specials Widget
|
669 |
+
|
670 |
+
= 3.8.8.1 =
|
671 |
+
* Fix: CSV import not working in 3.8.8.
|
672 |
+
* Fix: Category page display setting does not override default Presentation settings.
|
673 |
+
* Fix: Clicking All/None in Category target market settings doesn't work.
|
674 |
+
* Fix: Non-SSL stylesheet is loaded even when force SSL for checkout page is on.
|
675 |
+
* Fix: PHP Warning and Notice in sales log page.
|
676 |
+
* Fix: PayPal currency converter is wrong.
|
677 |
+
* Fix: Sales logs are not displayed for some installations.
|
678 |
+
* Fix: Sales logs page sometimes display empty customers' names.
|
679 |
+
* Fix: Saving payment gateway settings erase Shipping settings.
|
680 |
+
* Fix: Sometimes clicking Save doesn't save tracking ID on sales log page.
|
681 |
+
|
682 |
+
= 3.8.8 =
|
683 |
+
* New: Actions for bulk actions on sales page: wpsc_sales_log_process_bulk_action, wpsc_sales_log_extra_tablenav
|
684 |
+
* New: Allow variation checkboxes to be collapsed & expanded without having to tick the variation set checkbox itself.
|
685 |
+
* New: Digital Download UI improvement.
|
686 |
+
* 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
|
687 |
+
* New: Filter for ordering the sales logs: wpsc_purchase_logs_orderby.
|
688 |
+
* New: Filter wpsc_cart_shipping.
|
689 |
+
* New: Filter wpsc_default_shipping_quote.
|
690 |
+
* New: Filter wpsc_item_shipping_amount_db.
|
691 |
+
* New: Filter wpsc_paypal_standard_post_data.
|
692 |
+
* New: Filter wpsc_product_permalink_cat_slug.
|
693 |
+
* New: Filter wpsc_product_postage_and_packaging.
|
694 |
+
* New: Filter wpsc_shipping_quote_value.
|
695 |
+
* New: Filters wpsc_calculate_total_tax, wpsc_coupons_amount.
|
696 |
+
* New: 4 new filters for user meta in profile page and during checkout.class.php - wpsc_checkout_user_profile_get - wpsc_checkout_user_profile_update - wpsc_user_log_get - wpsc_user_log_update.
|
697 |
+
* New: Settings Page API.
|
698 |
+
* 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
|
699 |
+
* New: Variation Drag & Drop sorting.
|
700 |
+
* Change: Display file names instead of the product name on the downloads page.
|
701 |
+
* Change: Improved variation UI in Product Edit page.
|
702 |
+
* Change: In General Settings page, when changing country, load region / state list using AJAX instead of page reload.
|
703 |
+
* Change: Only display variants' associated terms in Product Edit page rather than including the parent product name, which is redundant and cluttered.
|
704 |
+
* Change: PayPal Standard settings now just offer dropdown of "live" / "sandbox" rather than URL entry.
|
705 |
+
* Change: Subtle UX tweaks for Store Settings page.
|
706 |
+
* Fix: %-based shipping cost is not working internationally.
|
707 |
+
* Fix: $wpsc_query->query_vars['wpsc_product_category'] not always set on product page with hierarchical category permalinks.
|
708 |
+
* Fix: Cannot add new Checkout field.
|
709 |
+
* Fix: Cannot re-re-send buyer receipt.
|
710 |
+
* Fix: 3.7 -> 3.8 Database Upgrade Routine causes some products with variations to display a $0.00 price.
|
711 |
+
* Fix: Double <p> tag with wpec_taxes_display_tax_bands() on product edit page.
|
712 |
+
* Fix: Fatal error when trying to include a non-existent admin file.
|
713 |
+
* Fix: Hide Google Feed information from display
|
714 |
+
* Fix: Incompatibility with Genesis framework in Product Edit page.
|
715 |
+
* Fix: Make the WP eCommerce 3.8.x activation/installation routine much more efficient.
|
716 |
+
* Fix: Mandatory fields in user_log_functions.php are not properly validated.
|
717 |
+
* Fix: Memory improvement for productfeed.
|
718 |
+
* Fix: Purchase logs have incorrect time if a timezone is specified in Settings->General.
|
719 |
+
* Fix: Summary line does not get updated when sales log status is changed.
|
720 |
+
* Fix: Total Quantity check fails for coupon codes.
|
721 |
+
* Fix: USPS: "FLATE RATE ENVELOPE" should be changed to "VARIABLE" to allow for shipping quotes to be based on weight.
|
722 |
+
* Fix: Use ->add_help_tab() to support WP 3.3 admin screen API.
|
723 |
+
* Fix: Using discount causes Paypal Express to calculate wrong total amount.
|
724 |
+
* Fix: get_the_content() is not enough in product feed.
|
725 |
+
* Fix: settings page JS compatibility issue with Firefox.
|
726 |
+
* Fix: wpsc_get_template_file_url() function is inefficient and causes 10 extra SQL queries per page load.
|
727 |
+
|
728 |
+
= 3.8.7.6.1 =
|
729 |
+
* Fix: PHP Warning for 'wpsc_load_settings_page' callback.
|
730 |
+
* Fix: PHP Warning in wpsc-transaction_results_functions.php.
|
731 |
+
* Fix: get_current_screen() is not available in WP 3.0.
|
732 |
+
|
733 |
+
= 3.8.7.6 =
|
734 |
+
* New: Default hook to filter sessionid for previously selected payment gateways.
|
735 |
+
* Change: Stock notification emails are now sent to "purchase log email address" rather than admin address.
|
736 |
+
* Fix: SQL injection vulnerability.
|
737 |
+
* Fix: 3.7 -> 3.8 Database Upgrade Routine fails when importing variations sets with the same name.
|
738 |
+
* Fix: Category link structure is not correct in pagination links with hierarchical category permalink.
|
739 |
+
* Fix: Fix SQL error when using "?items_per_page=all" query.
|
740 |
+
* Fix: Missing "Use as product thumbnail" on WordPress 3.3.
|
741 |
+
* Fix: Products Page does not support custom page template - uses page.php instead.
|
742 |
+
* Fix: Products page, category items per page is broken, relies on 'posts per page' setting in Settings -> reading.
|
743 |
+
* Fix: Sticky post view broken due to deprecated query_string filter.
|
744 |
+
* Fix: Sub-pages of Products Page aren't supported.
|
745 |
+
* Fix: Total Quantity check for coupons.
|
746 |
+
* Fix: Use ->add_help_tab() to support WP 3.3 admin screen API.
|
747 |
+
* Fix: [wpsc_products] shortcode does not use 'Sort Product By' setting - it defaults to date-based ordering.
|
748 |
+
* Fix: dashboard.css is loaded for WordPress > 3.3 (404 error).
|
749 |
+
|
750 |
+
= 3.8.7.5 =
|
751 |
+
* Fix XSS vulnerability.
|
752 |
+
|
753 |
+
= 3.8.7.4 =
|
754 |
+
* Fix: "Session expired" error when viewing Customer Account page.
|
755 |
+
|
756 |
+
= 3.8.7.3 =
|
757 |
+
* Security fixes.
|
758 |
+
|
759 |
+
= 3.8.7.2 =
|
760 |
+
* New: Support for g:availability to Google Merchant Centre feed. Props bbaskets & longercat
|
761 |
+
* Fix: Admin product page sorting by column was not working.
|
762 |
+
* Fix: Call to undefined function wpsc_clear_stock_claims().
|
763 |
+
* Fix: Checkbox and Radio buttons have unexpected issues in checkout.
|
764 |
+
* Fix: Checkout field options' values are mutilated before getting inserted into the database.
|
765 |
+
* Fix: PayPal standard IPN fails if data used to validate the IPN POST contains ' or ".
|
766 |
+
* Fix: Price incorrectly updated when multiple products with variations exist on the same page.
|
767 |
+
* Fix: Security vulnerability.
|
768 |
+
* Fix: ShareThis integration does not properl respect HTTPS connections.
|
769 |
+
* Fix: The Terms and conditions checkbox on the checkout page should have a required field asterisk, just like all other required checkout fields do.
|
770 |
+
* Fix: Wrong login URL for [userlog] page.
|
771 |
+
* Fix: Zero shipping price doesn't work in flatrate.php.
|
772 |
+
* Fix: invalid HTML on checkout page for default theme.
|
773 |
+
* Fix: wpsc_coupons::uses_coupons() needs optimization.
|
774 |
+
|
775 |
+
= 3.8.7.1 =
|
776 |
+
* Fix: Fancy notifications not being displayed on single product page.
|
777 |
+
* Fix: Sale and normal prices are switched around.
|
778 |
+
|
779 |
+
= 3.8.7 =
|
780 |
+
* New: 'insert_child_product_meta' filter to allow customising of meta data when a variation product (child product) is created.
|
781 |
+
* New: 'wpsc_variation_groups' and 'wpsc_all_associated_variations' filters. Allows customising order of variation menu items etc.
|
782 |
+
* New: Add hook "wpsc_product_form_fields_end" and rename "wpsc_product_form_fields" to "wpsc_product_form_fields_begin" to offer more flexibility when adding new fields to the product form.
|
783 |
+
* New: Add hooks "wpsc_add_to_cart_button_form_begin" and "wpsc_add_to_cart_button_form_end" when outputting [add_to_cart] shortcode. wpsc_add_to_cart_button() is also refactored to get rid of ugly repetitive "$output .= ".
|
784 |
+
* New: Additional hooks for adding extra FORM fields to the add to cart form.
|
785 |
+
* New: Additional filter hooks for product price and transaction result messages.
|
786 |
+
* New: Allow hierarchical product category URL.
|
787 |
+
* New: Hooks 'wpsc_product_form_fields_begin' and 'wpsc_product_form_fields_end' for list and grid views.
|
788 |
+
* New: Option to set claimed stock clearance interval (Store Settings -> General).
|
789 |
+
* New: filterable g:shipping_weight to google product feed. Thanks to Rudy Hassall.
|
790 |
+
* Change: Proper post updated messages - now says "Product updated" instead or "Post updated".
|
791 |
+
* Change: Settings tabs are restyled to conform with WordPress UI. Props Pippin.
|
792 |
+
* Fix: A product is displayed as "sold out" when its variations' stock control options are turned off.
|
793 |
+
* Fix: Additional Checkout Form Fields Not Showing with Variation. Props jRayx.
|
794 |
+
* Fix: Australia Post shipping quote caching by reducing the transient key length from 51 to 41 characters.
|
795 |
+
* Fix: AJAX error when changing country with a coupon applied.
|
796 |
+
* Fix: Breadcrumbs not showing for empty product categories.
|
797 |
+
* Fix: Discounts / coupons not passing to Paypal Standard.
|
798 |
+
* Fix: Error with merging image metadata in Media popup. Props Ben Huson.
|
799 |
+
* Fix: Fancy notifications are sometimes output twice.
|
800 |
+
* Fix: Fatal memory allocation error in Add Product page when WPEC downloadable folder is not created yet.
|
801 |
+
* Fix: Incompatibility with WP 3.3-dev (dashboard.css is merged into wp-admin.css).
|
802 |
+
* Fix: JavaScript globals not properly escaped, causing fatal JS errors due to internationalized strings that have single quotes in them.
|
803 |
+
* Fix: Paypal Express Checkout fails if product names contain unicode special characters.
|
804 |
+
* Fix: Paypal Standard passes wrong discount amount.
|
805 |
+
* Fix: PHP Notice when activating wpec, resulting in 'unexpected output' error message.
|
806 |
+
* Fix: PHP Notice when editing product category.
|
807 |
+
* Fix: PHP notice in wpsc-functions.php.
|
808 |
+
* Fix: Product categories sometimes disappear in admin (but still show on front end).
|
809 |
+
* Fix: Product variations not deleted when deleting a product from the trash.
|
810 |
+
* Fix: Products with variations display 'from' even if all prices are the same. Change: Product that have variations will display "from" price regardless of whether the variations are in stock or not (to avoid inconsistency).
|
811 |
+
* Fix: Removing additional description of a product doesn't have any effect. Props groques.
|
812 |
+
* Fix: SQL error when updating from 3.7.
|
813 |
+
* Fix: Saving thumbnail settings caused PHP timeout.
|
814 |
+
* Fix: Single product image is not re-generated properly sometimes.
|
815 |
+
* Fix: User submitted data is double-escaped, causing slashes to be stored in database table and sent to payment gateways.
|
816 |
+
* Fix: Variations are not cloned properly when duplicating a product, causing error / hang in wp-admin.
|
817 |
+
* Fix: WP Menus items don't apply current-menu-item (and ancestor) for product categories.
|
818 |
+
* Fix: When on the edit products page, the filter by category menu does not show subcategories if the parent has no products. Props benjaminhuson.
|
819 |
+
* Fix: for paypal express, coupons being included when there are none
|
820 |
+
* Fix: is_home() is true when viewing default category on products page.
|
821 |
+
* Fix: login redirect on checkout page if WordPress files are in a subfolder.
|
822 |
+
* Fix: $wpsc_cart->use_shipping() returns true even when shipping is disabled.
|
823 |
+
* Fix: wpsc_display_purchlog_totalprice() returns wrong value. Props dlingren for initial patch.
|
824 |
+
* Fix: wpsc_is_single_product() returns false even when viewing a single product. Props Ben Huson for initial patch.
|
825 |
+
* Fix: wpsc_the_product_thumbnail() sometimes returns relative URL instead of absolute URL, which causes image failure in Google Product Feed.
|
826 |
+
|
827 |
+
|
828 |
+
= 3.8.6.1 =
|
829 |
+
* Fix: Security vulnerability in chronopay.
|
830 |
+
|
831 |
+
= 3.8.6 =
|
832 |
+
* New: Filter for 'wpsc_display_product_multicurrency'.
|
833 |
+
* New: Additional filters for compatibility with WPML.
|
834 |
+
* Change: Discount information is now displayed on the Packing Slip.
|
835 |
+
* Fix: Sometimes wpsc_product_has_multicurrency() returns true when it should return false.
|
836 |
+
* Fix: Edit product page makes many database queries if you have lots of variations.
|
837 |
+
* Fix: Variation prices are not calculated correctly.
|
838 |
+
* Fix: Request-URI Too Large error when searching on the Admin Products page with lots of products.
|
839 |
+
* Fix: Add to cart shortcode doesn't display fancy notifications, and also doesn't check whether variations are selected.
|
840 |
+
* Fix: Infinite AJAX loop on checkout page when Same as Billing is checked.
|
841 |
+
* Fix: Per-item shipping total is calculated incorrectly in various places (Packing Slip, Sales Report etc.).
|
842 |
+
* Fix: Wrong product link when the product is assigned multiple categories.
|
843 |
+
* Fix: Canonical tags are not generated correctly for products with multiple categories.
|
844 |
+
* Fix: Edit variations inline messes up columns when stock limitation is disabled.
|
845 |
+
* Fix: Product with no category selected is not automatically assigned a default category when sort by drag&drop is enabled.
|
846 |
+
* Fix: Unnecessary use of livequery in variations.js causes Product edit page to freeze when there are many variation sets.
|
847 |
+
* Fix: Slashes added to checkout form field that has single quotes in it (e.g: O\'Connor).
|
848 |
+
* Fix: Multicurrency price is truncated when displayed.
|
849 |
+
* Fix: Checkout page keeps refreshing without displaying Google Checkout Button.
|
850 |
+
* Fix: Discount doesn't work with Paypal Standard.
|
851 |
+
* Fix: wpsc_single_template is not removed from the_content after it's run, causing subsequent the_content() calls to output the single product again.
|
852 |
+
* Fix: Sorting product categories is broken.
|
853 |
+
* Fix: Coupon rule "In Category" not taken into consideration.
|
854 |
+
* Fix: WPEC default stylesheet imposes #content font-size.
|
855 |
+
* Fix: Incompatibility with Prototype JS library.
|
856 |
+
* Fix: Checking (or unchecking) Stock checkbox when editing product causes variation table columns to break.
|
857 |
+
* Fix: jQuery 1.6 incompatibility with attr( 'className' ).
|
858 |
+
|
859 |
+
== Frequently Asked Questions ==
|
860 |
+
|
861 |
+
= How do I customize WP eCommerce =
|
862 |
+
|
863 |
+
First of all, you should check out the Presentation settings which are in the Settings -> Store page.
|
864 |
+
|
865 |
+
For advanced users, all of our eCommerce templates and CSS can be moved into your active theme folder for customization. Less advanced users have [several fantastic WP eCommerce consultants](https://wpecommerce.org/hire-an-expert/) to get help from.
|
866 |
+
|
867 |
+
= What payment gateways does WP eCommerce integrate with? =
|
868 |
+
|
869 |
+
Our [Gold Cart plugin](https://wpecommerce.org/store/premium-plugins/gold-cart/) contains nearly a dozen payment gateway options, including Authorize.net, LinkPoint and DPS. Our [Mirijeh integration plugin](https://wpecommerce.org/store/premium-plugins/mijireh-99-payment-gateways-pack/) provides access to nearly one hundred different gateway options. Beyond that, we have individual integration plugins for [Braintree](https://wpecommerce.org/store/premium-plugins/braintree-payment-gateway/), [Stripe](https://wpecommerce.org/store/premium-plugins/stripe/), [Authorize.net SIM](https://wpecommerce.org/store/premium-plugins/authorize-net-sim-payment-gateway-for-wordpress/) and more.
|
870 |
+
|
871 |
+
= I want to integrate a payment gateway that you don't support. Can you help with that? =
|
872 |
+
|
873 |
+
Absolutely! We have a [growing list of trusted consultants](https://wpecommerce.org/hire-an-expert/) who would be happy to partner with you to build a custom gateway. Alternatively, you're more than welcome to request that we build it as a plugin or part of our core plugin. The more requests we get, the more likely we are to build it. If you happen to be a talented developer, we have a great documentation site with helpful information on building payment gateways
|
874 |
+
|
875 |
+
= Which couriers does the plugin integrate with? =
|
876 |
+
|
877 |
+
We have table rate, weight rate and flat rate shipping calculators.
|
878 |
+
|
879 |
+
We also currently integrate with UPS, USPS, Australia Post and Shipwire for real-time shipping rates. We have a premium plugin for [FedEx](https://wpecommerce.org/store/premium-plugins/fedex-shipping-module/) as well.
|
880 |
+
|
881 |
+
= Which multi-lingual plugins is WP eCommerce compatible with? =
|
882 |
+
|
883 |
+
We currently provide basic support for WPML and qTranslate. We're excited about an up-and-coming multi-lingual project called [Babble](https://github.com/cftp/babble). We intend to fully and canonically support Babble as our primary multi-lingual partner in releases to come.
|
884 |
+
|
885 |
+
= Which additional modules are available for use with WP eCommerce? =
|
886 |
+
|
887 |
+
* [Gold Cart](https://wpecommerce.org/store/premium-plugins/gold-cart/) - adds more options, gateways and functionality to your store
|
888 |
+
* [MP3 Audio Player](https://wpecommerce.org/store/premium-plugins/mp3-player-plugin/) - Preview audio clips on your website
|
889 |
+
* [NextGen Gallery Buy Now Buttons](https://wpecommerce.org/store/premium-plugins/nextgen-gallery-buy-now-buttons/) - turns your NextGen gallery into an eCommerce solution
|
890 |
+
* [Members Plugin](https://wpecommerce.org/store/premium-plugins/membership-subscriptions/) - Integrates with PayPal Standard and Authorize.Net, allows you to create a Subscription-Based Product, as well as a "Members-Only" website with paid access to restricted content.
|
891 |
+
|
892 |
+
= How do you provide support? =
|
893 |
+
|
894 |
+
For users who have purchased a premium plugin from us (or a have purchased a [premium support token](https://wpecommerce.org/store/premium-plugins/premium-support-token/)), we offer high-touch, 1-on-1 support from our trained support staff. If you submit a support request here, you'll get a helpful response within 24 hours or less (during business hours).
|
895 |
+
|
896 |
+
For the rest of our users, we do our best to monitor the WordPress.org support forums and respond in as timely a manner as we are able. We appreciate the countless helpful volunteers who also take time to respond to forum posts here.
|
897 |
+
|
898 |
+
== Screenshots ==
|
899 |
+
|
900 |
+
1. Products list in WordPress backend
|
901 |
+
2. Edit Product screen
|
902 |
+
3. Single product page
|
903 |
+
4. Checkout page
|
904 |
+
|
905 |
+
== Upgrade Notice ==
|
906 |
+
|
907 |
+
= 3.8.1 =
|
908 |
+
This version addresses several urgent issues when upgrading from 3.7.x to 3.8.
|
trunk/screenshot-1.png
ADDED
Binary file
|
trunk/screenshot-2.png
ADDED
Binary file
|
trunk/screenshot-3.png
ADDED
Binary file
|
trunk/screenshot-4.png
ADDED
Binary file
|
trunk/wp-shopping-cart.php
ADDED
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WP eCommerce
|
4 |
+
* Plugin URI: http://wpecommerce.org/
|
5 |
+
* Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
|
6 |
+
* Version: 3.11.5
|
7 |
+
* Author: WP eCommerce
|
8 |
+
* Author URI: http://wpecommerce.org/
|
9 |
+
* Text Domain: wp-e-commerce
|
10 |
+
**/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* WP_eCommerce
|
14 |
+
*
|
15 |
+
* Main WPEC Plugin Class
|
16 |
+
*
|
17 |
+
* @package wp-e-commerce
|
18 |
+
*/
|
19 |
+
class WP_eCommerce {
|
20 |
+
private $components = array(
|
21 |
+
'merchant' => array(),
|
22 |
+
'marketplace' => array(),
|
23 |
+
'theme-engine' => array(),
|
24 |
+
);
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Start WPEC on plugins loaded
|
28 |
+
*
|
29 |
+
* @uses add_action() Attaches to 'plugins_loaded' hook
|
30 |
+
* @uses add_filter() Attaches to 'wpsc_components' hook
|
31 |
+
*/
|
32 |
+
public function __construct() {
|
33 |
+
add_action( 'plugins_loaded' , array( $this, 'init' ), 8 );
|
34 |
+
add_filter( 'wpsc_components', array( $this, '_register_core_components' ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Takes care of loading up WPEC
|
39 |
+
*
|
40 |
+
* @uses WP_eCommerce::start() Initializes basic WPEC constants
|
41 |
+
* @uses WP_eCommerce::constants() Setup WPEC core constants
|
42 |
+
* @uses WP_eCommerce::includes() Includes the WPEC files
|
43 |
+
* @uses WP_eCommerce::load() Setup WPEC Core
|
44 |
+
* @uses do_action() Calls 'wpsc_pre_init' which runs before WPEC initializes
|
45 |
+
* @uses do_action() Calls 'wpsc_init' runs just after WPEC initializes
|
46 |
+
*/
|
47 |
+
public function init() {
|
48 |
+
// Previous to initializing
|
49 |
+
do_action( 'wpsc_pre_init' );
|
50 |
+
// Initialize
|
51 |
+
$this->start();
|
52 |
+
$this->constants();
|
53 |
+
$this->includes();
|
54 |
+
$this->load();
|
55 |
+
|
56 |
+
// Finished initializing
|
57 |
+
do_action( 'wpsc_init' );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* New WPSC components API.
|
62 |
+
*
|
63 |
+
* Allows for modular coupling of different functionalities within WPSC.
|
64 |
+
* This is the way we'll be introducing cutting-edge APIs.
|
65 |
+
*
|
66 |
+
* @since 3.8.9.5
|
67 |
+
*
|
68 |
+
* @param array $components
|
69 |
+
* @return array $components
|
70 |
+
*/
|
71 |
+
public function _register_core_components( $components ) {
|
72 |
+
$components['merchant']['core-v2'] = array(
|
73 |
+
'title' => __( 'WP eCommerce Merchant API v2', 'wp-e-commerce' ),
|
74 |
+
'includes' =>
|
75 |
+
WPSC_FILE_PATH . '/wpsc-components/merchant-core-v2/merchant-core-v2.php'
|
76 |
+
);
|
77 |
+
|
78 |
+
$components['merchant']['core-v3'] = array(
|
79 |
+
'title' => __( 'WP eCommerce Merchant API v3', 'wp-e-commerce' ),
|
80 |
+
'includes' =>
|
81 |
+
WPSC_FILE_PATH . '/wpsc-components/merchant-core-v3/merchant-core-v3.php'
|
82 |
+
);
|
83 |
+
|
84 |
+
$components['marketplace']['core-v1'] = array(
|
85 |
+
'title' => __( 'WP eCommerce Marketplace API v1', 'wp-e-commerce' ),
|
86 |
+
'includes' =>
|
87 |
+
WPSC_FILE_PATH . '/wpsc-components/marketplace-core-v1/marketplace-core-v1.php'
|
88 |
+
);
|
89 |
+
|
90 |
+
$components['fancy-notifications']['fancy-notifications-v1'] = array(
|
91 |
+
'title' => __( 'Fancy Notifications v1', 'wpsc' ),
|
92 |
+
'includes' => WPSC_FILE_PATH . '/wpsc-components/fancy-notifications/fancy-notifications.php'
|
93 |
+
);
|
94 |
+
|
95 |
+
return $components;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Initialize the basic WP eCommerce constants
|
100 |
+
*
|
101 |
+
* @uses plugins_url() Retrieves url to plugins directory
|
102 |
+
* @uses load_plugin_textdomain() Loads plugin transations strings
|
103 |
+
* @uses plugin_basename() Gets the basename of a plugin (extracts the name of a plugin from its filename)
|
104 |
+
* @uses do_action() Calls 'wpsc_started' which runs after WPEC has started
|
105 |
+
*/
|
106 |
+
public function start() {
|
107 |
+
// Set the core file path
|
108 |
+
define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
|
109 |
+
|
110 |
+
// Define the path to the plugin folder
|
111 |
+
define( 'WPSC_DIR_NAME', basename( WPSC_FILE_PATH ) );
|
112 |
+
define( 'WPSC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
113 |
+
|
114 |
+
// Define the URL to the plugin folder
|
115 |
+
define( 'WPSC_FOLDER', dirname( WPSC_PLUGIN_BASENAME ) );
|
116 |
+
define( 'WPSC_URL', plugins_url( '', __FILE__ ) );
|
117 |
+
|
118 |
+
add_filter( 'load_textdomain_mofile', array( $this, 'load_old_textdomain' ), 10, 2 );
|
119 |
+
|
120 |
+
//load text domain
|
121 |
+
if ( ! load_plugin_textdomain( 'wp-e-commerce', false, '../languages/' ) ) {
|
122 |
+
load_plugin_textdomain( 'wp-e-commerce', false, dirname( WPSC_PLUGIN_BASENAME ) . '/wpsc-languages/' );
|
123 |
+
}
|
124 |
+
|
125 |
+
// Finished starting
|
126 |
+
do_action( 'wpsc_started' );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Load a .mo file for the old textdomain if one exists
|
131 |
+
* Necessary to maintain backwards compatibility after changing text-domains.
|
132 |
+
*
|
133 |
+
* @since 3.11.0
|
134 |
+
* @link: https://github.com/10up/grunt-wp-plugin/issues/21#issuecomment-62003284
|
135 |
+
*/
|
136 |
+
public function load_old_textdomain( $mofile, $textdomain ) {
|
137 |
+
if ( $textdomain === 'wp-e-commerce' && ! file_exists( $mofile ) ) {
|
138 |
+
$mofile = dirname( $mofile ) . DIRECTORY_SEPARATOR . str_replace( $textdomain, 'wpsc', basename( $mofile ) );
|
139 |
+
}
|
140 |
+
return $mofile;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Sets table names as WPDB properties.
|
145 |
+
*
|
146 |
+
* @since 4.0.0
|
147 |
+
* @return array Array of custom tables
|
148 |
+
*/
|
149 |
+
public function setup_table_names() {
|
150 |
+
global $wpdb;
|
151 |
+
|
152 |
+
$wpdb->wpsc_meta = WPSC_TABLE_META;
|
153 |
+
$wpdb->wpsc_also_bought = WPSC_TABLE_ALSO_BOUGHT;
|
154 |
+
$wpdb->wpsc_region_tax = WPSC_TABLE_REGION_TAX;
|
155 |
+
$wpdb->wpsc_coupon_codes = WPSC_TABLE_COUPON_CODES;
|
156 |
+
$wpdb->wpsc_cart_contents = WPSC_TABLE_CART_CONTENTS;
|
157 |
+
$wpdb->wpsc_claimed_stock = WPSC_TABLE_CLAIMED_STOCK;
|
158 |
+
$wpdb->wpsc_currency_list = WPSC_TABLE_CURRENCY_LIST;
|
159 |
+
$wpdb->wpsc_purchase_logs = WPSC_TABLE_PURCHASE_LOGS;
|
160 |
+
$wpdb->wpsc_checkout_forms = WPSC_TABLE_CHECKOUT_FORMS;
|
161 |
+
$wpdb->wpsc_product_rating = WPSC_TABLE_PRODUCT_RATING;
|
162 |
+
$wpdb->wpsc_download_status = WPSC_TABLE_DOWNLOAD_STATUS;
|
163 |
+
$wpdb->wpsc_submitted_form_data = WPSC_TABLE_SUBMITTED_FORM_DATA;
|
164 |
+
$wpdb->wpsc_cart_itemmeta = WPSC_TABLE_CART_ITEM_META;
|
165 |
+
$wpdb->wpsc_purchasemeta = WPSC_TABLE_PURCHASE_META;
|
166 |
+
$wpdb->wpsc_visitors = WPSC_TABLE_VISITORS;
|
167 |
+
$wpdb->wpsc_visitormeta = WPSC_TABLE_VISITOR_META;
|
168 |
+
|
169 |
+
return array(
|
170 |
+
$wpdb->wpsc_meta ,
|
171 |
+
$wpdb->wpsc_also_bought ,
|
172 |
+
$wpdb->wpsc_region_tax ,
|
173 |
+
$wpdb->wpsc_coupon_codes ,
|
174 |
+
$wpdb->wpsc_cart_contents ,
|
175 |
+
$wpdb->wpsc_claimed_stock ,
|
176 |
+
$wpdb->wpsc_currency_list ,
|
177 |
+
$wpdb->wpsc_purchase_logs ,
|
178 |
+
$wpdb->wpsc_checkout_forms ,
|
179 |
+
$wpdb->wpsc_product_rating ,
|
180 |
+
$wpdb->wpsc_download_status ,
|
181 |
+
$wpdb->wpsc_submitted_form_data,
|
182 |
+
$wpdb->wpsc_cart_itemmeta ,
|
183 |
+
$wpdb->wpsc_purchasemeta ,
|
184 |
+
$wpdb->wpsc_visitors ,
|
185 |
+
$wpdb->wpsc_visitormeta ,
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Setup the WPEC core constants
|
191 |
+
*
|
192 |
+
* @uses wpsc_core_constants() Loads the WPEC Core constants
|
193 |
+
* @uses wpsc_core_is_multisite() Checks if this is a multisite install. True if is multisite
|
194 |
+
* @uses wpsc_core_load_session() Loads the WPEC core session
|
195 |
+
* @uses wpsc_core_constants_version_processing() Checks and sets a constant for WordPress version
|
196 |
+
* @uses wpsc_core_constants_table_names() Sets constants for WPEC table names
|
197 |
+
* @uses wpsc_core_constants_uploads() Set the upload related constants
|
198 |
+
* @uses do_action() Calls 'wpsc_constants' which runs after the WPEC constants are defined
|
199 |
+
*/
|
200 |
+
public function constants() {
|
201 |
+
// Define globals and constants used by wp-e-commerce
|
202 |
+
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-constants.php' );
|
203 |
+
|
204 |
+
// Load the WPEC core constants
|
205 |
+
wpsc_core_constants();
|
206 |
+
|
207 |
+
// Is WordPress Multisite
|
208 |
+
wpsc_core_is_multisite();
|
209 |
+
|
210 |
+
// Start the wpsc session
|
211 |
+
wpsc_core_load_session();
|
212 |
+
|
213 |
+
// Which version of WPEC
|
214 |
+
wpsc_core_constants_version_processing();
|
215 |
+
|
216 |
+
// WPEC Table names and related constants
|
217 |
+
wpsc_core_constants_table_names();
|
218 |
+
|
219 |
+
// setup wpdb table name attributes
|
220 |
+
$this->setup_table_names();
|
221 |
+
|
222 |
+
// Uploads directory info
|
223 |
+
wpsc_core_constants_uploads();
|
224 |
+
|
225 |
+
// Any additional constants can hook in here
|
226 |
+
do_action( 'wpsc_constants' );
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Include the rest of WPEC's files
|
231 |
+
*
|
232 |
+
* @uses apply_filters() Calls 'wpsc_components' private merchant components
|
233 |
+
* @uses do_action() Calls 'wpsc_includes' which runs after WPEC files have been included
|
234 |
+
*/
|
235 |
+
public function includes() {
|
236 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-util.php' );
|
237 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/customer.php' );
|
238 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-customer.php' );
|
239 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-visitor.php' );
|
240 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-cart-item.php' );
|
241 |
+
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php' );
|
242 |
+
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
|
243 |
+
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-includes.php' );
|
244 |
+
|
245 |
+
$this->components = apply_filters( 'wpsc_components', $this->components );
|
246 |
+
|
247 |
+
foreach ( $this->components as $type => $registered ) {
|
248 |
+
foreach ( $registered as $component ) {
|
249 |
+
|
250 |
+
if ( ! is_array( $component['includes'] ) ) {
|
251 |
+
$component['includes'] = array( $component['includes'] );
|
252 |
+
}
|
253 |
+
|
254 |
+
foreach ( $component['includes'] as $include ) {
|
255 |
+
require_once( $include );
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
// Any additional file includes can hook in here
|
261 |
+
do_action( 'wpsc_includes' );
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Setup the WPEC core
|
266 |
+
*
|
267 |
+
* @uses do_action() Calls 'wpsc_pre_load' which runs before WPEC setup
|
268 |
+
* @uses do_action() Calls 'wpsc_before_init' which is a legacy action
|
269 |
+
* @uses _wpsc_action_create_customer_id() Sets up a customer id just in case we don't have it
|
270 |
+
* @uses wpsc_core_setup_globals() Sets up the WPEC core globals
|
271 |
+
* @uses wpsc_core_setup_cart() Sets up the WPEC core cart
|
272 |
+
* @uses wpsc_core_load_thumbnail_sizes() Sets up the core WPEC thumbnail sizes
|
273 |
+
* @uses wpsc_core_load_purchase_log_statuses() Loads the statuses for the purchase logs
|
274 |
+
* @uses wpsc_core_load_checkout_data() Sets up the core WPEC form checkout data
|
275 |
+
* @uses wpsc_core_load_gateways() Loads the merchants from the directory
|
276 |
+
* @uses wpsc_core_load_shipping_modules() Gets shipping modules from the shipping directory
|
277 |
+
* @uses wpsc_core_load_page_titles() Loads the core WPEC pagetitles
|
278 |
+
* @uses do_action() Calls 'wpsc_loaded' which runs after WPEC is fully loaded
|
279 |
+
*/
|
280 |
+
public function load() {
|
281 |
+
// Before setup
|
282 |
+
do_action( 'wpsc_pre_load' );
|
283 |
+
|
284 |
+
// Legacy action
|
285 |
+
do_action( 'wpsc_before_init' );
|
286 |
+
|
287 |
+
// Setup the core WPEC globals
|
288 |
+
wpsc_core_setup_globals();
|
289 |
+
|
290 |
+
add_action( 'init', '_wpsc_action_setup_customer', 1 );
|
291 |
+
|
292 |
+
// WPEC is ready to use as soon as WordPress and customer is setup and loaded
|
293 |
+
add_action( 'init', array( $this, '_wpsc_fire_ready_action' ), 100 );
|
294 |
+
|
295 |
+
// Load the purchase log statuses
|
296 |
+
wpsc_core_load_purchase_log_statuses();
|
297 |
+
|
298 |
+
// Load unique names and checkout form types
|
299 |
+
wpsc_core_load_checkout_data();
|
300 |
+
|
301 |
+
// Load the gateways
|
302 |
+
wpsc_core_load_gateways();
|
303 |
+
|
304 |
+
// Load the shipping modules
|
305 |
+
wpsc_core_load_shipping_modules();
|
306 |
+
|
307 |
+
// WPEC is fully loaded
|
308 |
+
do_action( 'wpsc_loaded' );
|
309 |
+
}
|
310 |
+
|
311 |
+
public function _wpsc_fire_ready_action() {
|
312 |
+
// WPEC is ready to use as soon as WordPress and customer is setup and loaded
|
313 |
+
do_action( 'wpsc_ready' );
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* WPEC Activation Hook
|
318 |
+
*
|
319 |
+
* @uses deactivate_plugins() Deactivates plugins by string
|
320 |
+
* @uses wp_die() Kills loading and returns the HTML
|
321 |
+
* @uses wpsc_install() Performs checks to see if this is a clean install or not
|
322 |
+
*/
|
323 |
+
public function install() {
|
324 |
+
|
325 |
+
if ( ! defined( 'WPSC_FILE_PATH' ) ) {
|
326 |
+
define( 'WPSC_FILE_PATH', dirname( __FILE__ ) );
|
327 |
+
}
|
328 |
+
|
329 |
+
require_once( WPSC_FILE_PATH . '/wpsc-core/wpsc-installer.php' );
|
330 |
+
$this->constants();
|
331 |
+
wpsc_install();
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Runs the WPEC deactivation routines.
|
336 |
+
*
|
337 |
+
* @uses wp_get_schedules() Retrieves all filtered WP_Cron recurrences
|
338 |
+
* @uses wp_clear_scheduled_hook() Removes any hooks on WP_Cron
|
339 |
+
*/
|
340 |
+
public function deactivate() {
|
341 |
+
foreach ( wp_get_schedules() as $cron => $schedule ) {
|
342 |
+
wp_clear_scheduled_hook( "wpsc_{$cron}_cron_task" );
|
343 |
+
}
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
// Start WPEC
|
348 |
+
$wpec = new WP_eCommerce();
|
349 |
+
|
350 |
+
// Activation
|
351 |
+
register_activation_hook( __FILE__ , array( $wpec, 'install' ) );
|
352 |
+
register_deactivation_hook( __FILE__, array( $wpec, 'deactivate' ) );
|
trunk/wpsc-admin/admin-form-functions.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Admin Form Functions
|
4 |
+
*
|
5 |
+
* These are the functions that power administrative forms in the WordPress admin
|
6 |
+
*
|
7 |
+
* @package wp-e-commerce
|
8 |
+
*/
|
9 |
+
function coupon_edit_form($coupon) {
|
10 |
+
|
11 |
+
$conditions = maybe_unserialize($coupon['condition']);
|
12 |
+
|
13 |
+
$start_timestamp = strtotime($coupon['start']);
|
14 |
+
$end_timestamp = strtotime($coupon['expiry']);
|
15 |
+
$id = $coupon['id'];
|
16 |
+
$output = '';
|
17 |
+
$output .= "<form name='edit_coupon' id='".$coupon['coupon_code']."' method='post' action=''>\n\r";
|
18 |
+
$output .= "<table class='add-coupon'>\n\r";
|
19 |
+
$output .= " <tr>\n\r";
|
20 |
+
$output .= " <th>".esc_html__('Coupon Code', 'wp-e-commerce')."</th>\n\r";
|
21 |
+
$output .= " <th>".esc_html__('Discount', 'wp-e-commerce')."</th>\n\r";
|
22 |
+
$output .= " <th>".esc_html__('Start', 'wp-e-commerce')."</th>\n\r";
|
23 |
+
$output .= " <th>".esc_html__('Expiry', 'wp-e-commerce')."</th>\n\r";
|
24 |
+
$output .= " <th>".esc_html__('Use Once', 'wp-e-commerce')."</th>\n\r";
|
25 |
+
$output .= " <th>".esc_html__('Active', 'wp-e-commerce')."</th>\n\r";
|
26 |
+
$output .= " <th>".esc_html__('Apply On All Products', 'wp-e-commerce')."</th>\n\r";
|
27 |
+
$output .= " <th></th>\n\r";
|
28 |
+
$output .= " </tr>\n\r";
|
29 |
+
$output .= " <tr>\n\r";
|
30 |
+
$output .= " <td>\n\r";
|
31 |
+
$output .= " <input type='hidden' value='true' name='is_edit_coupon' />\n\r";
|
32 |
+
$output .= " <input type='text' size='11' value='".$coupon['coupon_code']."' name='edit_coupon[".$id."][coupon_code]' />\n\r";
|
33 |
+
$output .= " </td>\n\r";
|
34 |
+
$output .= " <td>\n\r";
|
35 |
+
|
36 |
+
$output .= " <input type='text' size='3' value='".$coupon['value']."' name=edit_coupon[".$id."][value]' />";
|
37 |
+
$output .= " <select name='edit_coupon[".$id."][is-percentage]'>";
|
38 |
+
$output .= " <option value='0' ".(($coupon['is-percentage'] == 0) ? "selected='true'" : '')." >$</option>\n\r";//
|
39 |
+
$output .= " <option value='1' ".(($coupon['is-percentage'] == 1) ? "selected='true'" : '')." >%</option>\n\r";
|
40 |
+
$output .= " <option value='2' ".(($coupon['is-percentage'] == 2) ? "selected='true'" : '')." >" . esc_html__( 'Free shipping', 'wp-e-commerce' ) . "</option>\n\r";
|
41 |
+
$output .= " </select>\n\r";
|
42 |
+
$output .= " </td>\n\r";
|
43 |
+
$output .= " <td>\n\r";
|
44 |
+
$coupon_start = get_date_from_gmt( $coupon['start'], 'Y-m-d' );
|
45 |
+
$output .= "<input type='text' class='pickdate' size='11' name='edit_coupon[".$id."][start]' value='{$coupon_start}'>";
|
46 |
+
$output .= " </td>\n\r";
|
47 |
+
$output .= " <td>\n\r";
|
48 |
+
$coupon_expiry = get_date_from_gmt( $coupon['expiry'], 'Y-m-d' );
|
49 |
+
$output .= "<input type='text' class='pickdate' size='11' name='edit_coupon[".$id."][expiry]' value='{$coupon_expiry}'>";
|
50 |
+
$output .= " </td>\n\r";
|
51 |
+
$output .= " <td>\n\r";
|
52 |
+
$output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][use-once]' />\n\r";
|
53 |
+
$output .= " <input type='checkbox' value='1' ".(($coupon['use-once'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][use-once]' />\n\r";
|
54 |
+
$output .= " </td>\n\r";
|
55 |
+
$output .= " <td>\n\r";
|
56 |
+
$output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][active]' />\n\r";
|
57 |
+
$output .= " <input type='checkbox' value='1' ".(($coupon['active'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][active]' />\n\r";
|
58 |
+
$output .= " </td>\n\r";
|
59 |
+
$output .= " <td>\n\r";
|
60 |
+
$output .= " <input type='hidden' value='0' name='edit_coupon[".$id."][add_every_product]' />\n\r";
|
61 |
+
$output .= " <input type='checkbox' value='1' ".(($coupon['every_product'] == 1) ? "checked='checked'" : '')." name='edit_coupon[".$id."][add_every_product]' />\n\r";
|
62 |
+
$output .= " </td>\n\r";
|
63 |
+
$output .= " <td>\n\r";
|
64 |
+
$output .= " <input type='hidden' value='".$id."' name='edit_coupon[".$id."][id]' />\n\r";
|
65 |
+
$output .= " </td>\n\r";
|
66 |
+
$output .= " </tr>\n\r";
|
67 |
+
|
68 |
+
if($conditions != null){
|
69 |
+
$output .= "<tr>";
|
70 |
+
$output .= "<th>";
|
71 |
+
$output .= esc_html__("Conditions", 'wp-e-commerce');
|
72 |
+
$output .= "</th>";
|
73 |
+
$output .= "</tr>";
|
74 |
+
$output .= "<th>";
|
75 |
+
$output .= esc_html__("Delete", 'wp-e-commerce');
|
76 |
+
$output .= "</th>";
|
77 |
+
$output .= "<th>";
|
78 |
+
$output .= esc_html__("Property", 'wp-e-commerce');
|
79 |
+
$output .= "</th>";
|
80 |
+
$output .= "<th>";
|
81 |
+
$output .= esc_html__("Logic", 'wp-e-commerce');
|
82 |
+
$output .= "</th>";
|
83 |
+
$output .= "<th>";
|
84 |
+
$output .= esc_html__("Value", 'wp-e-commerce');
|
85 |
+
$output .= "</th>";
|
86 |
+
$output .= " </tr>\n\r";
|
87 |
+
|
88 |
+
foreach ($conditions as $i => $condition){
|
89 |
+
$output .= "<tr>";
|
90 |
+
$output .= "<td>";
|
91 |
+
$output .= "<input type='hidden' name='coupon_id' value='".$id."' />";
|
92 |
+
$output .= "<input type='submit' id='delete_condition".$i."' style='display:none;' value='".$i."' name='delete_condition' />";
|
93 |
+
$output .= "<span style='cursor:pointer;' class='delete_button' onclick='jQuery(\"#delete_condition".$i."\").click()'>" . esc_html__('Delete', 'wp-e-commerce' ) . "</span>";
|
94 |
+
$output .= "</td>";
|
95 |
+
$output .= "<td>";
|
96 |
+
$output .= $condition['property'];
|
97 |
+
$output .= "</td>";
|
98 |
+
$output .= "<td>";
|
99 |
+
$output .= $condition['logic'];
|
100 |
+
$output .= "</td>";
|
101 |
+
$output .= "<td>";
|
102 |
+
$output .= $condition['value'];
|
103 |
+
$output .= "</td>";
|
104 |
+
$output .= "</tr>";
|
105 |
+
$i++;
|
106 |
+
}
|
107 |
+
$output .= wpsc_coupons_conditions( $id);
|
108 |
+
}elseif($conditions == null){
|
109 |
+
$output .= wpsc_coupons_conditions( $id);
|
110 |
+
|
111 |
+
}
|
112 |
+
$output .= "</table>\n\r";
|
113 |
+
$output .= "</form>\n\r";
|
114 |
+
echo $output;
|
115 |
+
return $output;
|
116 |
+
}
|
117 |
+
function wpsc_coupons_conditions($id){
|
118 |
+
?>
|
119 |
+
|
120 |
+
<?php
|
121 |
+
|
122 |
+
$output ='
|
123 |
+
<input type="hidden" name="coupon_id" value="'.$id.'" />
|
124 |
+
<tr><td colspan="3"><b>' . esc_html__( 'Add Conditions', 'wp-e-commerce') . '</b></td></tr>
|
125 |
+
<tr><td colspan="6">
|
126 |
+
<div class="coupon_condition">
|
127 |
+
<div>
|
128 |
+
<select class="ruleprops" name="rules[property][]">
|
129 |
+
<option value="item_name" rel="order">' . esc_html__( 'Item name', 'wp-e-commerce') . '</option>
|
130 |
+
<option value="item_quantity" rel="order">' . esc_html__( 'Item quantity', 'wp-e-commerce') . '</option>
|
131 |
+
<option value="total_quantity" rel="order">' . esc_html__( 'Total quantity', 'wp-e-commerce') . '</option>
|
132 |
+
<option value="subtotal_amount" rel="order">' . esc_html__( 'Subtotal amount', 'wp-e-commerce') . '</option>
|
133 |
+
' . apply_filters( 'wpsc_coupon_rule_property_options', '' ) . '
|
134 |
+
</select>
|
135 |
+
<select name="rules[logic][]">
|
136 |
+
<option value="equal">' . esc_html__( 'Is equal to', 'wp-e-commerce') . '</option>
|
137 |
+
<option value="greater">' . esc_html__( 'Is greater than', 'wp-e-commerce') . '</option>
|
138 |
+
<option value="less">' . esc_html__( 'Is less than', 'wp-e-commerce') . '</option>
|
139 |
+
<option value="contains">' . esc_html__( 'Contains', 'wp-e-commerce') . '</option>
|
140 |
+
<option value="not_contain">' . esc_html__( 'Does not contain', 'wp-e-commerce') . '</option>
|
141 |
+
<option value="begins">' . esc_html__( 'Begins with', 'wp-e-commerce') . '</option>
|
142 |
+
<option value="ends">' . esc_html__( 'Ends with', 'wp-e-commerce') . '</option>
|
143 |
+
</select>
|
144 |
+
<span>
|
145 |
+
<input type="text" name="rules[value][]"/>
|
146 |
+
</span>
|
147 |
+
|
148 |
+
|
149 |
+
</div>
|
150 |
+
</div>
|
151 |
+
</td>
|
152 |
+
<td>
|
153 |
+
</td>
|
154 |
+
<td colspan="3">
|
155 |
+
<input type="submit" value="'.esc_attr__("Update Coupon", 'wp-e-commerce').'" class="button-primary" name="edit_coupon['.$id.'][submit_coupon]" />';
|
156 |
+
|
157 |
+
$nonced_url = admin_url( 'admin.php' );
|
158 |
+
$nonced_url = add_query_arg(
|
159 |
+
array(
|
160 |
+
'wpsc_admin_action' => 'wpsc-delete-coupon',
|
161 |
+
'delete_id' => $id,
|
162 |
+
'_wp_http_referer' => urlencode( admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ) ),
|
163 |
+
),
|
164 |
+
$nonced_url
|
165 |
+
);
|
166 |
+
$nonced_url = wp_nonce_url( $nonced_url, 'delete-coupon' );
|
167 |
+
|
168 |
+
$output.= "<a class='delete_button' style='text-decoration:none;' href=" .$nonced_url.">" . esc_html__( 'Delete', 'wp-e-commerce' ) . "</a>";
|
169 |
+
|
170 |
+
$output.='
|
171 |
+
</td>
|
172 |
+
</tr>
|
173 |
+
';
|
174 |
+
return $output;
|
175 |
+
|
176 |
+
}
|
177 |
+
function setting_button(){
|
178 |
+
$next_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']."?page=wpsc-edit-products";
|
179 |
+
|
180 |
+
$output = '';
|
181 |
+
$output .= "<div style='float: right; margin-top: 0px; position: relative;'> | <a href='#' onclick='display_settings_button(); return false;' style='text-decoration: underline;'>".esc_html__('Settings', 'wp-e-commerce')." »</a>";
|
182 |
+
$output .= "<span id='settings_button' style='width:180px;background-color:#f1f1f1;position:absolute; right: 10px; border:1px solid black; display:none;'>";
|
183 |
+
$output .= "<ul class='settings_button'>";
|
184 |
+
|
185 |
+
$output .= "<li><a href='admin.php?page=wpsc-settings'>".__('Shop Settings', 'wp-e-commerce')."</a></li>";
|
186 |
+
$output .= "<li><a href='admin.php?page=wpsc-settings&tab=gateway'>".__('Money and Payment', 'wp-e-commerce')."</a></li>";
|
187 |
+
$output .= "<li><a href='admin.php?page=wpsc-settings&tab=checkout'>".__('Checkout Page Settings', 'wp-e-commerce')."</a></li>";
|
188 |
+
$output .= "</ul>";
|
189 |
+
$output .= "</span>  </div>";
|
190 |
+
|
191 |
+
return $output;
|
192 |
+
}
|
193 |
+
|
194 |
+
function wpsc_right_now() {
|
195 |
+
global $wpdb;
|
196 |
+
$year = date("Y");
|
197 |
+
$month = date("m");
|
198 |
+
$start_timestamp = mktime(0, 0, 0, $month, 1, $year);
|
199 |
+
$end_timestamp = mktime(0, 0, 0, ($month+1), 0, $year);
|
200 |
+
$product_count = $wpdb->get_var("SELECT COUNT(*)
|
201 |
+
FROM `".$wpdb->posts."`
|
202 |
+
WHERE `post_status` = 'publish'
|
203 |
+
AND `post_type` = 'wpsc-product'"
|
204 |
+
);
|
205 |
+
$group_count = count(get_terms("wpsc_product_category"));
|
206 |
+
$sales_count = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `date` BETWEEN '".$start_timestamp."' AND '".$end_timestamp."'");
|
207 |
+
$monthtotal = wpsc_currency_display( admin_display_total_price( $start_timestamp,$end_timestamp ) );
|
208 |
+
$overaltotal = wpsc_currency_display( admin_display_total_price() );
|
209 |
+
$variation_count = count(get_terms("wpsc-variation", array('parent' => 0)));
|
210 |
+
$pending_sales = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN ('1','2')");
|
211 |
+
$accept_sales = $wpdb->get_var("SELECT COUNT(*) FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `processed` IN ('3' ,'4', '5')");
|
212 |
+
$theme = get_option('wpsc_selected_theme');
|
213 |
+
?>
|
214 |
+
<div class='table'>
|
215 |
+
<p class='sub'><?php esc_html_e( 'At a Glance', 'wp-e-commerce' ); ?></p>
|
216 |
+
<table style='border-top:1px solid #ececec;'>
|
217 |
+
<tr class='first'>
|
218 |
+
<td class='first b'>
|
219 |
+
<?php echo $product_count; ?>
|
220 |
+
</td>
|
221 |
+
<td class='t'>
|
222 |
+
<?php echo _nx( 'Product', 'Products', $product_count, 'dashboard widget', 'wp-e-commerce' ); ?>
|
223 |
+
</td>
|
224 |
+
<td class='b'>
|
225 |
+
<?php echo $sales_count; ?>
|
226 |
+
</td>
|
227 |
+
<td class='last'>
|
228 |
+
<?php echo _nx( 'Sale', 'Sales', $sales_count, 'dashboard widget', 'wp-e-commerce' ); ?>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
<tr>
|
232 |
+
<td class='first b'>
|
233 |
+
<?php echo $group_count; ?>
|
234 |
+
</td>
|
235 |
+
<td class='t'>
|
236 |
+
<?php echo _nx( 'Category', 'Categories', $group_count, 'dashboard widget', 'wp-e-commerce' ); ?>
|
237 |
+
</td>
|
238 |
+
<td class='b'>
|
239 |
+
<?php echo $pending_sales; ?>
|
240 |
+
</td>
|
241 |
+
<td class='last t waiting'>
|
242 |
+
<?php echo _n( 'Pending sale', 'Pending sales', $pending_sales, 'wp-e-commerce' ); ?>
|
243 |
+
</td>
|
244 |
+
</tr>
|
245 |
+
<tr>
|
246 |
+
<td class='first b'>
|
247 |
+
<?php echo $variation_count; ?>
|
248 |
+
</td>
|
249 |
+
<td class='t'>
|
250 |
+
<?php echo _nx( 'Variation', 'Variations', $variation_count, 'dashboard widget', 'wp-e-commerce' ); ?>
|
251 |
+
</td>
|
252 |
+
<td class='b'>
|
253 |
+
<?php echo $accept_sales; ?>
|
254 |
+
</td>
|
255 |
+
<td class='last t approved'>
|
256 |
+
<?php echo _n( 'Closed sale', 'Closed sales', $accept_sales, 'wp-e-commerce'); ?>
|
257 |
+
</td>
|
258 |
+
</tr>
|
259 |
+
</table>
|
260 |
+
</div>
|
261 |
+
<?php
|
262 |
+
}
|
263 |
+
|
264 |
+
function wpsc_product_item_row() {
|
265 |
+
}
|
trunk/wpsc-admin/admin.php
ADDED
@@ -0,0 +1,1581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP eCommerce Main Admin functions
|
4 |
+
*
|
5 |
+
* These are the main WPSC Admin functions
|
6 |
+
*
|
7 |
+
* @package wp-e-commerce
|
8 |
+
* @since 3.7.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
// admin includes
|
12 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-update.page.php' );
|
13 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-items.page.php' );
|
14 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-upgrades.page.php' );
|
15 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/display-items-functions.php' );
|
16 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-functions.php' );
|
17 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/save-data.functions.php' );
|
18 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/duplicate-product-class.php' );
|
19 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/updating-functions.php' );
|
20 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-coupons.php' );
|
21 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs.functions.php' );
|
22 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs.class.php' );
|
23 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/purchaselogs-items.class.php' );
|
24 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/theming.class.php' );
|
25 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax.php' );
|
26 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/init.php' );
|
27 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/ajax-and-init.php' );
|
28 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-options-settings.page.php' );
|
29 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/upgrade.php' );
|
30 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/media.php' );
|
31 |
+
|
32 |
+
if ( ! get_option( 'wpsc_checkout_form_sets' ) ) {
|
33 |
+
$form_sets = array( __( 'Default Checkout Forms', 'wp-e-commerce' ) );
|
34 |
+
update_option( 'wpsc_checkout_form_sets', $form_sets );
|
35 |
+
}
|
36 |
+
|
37 |
+
// if we add and wpec admin javascript will add the localizations
|
38 |
+
add_filter( 'wpsc_javascript_localizations', '_wpsc_admin_localizations', 1 );
|
39 |
+
|
40 |
+
/**
|
41 |
+
* wpsc_query_vars_product_list sets the ordering for the edit-products page list
|
42 |
+
*
|
43 |
+
* @since 3.8.0
|
44 |
+
* @access public
|
45 |
+
*
|
46 |
+
* @uses get_option() Gets option from the DB given key
|
47 |
+
*
|
48 |
+
* @param array $vars req Default query arguments
|
49 |
+
* @return array $vars Modified query arguments
|
50 |
+
*/
|
51 |
+
function wpsc_query_vars_product_list( $vars ){
|
52 |
+
|
53 |
+
if( 'wpsc-product' != $vars['post_type'] || in_array( $vars['orderby'], array( 'meta_value_num', 'meta_value' ) ) )
|
54 |
+
return $vars;
|
55 |
+
|
56 |
+
$vars['posts_per_archive_page'] = 0;
|
57 |
+
|
58 |
+
if( 'dragndrop' == get_option( 'wpsc_sort_by' ) ){
|
59 |
+
$vars['orderby'] = 'menu_order title';
|
60 |
+
$vars['order'] = 'desc';
|
61 |
+
$vars['nopaging'] = true;
|
62 |
+
}
|
63 |
+
|
64 |
+
return $vars;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Admin Edit Posts Order
|
69 |
+
*
|
70 |
+
* @since 3.8.12
|
71 |
+
* @access public
|
72 |
+
*
|
73 |
+
* @param string $orderby_sql Order by SQL.
|
74 |
+
* @return string Filtered order by SQL.
|
75 |
+
*/
|
76 |
+
function wpsc_admin_edit_posts_orderby( $orderby_sql ) {
|
77 |
+
global $wp_query, $wpdb;
|
78 |
+
if ( 'dragndrop' == get_option( 'wpsc_sort_by' ) ) {
|
79 |
+
if ( function_exists( 'is_main_query' ) && is_main_query() && 'wpsc-product' == get_query_var( 'post_type' ) && is_tax( 'wpsc_product_category' ) ) {
|
80 |
+
if ( ! empty( $orderby_sql ) )
|
81 |
+
$orderby_sql = ', ' . $orderby_sql;
|
82 |
+
$orderby_sql = " {$wpdb->term_relationships}.term_order ASC" . $orderby_sql;
|
83 |
+
remove_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $orderby_sql;
|
87 |
+
}
|
88 |
+
add_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );
|
89 |
+
|
90 |
+
/**
|
91 |
+
* setting the product & variations per page screen option to between 1 and 999
|
92 |
+
*
|
93 |
+
* @since 3.8.0
|
94 |
+
* @access public
|
95 |
+
*
|
96 |
+
* @uses update_user_option() Updates user option given userid, key, value
|
97 |
+
*
|
98 |
+
* @param $status
|
99 |
+
* @param string $option req Name of option being saved
|
100 |
+
* @param string $value req Value of option being saved
|
101 |
+
* @return $value after changes...
|
102 |
+
*/
|
103 |
+
function wpsc_set_screen_option($status, $option, $value){
|
104 |
+
if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page", "wpsc_purchases_per_page" )) ){
|
105 |
+
if ( "edit_wpsc_variation_per_page" == $option ){
|
106 |
+
global $user_ID;
|
107 |
+
update_user_option($user_ID,'edit_wpsc-variation_per_page',$value);
|
108 |
+
}
|
109 |
+
return $value;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
add_filter('set-screen-option', 'wpsc_set_screen_option', 99, 3);
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Limit admin variation dropdown to show variantion sets only.
|
116 |
+
*
|
117 |
+
* @param array $args Dropdown args.
|
118 |
+
* @param string $taxonomy Taxonomy.
|
119 |
+
* @param string $context Context.
|
120 |
+
*
|
121 |
+
* @since 4.0.0
|
122 |
+
*
|
123 |
+
* @return array Filtered dropdown args.
|
124 |
+
*/
|
125 |
+
function wpsc_variation_parent_dropdown_args( $args, $taxonomy, $context ) {
|
126 |
+
|
127 |
+
if ( 'wpsc-variation' == $taxonomy && 'edit' == $context ) {
|
128 |
+
$args['depth'] = 1;
|
129 |
+
}
|
130 |
+
|
131 |
+
return $args;
|
132 |
+
|
133 |
+
}
|
134 |
+
add_filter( 'taxonomy_parent_dropdown_args', 'wpsc_variation_parent_dropdown_args', 10, 3 );
|
135 |
+
|
136 |
+
/**
|
137 |
+
* When rearranging the products for drag and drop it is easiest to arrange them when they are all on the same page...
|
138 |
+
* @access public
|
139 |
+
*
|
140 |
+
* @since 3.8.0
|
141 |
+
* @access public
|
142 |
+
*
|
143 |
+
* @uses get_option() Gets option from the database given key
|
144 |
+
*
|
145 |
+
* @param int $per_page req number of products per page
|
146 |
+
* @param string $post_type req name of current post type
|
147 |
+
* @return $per_page after changes...
|
148 |
+
*/
|
149 |
+
function wpsc_drag_and_drop_ordering($per_page, $post_type){
|
150 |
+
global $wpdb;
|
151 |
+
if ( 'wpsc-product' == $post_type && 'dragndrop' == get_option( 'wpsc_sort_by' ) && $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `post_type`='wpsc-product' AND `post_parent`=0" ) )
|
152 |
+
$per_page = $count;
|
153 |
+
return $per_page;
|
154 |
+
}
|
155 |
+
add_filter( 'request', 'wpsc_query_vars_product_list' );
|
156 |
+
add_filter( 'edit_posts_per_page' , 'wpsc_drag_and_drop_ordering', 10, 2 );
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Checks whether to display or hide the update wp-e-commerce link
|
160 |
+
*
|
161 |
+
* @since 3.8.0
|
162 |
+
* @access public
|
163 |
+
*
|
164 |
+
* @uses get_option() Gets option from DB given key
|
165 |
+
*
|
166 |
+
* @return boolean true - show link, false- hide link
|
167 |
+
*/
|
168 |
+
function wpsc_show_update_link() {
|
169 |
+
global $wpdb;
|
170 |
+
// Check if old product_list table exists
|
171 |
+
// If it exists AND get_option wpsc_upgrade_complete is not true then return true
|
172 |
+
$sql = 'SHOW TABLES LIKE "'.$wpdb->prefix.'wpsc_product_list"';
|
173 |
+
$var = $wpdb->get_var( $sql );
|
174 |
+
if ( !empty( $var ) && false == get_option( 'wpsc_hide_update' ) )
|
175 |
+
return true;
|
176 |
+
else
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* wpsc_admin_pages function, all the definitons of admin pages are stores here.
|
182 |
+
* No parameters, returns nothing
|
183 |
+
*
|
184 |
+
* Fairly standard wordpress plugin API stuff for adding the admin pages, rearrange the order to rearrange the pages
|
185 |
+
* The bits to display the options page first on first use may be buggy, but tend not to stick around long enough to be identified and fixed
|
186 |
+
* if you find bugs, feel free to fix them.
|
187 |
+
*
|
188 |
+
* If the permissions are changed here, they will likewise need to be changed for the other sections of the admin that either use ajax
|
189 |
+
* or bypass the normal download system.
|
190 |
+
*
|
191 |
+
* @access public
|
192 |
+
*
|
193 |
+
* @uses wpsc_show_update_link() Decides whether or not to show the update link
|
194 |
+
* @uses add_submenu_page() Adds a WordPress submenu page
|
195 |
+
* @uses apply_filters() Calls wpsc_upgrades_cap allows hooking caps for adiministrator
|
196 |
+
* @uses apply_filters() Calls wpsc_coupon_cap allows filtering for the coupon caps
|
197 |
+
* @uses add_options_page() Adds a submenu to the settings page
|
198 |
+
* @uses add_action() Calls 'admin_print_scripts.$edit_options_page prints out WPEC admin scripts
|
199 |
+
* @uses apply_filters() Calls 'wpsc_additional_pages' Passes the page_hooks and product_page URL
|
200 |
+
* @uses do_action() Calls 'wpsc_add_submenu' Allows you to hook in to the WPEC menu
|
201 |
+
* @uses update_option() Updates option given key and value
|
202 |
+
*/
|
203 |
+
function wpsc_admin_pages() {
|
204 |
+
|
205 |
+
// Code to enable or disable the debug page
|
206 |
+
if ( isset( $_GET['wpsc_activate_debug_page'] ) ) {
|
207 |
+
if ( 'true' == $_GET['wpsc_activate_debug_page'] ) {
|
208 |
+
$_SESSION['wpsc_activate_debug_page'] = true;
|
209 |
+
} else if ( 'false' == $_GET['wpsc_activate_debug_page'] ) {
|
210 |
+
$_SESSION['wpsc_activate_debug_page'] = false;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
$store_upgrades_cap = apply_filters( 'wpsc_upgrades_cap', 'administrator' );
|
215 |
+
|
216 |
+
$page_hooks = array();
|
217 |
+
|
218 |
+
if ( wpsc_show_update_link() ) {
|
219 |
+
$page_hooks[] = add_submenu_page( 'index.php', __( 'Update Store', 'wp-e-commerce' ), __( 'Store Update', 'wp-e-commerce' ), $store_upgrades_cap, 'wpsc-update', 'wpsc_display_update_page' );
|
220 |
+
}
|
221 |
+
|
222 |
+
$purchase_logs_cap = apply_filters( 'wpsc_purchase_logs_cap', 'administrator' );
|
223 |
+
$page_hooks[] = $purchase_logs_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wp-e-commerce' ), __( 'Store Sales', 'wp-e-commerce' ), $purchase_logs_cap, 'wpsc-purchase-logs', 'wpsc_display_purchase_logs_page' );
|
224 |
+
|
225 |
+
$page_hooks[] = add_submenu_page( 'index.php', __( 'WPeC License', 'wp-e-commerce' ), __( 'WPeC Licensing', 'wp-e-commerce' ), $store_upgrades_cap, 'wpsc-upgrades', 'wpsc_display_upgrades_page' );
|
226 |
+
|
227 |
+
// Set the base page for Products
|
228 |
+
$products_page = 'edit.php?post_type=wpsc-product';
|
229 |
+
|
230 |
+
$manage_coupon_cap = apply_filters( 'wpsc_coupon_cap', 'administrator' );
|
231 |
+
$page_hooks[] = $edit_coupons_page = add_submenu_page( $products_page , __( 'Coupons', 'wp-e-commerce' ), __( 'Coupons', 'wp-e-commerce' ), $manage_coupon_cap, 'wpsc-edit-coupons', 'wpsc_display_coupons_page' );
|
232 |
+
|
233 |
+
// Add Settings pages
|
234 |
+
$page_hooks[] = $edit_options_page = add_options_page( __( 'Store Settings', 'wp-e-commerce' ), __( 'Store', 'wp-e-commerce' ), 'administrator', 'wpsc-settings', 'wpsc_display_settings_page' );
|
235 |
+
add_action( 'admin_print_scripts-' . $edit_options_page , 'wpsc_print_admin_scripts' );
|
236 |
+
|
237 |
+
$page_hooks = apply_filters( 'wpsc_additional_pages', $page_hooks, $products_page );
|
238 |
+
|
239 |
+
do_action( 'wpsc_add_submenu' );
|
240 |
+
|
241 |
+
// Include the javascript and CSS for this page
|
242 |
+
// This is so important that I can't even express it in one line
|
243 |
+
|
244 |
+
foreach ( $page_hooks as $page_hook ) {
|
245 |
+
add_action( 'load-' . $page_hook, 'wpsc_admin_include_css_and_js_refac' );
|
246 |
+
|
247 |
+
switch ( $page_hook ) {
|
248 |
+
|
249 |
+
case $edit_options_page :
|
250 |
+
add_action( 'load-' . $page_hook, 'wpsc_admin_include_optionspage_css_and_js' );
|
251 |
+
break;
|
252 |
+
|
253 |
+
case $purchase_logs_page :
|
254 |
+
add_action( 'admin_head', 'wpsc_product_log_rss_feed' );
|
255 |
+
add_action( 'load-' . $page_hook, 'wpsc_admin_include_purchase_logs_css_and_js' );
|
256 |
+
break;
|
257 |
+
|
258 |
+
case $edit_coupons_page :
|
259 |
+
add_action( 'load-' . $page_hook, 'wpsc_admin_include_coupon_js' );
|
260 |
+
break;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
// Some updating code is run from here, is as good a place as any, and better than some
|
265 |
+
if ( ( null == get_option( 'wpsc_trackingid_subject' ) ) && ( null == get_option( 'wpsc_trackingid_message' ) ) ) {
|
266 |
+
update_option( 'wpsc_trackingid_subject', __( 'Product Tracking Email', 'wp-e-commerce' ) );
|
267 |
+
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", 'wp-e-commerce' ) );
|
268 |
+
}
|
269 |
+
|
270 |
+
add_action( 'load-' . $edit_options_page, 'wpsc_load_settings_page', 1 );
|
271 |
+
|
272 |
+
// only load the purchase log list table and page classes when it's necessary
|
273 |
+
// also, the WPSC_Purchase_Logs_List_Table needs to be initializied before admin_header.php
|
274 |
+
// is loaded, therefore wpsc_load_purchase_logs_page needs to do this as well
|
275 |
+
add_action( 'load-' . $purchase_logs_page, 'wpsc_load_purchase_logs_page', 1 );
|
276 |
+
|
277 |
+
// Help tabs
|
278 |
+
add_action( 'load-' . $edit_options_page , 'wpsc_add_help_tabs' );
|
279 |
+
add_action( 'load-' . $purchase_logs_page , 'wpsc_add_help_tabs' );
|
280 |
+
add_action( 'load-' . $edit_coupons_page , 'wpsc_add_help_tabs' );
|
281 |
+
add_action( 'load-edit.php' , 'wpsc_add_help_tabs' );
|
282 |
+
add_action( 'load-post.php' , 'wpsc_add_help_tabs' );
|
283 |
+
add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
|
284 |
+
add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );
|
285 |
+
|
286 |
+
// screen options on Sales Log
|
287 |
+
add_action( 'load-' . $purchase_logs_page , 'wpsc_add_purchase_logs_screen_option' );
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* This function adds contextual help to all WPEC screens.
|
292 |
+
* add_contextual_help() is supported as well as $screen->add_help_tab().
|
293 |
+
*
|
294 |
+
* @since 3.8.8
|
295 |
+
* @access public
|
296 |
+
*
|
297 |
+
* @uses get_current_screen() Returns WordPress admin screen object
|
298 |
+
* @uses get_bloginfo() Returns information about the WordPress site
|
299 |
+
* @uses add_help_tab() Used to add a tab to the contextual help menu
|
300 |
+
*/
|
301 |
+
function wpsc_add_help_tabs() {
|
302 |
+
$tabs = array(
|
303 |
+
// Store Settings Page
|
304 |
+
'settings_page_wpsc-settings' => array(
|
305 |
+
'title' => _x( 'Store Settings', 'contextual help tab', 'wp-e-commerce' ),
|
306 |
+
'links' => array(
|
307 |
+
'category/configuring-your-store/store-settings/' => _x( 'Store Settings Overview' , 'contextual help link', 'wp-e-commerce' ),
|
308 |
+
'category/configuring-your-store/payment-gateways/' => _x( 'Configuring Your Payment Gateways', 'contextual help link', 'wp-e-commerce' ),
|
309 |
+
'category/configuring-your-store/shipping/' => _x( 'Configuring Your Shipping Modules', 'contextual help link', 'wp-e-commerce' ),
|
310 |
+
),
|
311 |
+
),
|
312 |
+
|
313 |
+
// Sales Log Page
|
314 |
+
'dashboard_page_wpsc-purchase-logs' => array(
|
315 |
+
'title' => _x( 'Sales Log', 'contextual help tab', 'wp-e-commerce' ),
|
316 |
+
'links' => array(
|
317 |
+
'documentation/sales/' => _x( 'Monitor and Manage Your Sales', 'contextual help link', 'wp-e-commerce' ),
|
318 |
+
),
|
319 |
+
),
|
320 |
+
|
321 |
+
// Main Products Listing Admin Page (edit.php?post_type=wpsc-product)
|
322 |
+
'edit-wpsc-product' => array(
|
323 |
+
'title' => _x( 'Product Catalog', 'contextual help tab', 'wp-e-commerce' ),
|
324 |
+
'links' => array(
|
325 |
+
'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wp-e-commerce' ),
|
326 |
+
),
|
327 |
+
),
|
328 |
+
|
329 |
+
// Add and Edit Product Pages
|
330 |
+
'wpsc-product' => array(
|
331 |
+
'title' => _x( 'Add and Edit Product', 'contextual help tab', 'wp-e-commerce' ),
|
332 |
+
'links' => array(
|
333 |
+
'category/managing-your-store/' => _x( 'Managing Your Store' , 'contextual help link', 'wp-e-commerce' ),
|
334 |
+
'resource/video-adding-products/' => _x( 'Video: Adding Products', 'contextual help link', 'wp-e-commerce' ),
|
335 |
+
),
|
336 |
+
),
|
337 |
+
|
338 |
+
// Product Tags Page
|
339 |
+
'edit-product_tag' => array(
|
340 |
+
'title' => _x( 'Product Tags', 'contextual help tab', 'wp-e-commerce' ),
|
341 |
+
'links' =>array(
|
342 |
+
'resource/video-product-tags/' => _x( 'Video: Product Tags', 'contextual help link', 'wp-e-commerce' ),
|
343 |
+
),
|
344 |
+
),
|
345 |
+
|
346 |
+
// Product Category Page
|
347 |
+
'edit-wpsc_product_category' => array(
|
348 |
+
'title' => _x( 'Product Categories', 'contextual help tab', 'wp-e-commerce' ),
|
349 |
+
'links' => array(
|
350 |
+
'resource/video-creating-product-categories/' => _x( 'Video: Creating Product Categories', 'contextual help link', 'wp-e-commerce' ),
|
351 |
+
),
|
352 |
+
),
|
353 |
+
|
354 |
+
// Product Variations Page
|
355 |
+
'edit-wpsc-variation' => array(
|
356 |
+
'title' => _x( 'Product Variations', 'contextual help tab', 'wp-e-commerce' ),
|
357 |
+
'links' => array(
|
358 |
+
'category/managing-your-store/' => _x( 'Managing Your Store', 'contextual help link', 'wp-e-commerce' ),
|
359 |
+
),
|
360 |
+
),
|
361 |
+
|
362 |
+
// Coupon Page
|
363 |
+
'wpsc-product_page_wpsc-edit-coupons' => array(
|
364 |
+
'title' => _x( 'Coupons', 'contextual help tab', 'wp-e-commerce' ),
|
365 |
+
'links' => array(
|
366 |
+
'resource/video-creating-coupons/' => _x( 'Video: Creating Coupons', 'contextual help link', 'wp-e-commerce' ),
|
367 |
+
),
|
368 |
+
),
|
369 |
+
);
|
370 |
+
|
371 |
+
$screen = get_current_screen();
|
372 |
+
if ( array_key_exists( $screen->id, $tabs ) ) {
|
373 |
+
$tab = $tabs[$screen->id];
|
374 |
+
$content = '<p><strong>' . __( 'For More Information', 'wp-e-commerce' ) . '</strong></p>';
|
375 |
+
$links = array();
|
376 |
+
foreach( $tab['links'] as $link => $link_title ) {
|
377 |
+
$link = 'http://docs.wpecommerce.org/' . $link;
|
378 |
+
$links[] = '<a target="_blank" href="' . esc_url( $link ) . '">' . esc_html( $link_title ) . '</a>';
|
379 |
+
}
|
380 |
+
$content .= '<p>' . implode( '<br />', $links ) . '</p>';
|
381 |
+
|
382 |
+
$screen->add_help_tab( array(
|
383 |
+
'id' => $screen->id . '_help',
|
384 |
+
'title' => $tab['title'],
|
385 |
+
'content' => $content,
|
386 |
+
) );
|
387 |
+
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* This function allows change in number of purchase logs shown on Sales Log (Screen Options).
|
393 |
+
*
|
394 |
+
* @since 3.9.0
|
395 |
+
* @access public
|
396 |
+
*
|
397 |
+
* @uses add_screen_option()
|
398 |
+
*/
|
399 |
+
function wpsc_add_purchase_logs_screen_option(){
|
400 |
+
|
401 |
+
// setup Screen Option for purchase logs per page
|
402 |
+
add_screen_option( 'per_page', array(
|
403 |
+
'label' => __("Sales Orders", 'wp-e-commerce'),
|
404 |
+
'default' => 20,
|
405 |
+
'option' => 'wpsc_purchases_per_page'
|
406 |
+
) );
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Includes purchase logs CSS and JS
|
411 |
+
*
|
412 |
+
* @acces public
|
413 |
+
*
|
414 |
+
* @uses wp_enqueue_script() Recommended way of adding scripts in WordPress
|
415 |
+
* @uses wp_localize_script() Adds noncing and other data to the logs script
|
416 |
+
*/
|
417 |
+
function wpsc_admin_include_purchase_logs_css_and_js() {
|
418 |
+
|
419 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
420 |
+
|
421 |
+
$dependencies = array( 'jquery' );
|
422 |
+
|
423 |
+
if ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) {
|
424 |
+
wp_enqueue_style( 'wp-admin' );
|
425 |
+
$dependencies[] = 'postbox';
|
426 |
+
}
|
427 |
+
|
428 |
+
wp_enqueue_script( 'wp-e-commerce-purchase-logs', WPSC_URL . '/wpsc-admin/js/purchase-logs.js', $dependencies, WPSC_VERSION . '.' . WPSC_MINOR_VERSION, true );
|
429 |
+
wp_localize_script( 'wp-e-commerce-purchase-logs', 'WPSC_Purchase_Logs_Admin', array(
|
430 |
+
'nonce' => wp_create_nonce( 'wpsc_purchase_logs' ),
|
431 |
+
'change_purchase_log_status_nonce' => _wpsc_create_ajax_nonce( 'change_purchase_log_status' ),
|
432 |
+
'purchase_log_save_tracking_id_nonce' => _wpsc_create_ajax_nonce( 'purchase_log_save_tracking_id' ),
|
433 |
+
'purchase_log_send_tracking_email_nonce' => _wpsc_create_ajax_nonce( 'purchase_log_send_tracking_email' ),
|
434 |
+
'purchase_log_refund_items_nonce' => _wpsc_create_ajax_nonce( 'purchase_log_refund_items' ),
|
435 |
+
'remove_log_item_nonce' => _wpsc_create_ajax_nonce( 'remove_log_item' ),
|
436 |
+
'update_log_item_qty_nonce' => _wpsc_create_ajax_nonce( 'update_log_item_qty' ),
|
437 |
+
'add_log_item_nonce' => _wpsc_create_ajax_nonce( 'add_log_item' ),
|
438 |
+
'edit_contact_details_nonce' => _wpsc_create_ajax_nonce( 'edit_contact_details' ),
|
439 |
+
'add_note_nonce' => _wpsc_create_ajax_nonce( 'add_note' ),
|
440 |
+
'delete_note_nonce' => _wpsc_create_ajax_nonce( 'delete_note' ),
|
441 |
+
'search_products_nonce' => _wpsc_create_ajax_nonce( 'search_products' ),
|
442 |
+
'sending_message' => _x( 'sending...', 'sending tracking email for purchase log', 'wp-e-commerce' ),
|
443 |
+
'sent_message' => _x( 'Email Sent!', 'sending tracking email for purchase log', 'wp-e-commerce' ),
|
444 |
+
'current_view' => empty( $_REQUEST['status'] ) ? 'all' : $_REQUEST['status'],
|
445 |
+
'current_filter' => empty( $_REQUEST['m'] ) ? '' : $_REQUEST['m'],
|
446 |
+
'current_page' => empty( $_REQUEST['paged'] ) ? '' : $_REQUEST['paged'],
|
447 |
+
'log_id' => isset( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : 0,
|
448 |
+
'strings' => array(
|
449 |
+
'confirm_delete_item' => esc_html__( 'Are you sure you want to remove this item?', 'wp-e-commerce' ),
|
450 |
+
'confirm_delete_note' => esc_html__( 'Are you sure you want to delete this note?', 'wp-e-commerce' ),
|
451 |
+
'confirm_refund_order' => esc_html__( 'Are you sure you want to refund this order?', 'wp-e-commerce' ),
|
452 |
+
'confirm_refund_order_manually' => esc_html__( 'Are you sure you want to refund this order manually? Note: this only affects your on-site records, it does not interface with any payment gateway to return funds to the customer.', 'wp-e-commerce' ),
|
453 |
+
'search_head' => esc_html__( 'Search for Products to Add', 'wp-e-commerce' ),
|
454 |
+
'cancel_btn' => esc_html__( 'Cancel', 'wp-e-commerce' ),
|
455 |
+
),
|
456 |
+
) );
|
457 |
+
|
458 |
+
// Purchase Log Action Links
|
459 |
+
wp_enqueue_script( 'wpsc-purchase-log-action-links', WPSC_URL . '/wpsc-admin/js/purchase-log-action-links.js', array( 'jquery' ), WPSC_VERSION . '.' . WPSC_MINOR_VERSION, true );
|
460 |
+
wp_localize_script( 'wpsc-purchase-log-action-links', 'WPSC_Purchase_Log_Action_Links', array(
|
461 |
+
'purchase_log_action_link_nonce' => _wpsc_create_ajax_nonce( 'purchase_log_action_link' ),
|
462 |
+
'log_id' => empty( $_REQUEST['id'] ) ? '' : absint( $_REQUEST['id'] )
|
463 |
+
) );
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Loads the WPEC settings page
|
469 |
+
*
|
470 |
+
* @access public
|
471 |
+
*
|
472 |
+
* @uses WPSC_Settings_Page::get_instance() Gets instance of WPEC settings page
|
473 |
+
*/
|
474 |
+
function wpsc_load_settings_page() {
|
475 |
+
require_once('settings-page.php');
|
476 |
+
WPSC_Settings_Page::get_instance();
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Leads the purchase logs page
|
481 |
+
*
|
482 |
+
* @uses WPSC_Purchase_Log_Page() Loads the edit and view sales page
|
483 |
+
*/
|
484 |
+
function wpsc_load_purchase_logs_page() {
|
485 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
|
486 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
|
487 |
+
$page = new WPSC_Purchase_Log_Page();
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Displays the WPEC purchase logs
|
492 |
+
*
|
493 |
+
* @uses do_action() Calls 'wpsc_display_purchase_logs_page' allows hooking of the sales log page
|
494 |
+
*/
|
495 |
+
function wpsc_display_purchase_logs_page() {
|
496 |
+
do_action( 'wpsc_display_purchase_logs_page' );
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Produces an RSS feed for the product log
|
501 |
+
*
|
502 |
+
* @uses add_query_arg() Allows you to add arguments to the end of a URL
|
503 |
+
* @uses admin_url() Retrieves URL to the WordPress admin
|
504 |
+
*/
|
505 |
+
function wpsc_product_log_rss_feed() {
|
506 |
+
echo "<link type='application/rss+xml' href='" . add_query_arg( array( 'rss' => 'true', 'rss_key' => 'key', 'action' => 'purchase_log', 'type' => 'rss' ), admin_url( 'index.php' ) ) . "' title='" . esc_attr__( 'WP eCommerce Purchase Log RSS', 'wp-e-commerce' ) . "' rel='alternate' />";
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Includes and enqueues scripts and styles for coupons
|
511 |
+
*
|
512 |
+
* @uses wp_enqueue_style() Includes and prints styles for WPEC in the WordPress admin
|
513 |
+
* @uses wp_enqueue_script() Includes and prints scripts for WPEC in the WordPress admin
|
514 |
+
*/
|
515 |
+
function wpsc_admin_include_coupon_js() {
|
516 |
+
|
517 |
+
// Variables
|
518 |
+
$version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
|
519 |
+
|
520 |
+
// global js
|
521 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
522 |
+
|
523 |
+
// Coupon CSS
|
524 |
+
wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
|
525 |
+
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
526 |
+
|
527 |
+
// Coupon JS
|
528 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
529 |
+
wp_enqueue_style( 'jquery-ui-datepicker' );
|
530 |
+
|
531 |
+
wp_enqueue_script( 'wp-e-commerce-admin_legacy', WPSC_URL . '/wpsc-admin/js/admin-legacy.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-datepicker' ), $version_identifier );
|
532 |
+
|
533 |
+
$admin_color = get_user_option( 'admin_color' );
|
534 |
+
$scheme = 'classic' === $admin_color ? $admin_color : 'fresh';
|
535 |
+
|
536 |
+
wp_enqueue_style( 'wpsc-jquery-ui-datepicker', WPSC_URL . '/wpsc-admin/css/jquery.ui.datepicker-' . $scheme . '.css', false, $version_identifier );
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Includes and enqueues scripts and styles for the WPEC options page
|
541 |
+
*
|
542 |
+
* @uses wp_enqueue_script() Includes and prints out the JS for the WPEC options page
|
543 |
+
* @uses wp_localize_script() Sets up the JS vars needed
|
544 |
+
* @uses _wpsc_create_ajax_nonce() Alias for wp_create_nonce, creates a random one time use token
|
545 |
+
* @uses get_current_tab_id() Returns the current tab id
|
546 |
+
* @uses wp_enqueue_style() Includes and prints out the CSS for the WPEC options page
|
547 |
+
*/
|
548 |
+
function wpsc_admin_include_optionspage_css_and_js() {
|
549 |
+
|
550 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
551 |
+
|
552 |
+
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
553 |
+
wp_enqueue_script( 'wp-e-commerce-admin-settings-page', WPSC_URL . '/wpsc-admin/js/settings-page.js', array( 'jquery-query' ), $version_identifier );
|
554 |
+
|
555 |
+
wp_localize_script( 'wp-e-commerce-admin-settings-page', 'WPSC_Settings_Page', array(
|
556 |
+
'navigate_settings_tab_nonce' => _wpsc_create_ajax_nonce( 'navigate_settings_tab' ),
|
557 |
+
'payment_gateway_settings_form_nonce' => _wpsc_create_ajax_nonce( 'payment_gateway_settings_form' ),
|
558 |
+
'shipping_module_settings_form_nonce' => _wpsc_create_ajax_nonce( 'shipping_module_settings_form' ),
|
559 |
+
'display_region_list_nonce' => _wpsc_create_ajax_nonce( 'display_region_list' ),
|
560 |
+
'update_checkout_fields_order_nonce' => _wpsc_create_ajax_nonce( 'update_checkout_fields_order' ),
|
561 |
+
'add_tax_rate_nonce' => _wpsc_create_ajax_nonce( 'add_tax_rate' ),
|
562 |
+
'current_tab' => WPSC_Settings_Page::get_instance()->get_current_tab_id(),
|
563 |
+
'before_unload_dialog' => __( 'The changes you made will be lost if you navigate away from this page.', 'wp-e-commerce' ),
|
564 |
+
'ajax_navigate_confirm_dialog' => __( 'The changes you made will be lost if you navigate away from this page.', 'wp-e-commerce' ) . "\n\n" . __( 'Click OK to discard your changes, or Cancel to remain on this page.', 'wp-e-commerce' ),
|
565 |
+
'edit_field_options' => __( 'Edit Options', 'wp-e-commerce' ),
|
566 |
+
'hide_edit_field_options' => __( 'Hide Options', 'wp-e-commerce' ),
|
567 |
+
'delete_form_set_confirm' => __( 'Are you sure you want to delete %s? Submitted data of this form set will also be removed from sales logs.', 'wp-e-commerce' ),
|
568 |
+
) );
|
569 |
+
|
570 |
+
wp_enqueue_style( 'wp-e-commerce-admin_2.7', WPSC_URL . '/wpsc-admin/css/settingspage.css', false, false, 'all' );
|
571 |
+
wp_enqueue_style( 'wp-e-commerce-ui-tabs', WPSC_URL . '/wpsc-admin/css/jquery.ui.tabs.css', false, $version_identifier, 'all' );
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Sets up the WPEC metaboxes
|
576 |
+
*
|
577 |
+
* @uses remove_meta_box() Removes the default taxonomy meta box so our own can be added
|
578 |
+
* @uses add_meta_bax() Adds metaboxes to the WordPress admin interface
|
579 |
+
*/
|
580 |
+
function wpsc_meta_boxes() {
|
581 |
+
global $post;
|
582 |
+
$pagename = 'wpsc-product';
|
583 |
+
remove_meta_box( 'wpsc-variationdiv', 'wpsc-product', 'side' );
|
584 |
+
|
585 |
+
//if a variation page do not show these metaboxes
|
586 |
+
if ( is_object( $post ) && $post->post_parent == 0 ) {
|
587 |
+
add_meta_box( 'wpsc_product_variation_forms' , __( 'Variations', 'wp-e-commerce' ) , 'wpsc_product_variation_forms' , $pagename, 'normal', 'high' );
|
588 |
+
} else if( is_object( $post ) && $post->post_status == "inherit" ) {
|
589 |
+
remove_meta_box( 'tagsdiv-product_tag' , 'wpsc-product', 'core' );
|
590 |
+
remove_meta_box( 'wpsc_product_categorydiv' , 'wpsc-product', 'core' );
|
591 |
+
}
|
592 |
+
|
593 |
+
add_meta_box( 'wpsc_price_control_forms', __('Product Pricing', 'wp-e-commerce'), 'wpsc_price_control_forms', $pagename, 'side', 'low' );
|
594 |
+
add_meta_box( 'wpsc_stock_control_forms', __('Stock Inventory', 'wp-e-commerce'), 'wpsc_stock_control_forms', $pagename, 'side', 'low' );
|
595 |
+
add_meta_box( 'wpsc_product_taxes_forms', __('Taxes', 'wp-e-commerce'), 'wpsc_product_taxes_forms', $pagename, 'side', 'low' );
|
596 |
+
add_meta_box( 'wpsc_product_delivery_forms', __('Product Delivery', 'wp-e-commerce'), 'wpsc_product_delivery_forms', $pagename, 'normal', 'high' );
|
597 |
+
add_meta_box( 'wpsc_product_details_forms', __('Product Details', 'wp-e-commerce'), 'wpsc_product_details_forms', $pagename, 'normal', 'high' );
|
598 |
+
}
|
599 |
+
|
600 |
+
add_action( 'admin_footer', 'wpsc_meta_boxes' );
|
601 |
+
add_action( 'admin_enqueue_scripts', 'wpsc_admin_include_css_and_js_refac' );
|
602 |
+
|
603 |
+
/**
|
604 |
+
* Includes the JS and CSS
|
605 |
+
*
|
606 |
+
* @param string $pagehook The pagehook for the currently viewing page, provided by the 'admin_enqueue_scripts' action
|
607 |
+
*
|
608 |
+
* @uses wp_admin_css() Enqueues or prints a stylesheet in the admin
|
609 |
+
* @uses wp_enqueue_script() Enqueues the specified script
|
610 |
+
* @uses wp_localize_script() Sets up the JS vars needed
|
611 |
+
* @uses wp_enqueue_style() Enqueues the styles
|
612 |
+
* @uses wp_dequeue_script() Removes a previously enqueued script by handle
|
613 |
+
* @uses _wpsc_create_ajax_nonce() Alias for wp_create_nonce, creates a random one time use token
|
614 |
+
*/
|
615 |
+
function wpsc_admin_include_css_and_js_refac( $pagehook ) {
|
616 |
+
global $post_type, $post;
|
617 |
+
|
618 |
+
$current_screen = get_current_screen();
|
619 |
+
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
620 |
+
$pages = array( 'index.php', 'options-general.php', 'edit.php', 'post.php', 'post-new.php' );
|
621 |
+
|
622 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
623 |
+
|
624 |
+
if ( ! is_customize_preview() ) {
|
625 |
+
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 );
|
626 |
+
}
|
627 |
+
|
628 |
+
if ( 'dashboard_page_wpsc-sales-logs' == $current_screen->id ) {
|
629 |
+
// jQuery
|
630 |
+
wp_enqueue_script( 'jquery' );
|
631 |
+
wp_enqueue_script( 'jquery-ui-draggable' );
|
632 |
+
wp_enqueue_script( 'jquery-ui-droppable' );
|
633 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
634 |
+
|
635 |
+
// Metaboxes
|
636 |
+
wp_enqueue_script( 'common' );
|
637 |
+
wp_enqueue_script( 'wp-lists' );
|
638 |
+
wp_enqueue_script( 'postbox' );
|
639 |
+
}
|
640 |
+
|
641 |
+
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' || $current_screen->id == 'wpsc-product-variations-iframe' || ( $pagehook == 'media-upload-popup' && get_post_type( $_REQUEST['post_id'] ) == 'wpsc-product' ) ) {
|
642 |
+
|
643 |
+
wp_enqueue_script( 'wpsc-sortable-table', WPSC_URL . '/wpsc-admin/js/sortable-table.js', array( 'jquery' ) );
|
644 |
+
|
645 |
+
if ( in_array( $current_screen->id, array( 'wpsc-product', 'edit-wpsc-variation', 'wpsc-product' ) ) ) {
|
646 |
+
wp_enqueue_script( 'wp-e-commerce-variations', WPSC_URL . '/wpsc-admin/js/variations.js', array( 'jquery', 'wpsc-sortable-table' ), $version_identifier );
|
647 |
+
wp_localize_script(
|
648 |
+
'wp-e-commerce-variations', // handle
|
649 |
+
'WPSC_Variations', // variable name
|
650 |
+
array( // args
|
651 |
+
'thickbox_title' => __( 'Add Media - %s', 'wp-e-commerce' ),
|
652 |
+
)
|
653 |
+
);
|
654 |
+
}
|
655 |
+
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
656 |
+
|
657 |
+
}
|
658 |
+
|
659 |
+
static $_wpsc_admin_l10n_loaded;
|
660 |
+
|
661 |
+
if ( ! $_wpsc_admin_l10n_loaded ) {
|
662 |
+
// Localize scripts
|
663 |
+
wp_localize_script( 'wp-e-commerce-admin', 'wpsc_adminL10n', array(
|
664 |
+
'dragndrop_set' => ( get_option( 'wpsc_sort_by' ) == 'dragndrop' ? 'true' : 'false' ),
|
665 |
+
'save_product_order_nonce' => _wpsc_create_ajax_nonce( 'save_product_order' ),
|
666 |
+
'l10n_print_after' => 'try{convertEntities(wpsc_adminL10n);}catch(e){};',
|
667 |
+
'empty_coupon' => esc_html__( 'Please enter a coupon code.', 'wp-e-commerce' ),
|
668 |
+
'bulk_edit_no_vars' => esc_html__( 'Quick Edit options are limited when editing products that have variations. You will need to edit the variations themselves.', 'wp-e-commerce' ),
|
669 |
+
'wpsc_core_images_url' => WPSC_CORE_IMAGES_URL,
|
670 |
+
'variation_parent_swap' => esc_html_x( 'New Variation Set', 'Variation taxonomy parent', 'wp-e-commerce' ),
|
671 |
+
/* translators : This string is prepended to the 'New Variation Set' string */
|
672 |
+
'variation_helper_text' => esc_html_x( 'Choose the Variation Set you want to add variants to. If you\'re creating a new variation set, then select', 'Variation helper text', 'wp-e-commerce' ),
|
673 |
+
'variations_tutorial' => esc_html__( 'Variations allow you to create options for your products. For example, if you\'re selling T-Shirts, they will generally have a "Size" option. 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 dragging and dropping them within their Variation Set.', 'wp-e-commerce' ),
|
674 |
+
/* translators : These strings are dynamically inserted as a drop-down for the Coupon comparison conditions */
|
675 |
+
'coupons_compare_or' => esc_html_x( 'OR' , 'Coupon comparison logic', 'wp-e-commerce' ),
|
676 |
+
'coupons_compare_and' => esc_html_x( 'AND' , 'Coupon comparison logic', 'wp-e-commerce' ),
|
677 |
+
'meta_downloads_plural' => _x( ' downloads', 'live preview for downloads metabox', 'wp-e-commerce' ),
|
678 |
+
'meta_downloads_singular' => _x( ' download' , 'live preview for downloads metabox', 'wp-e-commerce' ),
|
679 |
+
'wpsc_inline_css_error' => __( 'It is not possible to change the state of the inline CSS without also changing the common CSS.', 'wp-e-commerce' )
|
680 |
+
) );
|
681 |
+
|
682 |
+
$_wpsc_admin_l10n_loaded = true;
|
683 |
+
}
|
684 |
+
|
685 |
+
if ( $pagehook == 'wpsc-product-variations-iframe' ) {
|
686 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
687 |
+
|
688 |
+
wp_enqueue_script( 'wp-e-commerce-product-variations', WPSC_URL . '/wpsc-admin/js/product-variations.js', array( 'jquery' ), $version_identifier );
|
689 |
+
wp_localize_script( 'wp-e-commerce-product-variations', 'WPSC_Product_Variations', array(
|
690 |
+
'product_id' => absint( $_REQUEST['product_id'] ),
|
691 |
+
'add_variation_set_nonce' => _wpsc_create_ajax_nonce( 'add_variation_set' ),
|
692 |
+
) );
|
693 |
+
}
|
694 |
+
|
695 |
+
if ( $pagehook == 'media-upload-popup' ) {
|
696 |
+
|
697 |
+
$post = get_post( $_REQUEST['post_id'] );
|
698 |
+
if ( $post->post_type == 'wpsc-product' && $post->post_parent ) {
|
699 |
+
_wpsc_enqueue_wp_e_commerce_admin();
|
700 |
+
|
701 |
+
wp_dequeue_script( 'set-post-thumbnail' );
|
702 |
+
wp_enqueue_script( 'wpsc-set-post-thumbnail', WPSC_URL . '/wpsc-admin/js/set-post-thumbnail.js', array( 'jquery', 'wp-e-commerce-admin' ), $version_identifier );
|
703 |
+
wp_localize_script( 'wpsc-set-post-thumbnail', 'WPSC_Set_Post_Thumbnail', array(
|
704 |
+
'link_text' => __( 'Use as Product Thumbnail', 'wp-e-commerce' ),
|
705 |
+
'saving' => __( 'Saving...', 'wp-e-commerce' ),
|
706 |
+
'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.', 'wp-e-commerce' ),
|
707 |
+
'done' => __( 'Done', 'wp-e-commerce' ),
|
708 |
+
'nonce' => _wpsc_create_ajax_nonce( 'set_variation_product_thumbnail' ),
|
709 |
+
) );
|
710 |
+
}
|
711 |
+
}
|
712 |
+
|
713 |
+
if ( 'dashboard_page_wpsc-upgrades' == $pagehook || 'dashboard_page_wpsc-update' == $pagehook )
|
714 |
+
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
715 |
+
}
|
716 |
+
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Adds admin javascript to the wp-e-commerce-admin javascript
|
720 |
+
*
|
721 |
+
* @since 3.8.14
|
722 |
+
*
|
723 |
+
* @param array array containing key value pairs, keys are turned into javascript globals with thier associated values
|
724 |
+
*
|
725 |
+
*/
|
726 |
+
function _wpsc_admin_localizations( $localizations ) {
|
727 |
+
|
728 |
+
$hidden_boxes = get_option( 'wpsc_hidden_box' );
|
729 |
+
$hidden_boxes = implode( ',', (array)$hidden_boxes );
|
730 |
+
|
731 |
+
$form_types_option = get_option( 'wpsc_checkout_form_fields' );
|
732 |
+
if ( ! $form_types_option || ! is_array( $form_types_option ) ) {
|
733 |
+
$form_types_option = array();
|
734 |
+
}
|
735 |
+
|
736 |
+
$unique_names_option = get_option( 'wpsc_checkout_unique_names' );
|
737 |
+
if ( ! $unique_names_option || ! is_array( $unique_names_option ) ) {
|
738 |
+
$unique_names_option = array();
|
739 |
+
}
|
740 |
+
|
741 |
+
$form_types = '';
|
742 |
+
foreach ( $form_types_option as $form_type ) {
|
743 |
+
$form_types .= '<option value="' . $form_type . '">' . $form_type . '</option>';
|
744 |
+
}
|
745 |
+
|
746 |
+
$unique_names = '<option value="-1">' . __( 'Select a Unique Name', 'wp-e-commerce' ) . '</option>';
|
747 |
+
foreach ( $unique_names_option as $unique_name ) {
|
748 |
+
$unique_names .= '<option value="' . $unique_name . '">' . $unique_name . '</option>';
|
749 |
+
}
|
750 |
+
|
751 |
+
$localizations['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
|
752 |
+
$localizations['hidden_boxes'] = '"' . esc_js( $hidden_boxes ) . '"';
|
753 |
+
$localizations['IS_WP27'] = '"' . esc_js( IS_WP27 ) . '"';
|
754 |
+
$localizations['TXT_WPSC_DELETE'] = '"' . esc_js( __( 'Delete', 'wp-e-commerce' ) ) . '"';
|
755 |
+
$localizations['TXT_WPSC_TEXT'] = '"' . esc_js( __( 'Text', 'wp-e-commerce' ) ) . '"';
|
756 |
+
$localizations['TXT_WPSC_EMAIL'] = '"' . esc_js( __( 'Email', 'wp-e-commerce' ) ) . '"';
|
757 |
+
$localizations['TXT_WPSC_COUNTRY'] = '"' . esc_js( __( 'Country', 'wp-e-commerce' ) ) . '"';
|
758 |
+
$localizations['TXT_WPSC_TEXTAREA'] = '"' . esc_js( __( 'Textarea', 'wp-e-commerce' ) ) . '"';
|
759 |
+
$localizations['TXT_WPSC_HEADING'] = '"' . esc_js( __( 'Heading', 'wp-e-commerce' ) ) . '"';
|
760 |
+
$localizations['TXT_WPSC_COUPON'] = '"' . esc_js( __( 'Coupon', 'wp-e-commerce' ) ) . '"';
|
761 |
+
|
762 |
+
$localizations['HTML_FORM_FIELD_TYPES'] = '"' . esc_js( $form_types ) . '"';
|
763 |
+
$localizations['HTML_FORM_FIELD_UNIQUE_NAMES'] = '"' . esc_js( $unique_names ) . '"';
|
764 |
+
|
765 |
+
$localizations['TXT_WPSC_LABEL'] = '"' . esc_js( __( 'Label', 'wp-e-commerce' ) ) . '"';
|
766 |
+
$localizations['TXT_WPSC_LABEL_DESC'] = '"' . esc_js( __( 'Label Description', 'wp-e-commerce' ) ) . '"';
|
767 |
+
$localizations['TXT_WPSC_ITEM_NUMBER'] = '"' . esc_js( __( 'Item Number', 'wp-e-commerce' ) ) . '"';
|
768 |
+
$localizations['TXT_WPSC_LIFE_NUMBER'] = '"' . esc_js( __( 'Life Number', 'wp-e-commerce' ) ) . '"';
|
769 |
+
$localizations['TXT_WPSC_PRODUCT_CODE'] = '"' . esc_js( __( 'Product Code', 'wp-e-commerce' ) ) . '"';
|
770 |
+
$localizations['TXT_WPSC_PDF'] = '"' . esc_js( __( 'PDF', 'wp-e-commerce' ) ) . '"';
|
771 |
+
|
772 |
+
$localizations['TXT_WPSC_AND_ABOVE'] = '"' . esc_js( __( ' and above', 'wp-e-commerce' ) ) . '"';
|
773 |
+
$localizations['TXT_WPSC_IF_PRICE_IS'] = '"' . esc_js( __( 'If price is ', 'wp-e-commerce' ) ) . '"';
|
774 |
+
$localizations['TXT_WPSC_IF_WEIGHT_IS'] = '"' . esc_js( __( 'If weight is ', 'wp-e-commerce' ) ) . '"';
|
775 |
+
|
776 |
+
// we only want to add these localizations once, it should happen on the first admin script load
|
777 |
+
remove_filter( 'wpsc_javascript_localizations', '_wpsc_admin_localizations', 1 );
|
778 |
+
|
779 |
+
return $localizations;
|
780 |
+
}
|
781 |
+
|
782 |
+
/*
|
783 |
+
* Enqueue the admin script that applies to applies to all wpsc admin pages
|
784 |
+
*/
|
785 |
+
function _wpsc_enqueue_wp_e_commerce_admin( ) {
|
786 |
+
static $already_enqueued = false;
|
787 |
+
if ( ! $already_enqueued ) {
|
788 |
+
$version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
|
789 |
+
wp_enqueue_script( 'wp-e-commerce-admin-js', WPSC_URL . '/wpsc-admin/js/wp-e-commerce-admin.js', false, false, $version_identifier );
|
790 |
+
wp_localize_script( 'wp-e-commerce-admin-js', 'wpsc_admin_vars', wpsc_javascript_localizations() );
|
791 |
+
$already_enqueued = true;
|
792 |
+
}
|
793 |
+
}
|
794 |
+
|
795 |
+
add_action( 'admin_menu', 'wpsc_admin_pages' );
|
796 |
+
|
797 |
+
/**
|
798 |
+
* Displays latest activity in the Dashboard widget
|
799 |
+
*
|
800 |
+
* @uses $wpdb WordPress database object for queries
|
801 |
+
* @uses get_var() Returns single variable from the database
|
802 |
+
* @uses esc_html__() Gets translation of $text and escapes it for HTML output
|
803 |
+
* @uses wpsc_currency_display() Displays the currency
|
804 |
+
* @uses admin_display_total_price() Displays the total price
|
805 |
+
* @uses esc_html_x()
|
806 |
+
* @uses _n() Retrieves the singular or plural version
|
807 |
+
*/
|
808 |
+
function wpsc_admin_latest_activity() {
|
809 |
+
global $wpdb;
|
810 |
+
$totalOrders = $wpdb->get_var( "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "`" );
|
811 |
+
|
812 |
+
/*
|
813 |
+
* This is the right hand side for the past 30 days revenue on the wp dashboard
|
814 |
+
*/
|
815 |
+
echo "<div id='leftDashboard'>";
|
816 |
+
echo "<strong class='dashboardHeading'>" . esc_html__( 'Current Month', 'wp-e-commerce' ) . "</strong><br />";
|
817 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
818 |
+
// calculates total amount of orders for the month
|
819 |
+
$year = date( "Y" );
|
820 |
+
$month = date( "m" );
|
821 |
+
$start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
|
822 |
+
$end_timestamp = mktime( 0, 0, 0, ( $month + 1 ), 0, $year );
|
823 |
+
$sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '$start_timestamp' AND '$end_timestamp' AND `processed` IN (2,3,4) ORDER BY `date` DESC";
|
824 |
+
$currentMonthOrders = $wpdb->get_var( $sql );
|
825 |
+
|
826 |
+
//calculates amount of money made for the month
|
827 |
+
$currentMonthsSales = wpsc_currency_display( admin_display_total_price( $start_timestamp, $end_timestamp ) );
|
828 |
+
echo $currentMonthsSales;
|
829 |
+
echo "<span class='dashboardWidget'>" . esc_html_x( 'Sales', 'the total value of sales in dashboard widget', 'wp-e-commerce' ) . "</span>";
|
830 |
+
echo "</p>";
|
831 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
832 |
+
echo "<span class='pricedisplay'>";
|
833 |
+
echo $currentMonthOrders;
|
834 |
+
echo "</span>";
|
835 |
+
echo "<span class='dashboardWidget'>" . _n( 'Order', 'Orders', $currentMonthOrders, 'wp-e-commerce' ) . "</span>";
|
836 |
+
echo "</p>";
|
837 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
838 |
+
//calculates average sales amount per order for the month
|
839 |
+
if ( $currentMonthOrders > 0 ) {
|
840 |
+
$monthsAverage = ( (int)admin_display_total_price( $start_timestamp, $end_timestamp ) / (int)$currentMonthOrders );
|
841 |
+
echo wpsc_currency_display( $monthsAverage );
|
842 |
+
}
|
843 |
+
//echo "</span>";
|
844 |
+
echo "<span class='dashboardWidget'>" . esc_html__( 'Avg Order', 'wp-e-commerce' ) . "</span>";
|
845 |
+
echo "</p>";
|
846 |
+
echo "</div>";
|
847 |
+
/*
|
848 |
+
* This is the left side for the total life time revenue on the wp dashboard
|
849 |
+
*/
|
850 |
+
|
851 |
+
echo "<div id='rightDashboard' >";
|
852 |
+
echo "<strong class='dashboardHeading'>" . esc_html__( 'Total Income', 'wp-e-commerce' ) . "</strong><br />";
|
853 |
+
|
854 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
855 |
+
echo wpsc_currency_display( admin_display_total_price() );
|
856 |
+
echo "<span class='dashboardWidget'>" . esc_html_x( 'Sales', 'the total value of sales in dashboard widget', 'wp-e-commerce' ) . "</span>";
|
857 |
+
echo "</p>";
|
858 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
859 |
+
echo "<span class='pricedisplay'>";
|
860 |
+
echo $totalOrders;
|
861 |
+
echo "</span>";
|
862 |
+
echo "<span class='dashboardWidget'>" . _n( 'Order', 'Orders', $totalOrders, 'wp-e-commerce' ) . "</span>";
|
863 |
+
echo "</p>";
|
864 |
+
echo "<p class='dashboardWidgetSpecial'>";
|
865 |
+
//calculates average sales amount per order for the month
|
866 |
+
if ( ( admin_display_total_price() > 0 ) && ( $totalOrders > 0 ) ) {
|
867 |
+
$totalAverage = ( (int)admin_display_total_price() / (int)$totalOrders );
|
868 |
+
} else {
|
869 |
+
$totalAverage = 0;
|
870 |
+
}
|
871 |
+
echo wpsc_currency_display( $totalAverage );
|
872 |
+
//echo "</span>";
|
873 |
+
echo "<span class='dashboardWidget'>" . esc_html__( 'Avg Order', 'wp-e-commerce' ) . "</span>";
|
874 |
+
echo "</p>";
|
875 |
+
echo "</div>";
|
876 |
+
echo "<div style='clear:both'></div>";
|
877 |
+
}
|
878 |
+
add_action( 'wpsc_admin_pre_activity', 'wpsc_admin_latest_activity' );
|
879 |
+
|
880 |
+
/*
|
881 |
+
* Dashboard Widget Setup
|
882 |
+
* Adds the dashboard widgets if the user is an admin
|
883 |
+
*
|
884 |
+
* Since 3.6
|
885 |
+
*
|
886 |
+
* @uses wp_enqueue_style() Enqueues CSS
|
887 |
+
* @uses wp_enqueue_script() Enqueues JS
|
888 |
+
* @uses wp_add_dashboard_widget() Adds a new widget to the WordPress admin dashboard
|
889 |
+
* @uses current_user_can() Checks the capabilities of the current user
|
890 |
+
*/
|
891 |
+
function wpsc_dashboard_widget_setup() {
|
892 |
+
$version_identifier = WPSC_VERSION . "." . WPSC_MINOR_VERSION;
|
893 |
+
// Enqueue the styles and scripts necessary
|
894 |
+
wp_enqueue_style( 'wp-e-commerce-admin', WPSC_URL . '/wpsc-admin/css/admin.css', false, $version_identifier, 'all' );
|
895 |
+
wp_enqueue_script( 'datepicker-ui', WPSC_URL . "/wpsc-core/js/ui.datepicker.js", array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), $version_identifier );
|
896 |
+
|
897 |
+
$news_cap = apply_filters( 'wpsc_dashboard_news_cap' , 'manage_options' );
|
898 |
+
$sales_cap = apply_filters( 'wpsc_dashboard_sales_summary_cap' , 'manage_options' );
|
899 |
+
$quarterly_sales_cap = apply_filters( 'wpsc_dashboard_quarterly_sales_cap', 'manage_options' );
|
900 |
+
$monthly_sales_cap = apply_filters( 'wpsc_dashboard_monthly_sales_cap' , 'manage_options' );
|
901 |
+
|
902 |
+
// Add the dashboard widgets
|
903 |
+
if ( current_user_can( $news_cap ) )
|
904 |
+
wp_add_dashboard_widget( 'wpsc_dashboard_news', __( 'WP eCommerce News' , 'wp-e-commerce' ), 'wpsc_dashboard_news' );
|
905 |
+
if ( current_user_can( $sales_cap ) )
|
906 |
+
wp_add_dashboard_widget( 'wpsc_dashboard_widget', __( 'Sales Summary', 'wp-e-commerce' ), 'wpsc_dashboard_widget' );
|
907 |
+
if ( current_user_can( $quarterly_sales_cap ) )
|
908 |
+
wp_add_dashboard_widget( 'wpsc_quarterly_dashboard_widget', __( 'Sales by Quarter', 'wp-e-commerce' ), 'wpsc_quarterly_dashboard_widget' );
|
909 |
+
if ( current_user_can( $monthly_sales_cap ) )
|
910 |
+
wp_add_dashboard_widget( 'wpsc_dashboard_4months_widget', __( 'Sales by Month', 'wp-e-commerce' ), 'wpsc_dashboard_4months_widget' );
|
911 |
+
|
912 |
+
// Sort the Dashboard widgets so ours it at the top
|
913 |
+
global $wp_meta_boxes;
|
914 |
+
$boxes = $wp_meta_boxes['dashboard'];
|
915 |
+
$normal = isset( $wp_meta_boxes['dashboard']['normal'] ) ? $wp_meta_boxes['dashboard']['normal'] : array();
|
916 |
+
|
917 |
+
$normal_dashboard = isset( $normal['core'] ) ? $normal['core'] : array();
|
918 |
+
|
919 |
+
// Backup and delete our new dashbaord widget from the end of the array
|
920 |
+
$wpsc_widget_backup = array();
|
921 |
+
if ( isset( $normal_dashboard['wpsc_dashboard_news'] ) ) {
|
922 |
+
$wpsc_widget_backup['wpsc_dashboard_news'] = $normal_dashboard['wpsc_dashboard_news'];
|
923 |
+
unset( $normal_dashboard['wpsc_dashboard_news'] );
|
924 |
+
}
|
925 |
+
if ( isset( $normal_dashboard['wpsc_dashboard_widget'] ) ) {
|
926 |
+
$wpsc_widget_backup['wpsc_dashboard_widget'] = $normal_dashboard['wpsc_dashboard_widget'];
|
927 |
+
unset( $normal_dashboard['wpsc_dashboard_widget'] );
|
928 |
+
}
|
929 |
+
if ( isset( $normal_dashboard['wpsc_quarterly_dashboard_widget'] ) ) {
|
930 |
+
$wpsc_widget_backup['wpsc_quarterly_dashboard_widget'] = $normal_dashboard['wpsc_quarterly_dashboard_widget'];
|
931 |
+
unset( $normal_dashboard['wpsc_quarterly_dashboard_widget'] );
|
932 |
+
}
|
933 |
+
if ( isset( $normal_dashboard['wpsc_dashboard_4months_widget'] ) ) {
|
934 |
+
$wpsc_widget_backup['wpsc_dashboard_4months_widget'] = $normal_dashboard['wpsc_dashboard_4months_widget'];
|
935 |
+
unset( $normal_dashboard['wpsc_dashboard_4months_widget'] );
|
936 |
+
}
|
937 |
+
|
938 |
+
// Merge the two arrays together so our widget is at the beginning
|
939 |
+
$sorted_dashboard = array_merge( $wpsc_widget_backup, $normal_dashboard );
|
940 |
+
|
941 |
+
// Save the sorted array back into the original metaboxes
|
942 |
+
|
943 |
+
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
944 |
+
}
|
945 |
+
|
946 |
+
/*
|
947 |
+
* Registers the widgets on the WordPress Dashboard
|
948 |
+
*/
|
949 |
+
|
950 |
+
add_action( 'wp_dashboard_setup', 'wpsc_dashboard_widget_setup' );
|
951 |
+
|
952 |
+
/**
|
953 |
+
* Shows the RSS feed for the WPEC dashboard widget
|
954 |
+
*
|
955 |
+
* @uses fetch_feed() Build SimplePie object based on RSS or Atom feed from URL.
|
956 |
+
* @uses wp_widget_rss_output() Display the RSS entries in a list
|
957 |
+
*/
|
958 |
+
function wpsc_dashboard_news() {
|
959 |
+
$rss = fetch_feed( 'http://wpecommerce.org/feed/?category_name=news' );
|
960 |
+
$args = array( 'show_author' => 1, 'show_date' => 1, 'show_summary' => 1, 'items' => 3 );
|
961 |
+
wp_widget_rss_output( $rss, $args );
|
962 |
+
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Gets the quarterly summary of revenue
|
967 |
+
*
|
968 |
+
* @uses get_option() Retrieves an option from the WordPress database
|
969 |
+
* @uses admin_display_total_price() Displays the total price
|
970 |
+
*
|
971 |
+
* @return array The array of prices
|
972 |
+
*/
|
973 |
+
function wpsc_get_quarterly_summary() {
|
974 |
+
$firstquarter = (int)get_option( 'wpsc_first_quart' );
|
975 |
+
$secondquarter = (int)get_option( 'wpsc_second_quart' );
|
976 |
+
$thirdquarter = (int)get_option( 'wpsc_third_quart' );
|
977 |
+
$fourthquarter = (int)get_option( 'wpsc_fourth_quart' );
|
978 |
+
$finalquarter = (int)get_option( 'wpsc_final_quart' );
|
979 |
+
|
980 |
+
$results = array();
|
981 |
+
$results[] = admin_display_total_price( $thirdquarter + 1, $fourthquarter );
|
982 |
+
$results[] = admin_display_total_price( $secondquarter + 1, $thirdquarter );
|
983 |
+
$results[] = admin_display_total_price( $firstquarter + 1, $secondquarter );
|
984 |
+
$results[] = admin_display_total_price( $finalquarter, $firstquarter );
|
985 |
+
return $results;
|
986 |
+
}
|
987 |
+
|
988 |
+
/**
|
989 |
+
* Called by wp_add_dashboard_widget and ads the quarterly revenue reports to the WordPress admin dashboard
|
990 |
+
*
|
991 |
+
* @uses get_option() Gets the specified option from database
|
992 |
+
* @uses esc_html_e() Displays translated text that has been escaped for safe use in HTML
|
993 |
+
*/
|
994 |
+
function wpsc_quarterly_dashboard_widget() {
|
995 |
+
if ( get_option( 'wpsc_business_year_start' ) == false ) {
|
996 |
+
?>
|
997 |
+
<form action='' method='post'>
|
998 |
+
<label for='date_start'><?php esc_html_e( 'Financial Year End' , 'wp-e-commerce' ); ?>: </label>
|
999 |
+
<input id='date_start' type='text' class='pickdate' size='11' value='<?php echo get_option( 'wpsc_last_date' ); ?>' name='add_start' />
|
1000 |
+
<!--<select name='add_start[day]'>
|
1001 |
+
<?php
|
1002 |
+
for ( $i = 1; $i <= 31; ++$i ) {
|
1003 |
+
$selected = '';
|
1004 |
+
if ( $i == date( "d" ) ) {
|
1005 |
+
$selected = "selected='selected'";
|
1006 |
+
}
|
1007 |
+
echo "<option $selected value='$i'>$i</option>";
|
1008 |
+
}
|
1009 |
+
?>
|
1010 |
+
</select>
|
1011 |
+
<select name='add_start[month]'>
|
1012 |
+
<?php
|
1013 |
+
for ( $i = 1; $i <= 12; ++$i ) {
|
1014 |
+
$selected = '';
|
1015 |
+
if ( $i == (int)date( "m" ) ) {
|
1016 |
+
$selected = "selected='selected'";
|
1017 |
+
}
|
1018 |
+
echo "<option $selected value='$i'>" . date( "M", mktime( 0, 0, 0, $i, 1, date( "Y" ) ) ) . "</option>";
|
1019 |
+
}
|
1020 |
+
?>
|
1021 |
+
</select>
|
1022 |
+
<select name='add_start[year]'>
|
1023 |
+
<?php
|
1024 |
+
for ( $i = date( "Y" ); $i <= ( date( "Y" ) + 12 ); ++$i ) {
|
1025 |
+
$selected = '';
|
1026 |
+
if ( $i == date( "Y" ) ) {
|
1027 |
+
$selected = "selected='true'";
|
1028 |
+
}
|
1029 |
+
echo "<option $selected value='$i'>" . $i . "</option>";
|
1030 |
+
}
|
1031 |
+
?>
|
1032 |
+
</select>-->
|
1033 |
+
<input type='hidden' name='wpsc_admin_action' value='wpsc_quarterly' />
|
1034 |
+
<input type='submit' class='button primary' value='Submit' name='wpsc_submit' />
|
1035 |
+
</form>
|
1036 |
+
<?php
|
1037 |
+
if ( get_option( 'wpsc_first_quart' ) != '' ) {
|
1038 |
+
$firstquarter = get_option( 'wpsc_first_quart' );
|
1039 |
+
$secondquarter = get_option( 'wpsc_second_quart' );
|
1040 |
+
$thirdquarter = get_option( 'wpsc_third_quart' );
|
1041 |
+
$fourthquarter = get_option( 'wpsc_fourth_quart' );
|
1042 |
+
$finalquarter = get_option( 'wpsc_final_quart' );
|
1043 |
+
$revenue = wpsc_get_quarterly_summary();
|
1044 |
+
$currsymbol = wpsc_get_currency_symbol();
|
1045 |
+
foreach ( $revenue as $rev ) {
|
1046 |
+
if ( $rev == '' ) {
|
1047 |
+
$totals[] = '0.00';
|
1048 |
+
} else {
|
1049 |
+
$totals[] = $rev;
|
1050 |
+
}
|
1051 |
+
}
|
1052 |
+
?>
|
1053 |
+
<div id='box'>
|
1054 |
+
<p class='atglance'>
|
1055 |
+
<span class='wpsc_quart_left'><?php esc_html_e( 'At a Glance' , 'wp-e-commerce' ); ?></span>
|
1056 |
+
<span class='wpsc_quart_right'><?php esc_html_e( 'Revenue' , 'wp-e-commerce' ); ?></span>
|
1057 |
+
</p>
|
1058 |
+
<div style='clear:both'></div>
|
1059 |
+
<p class='quarterly'>
|
1060 |
+
<span class='wpsc_quart_left'><strong>01</strong> (<?php echo date( 'M Y', $thirdquarter ) . ' - ' . date( 'M Y', $fourthquarter ); ?>)</span>
|
1061 |
+
<span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[0]; ?></span></p>
|
1062 |
+
<p class='quarterly'>
|
1063 |
+
<span class='wpsc_quart_left'><strong>02</strong> (<?php echo date( 'M Y', $secondquarter ) . ' - ' . date( 'M Y', $thirdquarter ); ?>)</span>
|
1064 |
+
<span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[1]; ?></span></p>
|
1065 |
+
<p class='quarterly'>
|
1066 |
+
<span class='wpsc_quart_left'><strong>03</strong> (<?php echo date( 'M Y', $firstquarter ) . ' - ' . date( 'M Y', $secondquarter ); ?>)</span>
|
1067 |
+
<span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[2]; ?></span></p>
|
1068 |
+
<p class='quarterly'>
|
1069 |
+
<span class='wpsc_quart_left'><strong>04</strong> (<?php echo date( 'M Y', $finalquarter ) . ' - ' . date( 'M Y', $firstquarter ); ?>)</span>
|
1070 |
+
<span class='wpsc_quart_right'><?php echo $currsymbol . ' ' . $totals[3]; ?></span>
|
1071 |
+
</p>
|
1072 |
+
<div style='clear:both'></div>
|
1073 |
+
</div>
|
1074 |
+
<?php
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
/**
|
1080 |
+
* Called by wp_add_dashboard_widget to add the WPSC dashboard widget
|
1081 |
+
*
|
1082 |
+
* @uses do_action() Calls 'wpsc_admin_pre_activity'
|
1083 |
+
* @uses do_action() Calls 'wpsc_admin_post_activity'
|
1084 |
+
*/
|
1085 |
+
function wpsc_dashboard_widget() {
|
1086 |
+
do_action( 'wpsc_admin_pre_activity' );
|
1087 |
+
do_action( 'wpsc_admin_post_activity' );
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
/*
|
1091 |
+
* END - Dashboard Widget for 2.7
|
1092 |
+
*/
|
1093 |
+
|
1094 |
+
|
1095 |
+
/*
|
1096 |
+
* Dashboard Widget Last Four Month Sales.
|
1097 |
+
*
|
1098 |
+
* @uses $wpdb WordPress database object for queries
|
1099 |
+
* @uses get_results() Gets generic multiple row results from the WordPress database
|
1100 |
+
* @uses get_var() Returns a single variable from the database
|
1101 |
+
* @uses wpsc_currency_display() Returns the currency with the display options applied
|
1102 |
+
*/
|
1103 |
+
function wpsc_dashboard_4months_widget() {
|
1104 |
+
global $wpdb;
|
1105 |
+
|
1106 |
+
$this_year = date( "Y" ); //get current year and month
|
1107 |
+
$this_month = date( "n" );
|
1108 |
+
|
1109 |
+
$months = array();
|
1110 |
+
$months[] = mktime( 0, 0, 0, $this_month - 3, 1, $this_year ); //generate unix time stamps fo 4 last months
|
1111 |
+
$months[] = mktime( 0, 0, 0, $this_month - 2, 1, $this_year );
|
1112 |
+
$months[] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
|
1113 |
+
$months[] = mktime( 0, 0, 0, $this_month, 1, $this_year );
|
1114 |
+
|
1115 |
+
$products = $wpdb->get_results( "SELECT `cart`.`prodid`,
|
1116 |
+
`cart`.`name`
|
1117 |
+
FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
|
1118 |
+
INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
|
1119 |
+
ON `cart`.`purchaseid` = `logs`.`id`
|
1120 |
+
WHERE `logs`.`processed` >= 2
|
1121 |
+
AND `logs`.`date` >= " . $months[0] . "
|
1122 |
+
GROUP BY `cart`.`prodid`
|
1123 |
+
ORDER BY SUM(`cart`.`price` * `cart`.`quantity`) DESC
|
1124 |
+
LIMIT 4", ARRAY_A ); //get 4 products with top income in 4 last months.
|
1125 |
+
|
1126 |
+
$timeranges = array();
|
1127 |
+
$timeranges[0]["start"] = mktime( 0, 0, 0, $this_month - 3, 1, $this_year ); //make array of time ranges
|
1128 |
+
$timeranges[0]["end"] = mktime( 0, 0, 0, $this_month - 2, 1, $this_year );
|
1129 |
+
$timeranges[1]["start"] = mktime( 0, 0, 0, $this_month - 2, 1, $this_year );
|
1130 |
+
$timeranges[1]["end"] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
|
1131 |
+
$timeranges[2]["start"] = mktime( 0, 0, 0, $this_month - 1, 1, $this_year );
|
1132 |
+
$timeranges[2]["end"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
|
1133 |
+
$timeranges[3]["start"] = mktime( 0, 0, 0, $this_month, 1, $this_year );
|
1134 |
+
$timeranges[3]["end"] = time(); // using mktime here can generate a php runtime warning
|
1135 |
+
|
1136 |
+
$prod_data = array( );
|
1137 |
+
foreach ( (array)$products as $product ) { //run through products and get each product income amounts and name
|
1138 |
+
$sale_totals = array( );
|
1139 |
+
foreach ( $timeranges as $timerange ) { //run through time ranges of product, and get its income over each time range
|
1140 |
+
$prodsql = "SELECT
|
1141 |
+
SUM(`cart`.`price` * `cart`.`quantity`) AS sum
|
1142 |
+
FROM `" . WPSC_TABLE_CART_CONTENTS . "` AS `cart`
|
1143 |
+
INNER JOIN `" . WPSC_TABLE_PURCHASE_LOGS . "` AS `logs`
|
1144 |
+
ON `cart`.`purchaseid` = `logs`.`id`
|
1145 |
+
WHERE `logs`.`processed` >= 2
|
1146 |
+
AND `logs`.`date` >= " . $timerange["start"] . "
|
1147 |
+
AND `logs`.`date` < " . $timerange["end"] . "
|
1148 |
+
AND `cart`.`prodid` = " . $product['prodid'] . "
|
1149 |
+
GROUP BY `cart`.`prodid`"; //get the amount of income that current product has generaterd over current time range
|
1150 |
+
$sale_totals[] = $wpdb->get_var( $prodsql ); //push amount to array
|
1151 |
+
}
|
1152 |
+
$prod_data[] = array(
|
1153 |
+
'sale_totals' => $sale_totals,
|
1154 |
+
'product_name' => $product['name'] ); //result: array of 2: $prod_data[0] = array(income)
|
1155 |
+
$sums = array( ); //reset array //$prod_data[1] = product name
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
$tablerow = 1;
|
1159 |
+
ob_start();
|
1160 |
+
?>
|
1161 |
+
<div style="padding-bottom:15px; "><?php esc_html_e( 'Last four months of sales on a per product basis:', 'wp-e-commerce' ); ?></div>
|
1162 |
+
<table style="width:100%" border="0" cellspacing="0">
|
1163 |
+
<tr style="font-style:italic; color:#666;" height="20">
|
1164 |
+
<td colspan="2" style=" font-family:\'Times New Roman\', Times, serif; font-size:15px; border-bottom:solid 1px #000;"><?php esc_html_e( 'At a Glance', 'wp-e-commerce' ); ?></td>
|
1165 |
+
<?php foreach ( $months as $mnth ): ?>
|
1166 |
+
<td align="center" style=" font-family:\'Times New Roman\'; font-size:15px; border-bottom:solid 1px #000;"><?php echo date( "M", $mnth ); ?></td>
|
1167 |
+
<?php endforeach; ?>
|
1168 |
+
</tr>
|
1169 |
+
<?php foreach ( (array)$prod_data as $sales_data ): ?>
|
1170 |
+
<tr height="20">
|
1171 |
+
<td width="20" style="font-weight:bold; color:#008080; border-bottom:solid 1px #000;"><?php echo $tablerow; ?></td>
|
1172 |
+
<td style="border-bottom:solid 1px #000;width:60px"><?php echo $sales_data['product_name']; ?></td>
|
1173 |
+
<?php foreach ( $sales_data['sale_totals'] as $amount ): ?>
|
1174 |
+
<td align="center" style="border-bottom:solid 1px #000;"><?php echo wpsc_currency_display($amount); ?></td>
|
1175 |
+
<?php endforeach; ?>
|
1176 |
+
</tr>
|
1177 |
+
<?php
|
1178 |
+
$tablerow++;
|
1179 |
+
endforeach; ?>
|
1180 |
+
</table>
|
1181 |
+
<?php
|
1182 |
+
ob_end_flush();
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
|
1186 |
+
//Modification to allow for multiple column layout
|
1187 |
+
|
1188 |
+
/**
|
1189 |
+
* @todo docs
|
1190 |
+
* @param $columns
|
1191 |
+
* @param $screen
|
1192 |
+
* @return mixed
|
1193 |
+
*/
|
1194 |
+
function wpec_two_columns( $columns, $screen ) {
|
1195 |
+
if ( $screen == 'toplevel_page_wpsc-edit-products' )
|
1196 |
+
$columns['toplevel_page_wpsc-edit-products'] = 2;
|
1197 |
+
|
1198 |
+
return $columns;
|
1199 |
+
}
|
1200 |
+
add_filter( 'screen_layout_columns', 'wpec_two_columns', 10, 2 );
|
1201 |
+
|
1202 |
+
/**
|
1203 |
+
* @todo docs
|
1204 |
+
* @param $actions
|
1205 |
+
* @return mixed
|
1206 |
+
*/
|
1207 |
+
function wpsc_fav_action( $actions ) {
|
1208 |
+
$actions['post-new.php?post_type=wpsc-product'] = array( 'New Product', 'manage_options' );
|
1209 |
+
return $actions;
|
1210 |
+
}
|
1211 |
+
add_filter( 'favorite_actions', 'wpsc_fav_action' );
|
1212 |
+
|
1213 |
+
/**
|
1214 |
+
* Enqueue the admin scripts
|
1215 |
+
*
|
1216 |
+
* @uses wp_enqueue_script() Enqueues scripts
|
1217 |
+
* @uses home_url() Returns the base url for the site
|
1218 |
+
*/
|
1219 |
+
function wpsc_print_admin_scripts() {
|
1220 |
+
$version_identifier = WPSC_VERSION . '.' . WPSC_MINOR_VERSION;
|
1221 |
+
wp_enqueue_script( 'wp-e-commerce-admin', WPSC_CORE_JS_URL . '/wp-e-commerce.js', array( 'jquery' ), $version_identifier );
|
1222 |
+
wp_localize_script( 'wp-e-commerce-admin', 'wpsc_ajax', wpsc_javascript_localizations() );
|
1223 |
+
}
|
1224 |
+
|
1225 |
+
/**
|
1226 |
+
* wpsc_ajax_ie_save save changes made using inline edit
|
1227 |
+
*
|
1228 |
+
* @since 3.8.0
|
1229 |
+
* @access public
|
1230 |
+
*
|
1231 |
+
* @uses get_post_type_object() Gets post object for given registered post type name
|
1232 |
+
* @uses current_user_can() Checks the capabilities of the current user
|
1233 |
+
* @uses absint() Converts to a nonnegative integer
|
1234 |
+
* @uses get_post() Gets the post object given post id
|
1235 |
+
* @uses wp_get_object_terms() Gets terms for given post object
|
1236 |
+
* @uses wp_update_post() Updates the post in the database
|
1237 |
+
* @uses get_product_meta() An alias for get_post_meta prefixes with the WPSC key
|
1238 |
+
* @uses wpsc_convert_weight() Converts to weight format specified by user
|
1239 |
+
* @uses json_encode() Encodes array for JS
|
1240 |
+
* @uses esc_js() Escape single quotes, htmlspecialchar " < > &, and fix line endings.
|
1241 |
+
*
|
1242 |
+
* @returns nothing
|
1243 |
+
*/
|
1244 |
+
function wpsc_ajax_ie_save() {
|
1245 |
+
|
1246 |
+
$product_post_type = get_post_type_object( 'wpsc-product' );
|
1247 |
+
|
1248 |
+
if ( !current_user_can( $product_post_type->cap->edit_posts ) ) {
|
1249 |
+
echo '({"error":"' . __( 'Error: you don\'t have required permissions to edit this product', 'wp-e-commerce' ) . '", "id": "'. esc_js( $_POST['id'] ) .'"})';
|
1250 |
+
die();
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
$id = absint( $_POST['id'] );
|
1254 |
+
$post = get_post( $_POST['id'] );
|
1255 |
+
$parent = get_post( $post->post_parent );
|
1256 |
+
$terms = wpsc_get_product_terms( $id, 'wpsc-variation', 'name' );
|
1257 |
+
|
1258 |
+
$product = array(
|
1259 |
+
'ID' => $_POST['id'],
|
1260 |
+
'post_title' => $parent->post_title . ' (' . implode( ', ', $terms ) . ')',
|
1261 |
+
);
|
1262 |
+
|
1263 |
+
$id = wp_update_post( $product );
|
1264 |
+
if ( $id > 0 ) {
|
1265 |
+
//need parent meta to know which weight unit we are using
|
1266 |
+
$parent_meta = get_product_meta($post->post_parent, 'product_metadata', true );
|
1267 |
+
$product_meta = get_product_meta( $product['ID'], 'product_metadata', true );
|
1268 |
+
if ( is_numeric( $_POST['weight'] ) || empty( $_POST['weight'] ) ){
|
1269 |
+
$product_meta['weight'] = wpsc_convert_weight($_POST['weight'], $parent_meta['weight_unit'], 'pound', true);
|
1270 |
+
$product_meta['weight_unit'] = $parent_meta['weight_unit'];
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
update_product_meta( $product['ID'], 'product_metadata', $product_meta );
|
1274 |
+
update_product_meta( $product['ID'], 'price', (float)$_POST['price'] );
|
1275 |
+
update_product_meta( $product['ID'], 'special_price', (float)$_POST['special_price'] );
|
1276 |
+
update_product_meta( $product['ID'], 'sku', sanitize_text_field( $_POST['sku'] ) );
|
1277 |
+
|
1278 |
+
if ( !is_numeric($_POST['stock']) )
|
1279 |
+
update_product_meta( $product['ID'], 'stock', '' );
|
1280 |
+
else
|
1281 |
+
update_product_meta( $product['ID'], 'stock', absint( $_POST['stock'] ) );
|
1282 |
+
|
1283 |
+
$meta = get_product_meta( $id, 'product_metadata', true );
|
1284 |
+
$price = get_product_meta( $id, 'price', true );
|
1285 |
+
$special_price = get_product_meta( $id, 'special_price', true );
|
1286 |
+
$sku = get_product_meta( $id, 'sku', true );
|
1287 |
+
$sku = ( $sku )?$sku:__('N/A', 'wp-e-commerce');
|
1288 |
+
$stock = get_product_meta( $id, 'stock', true );
|
1289 |
+
$stock = ( $stock === '' )?__('N/A', 'wp-e-commerce'):$stock;
|
1290 |
+
$results = array( 'id' => $id, 'title' => $post->post_title, 'weight' => wpsc_convert_weight($meta['weight'], 'pound', $parent_meta['weight_unit']), 'price' => wpsc_currency_display( $price ), 'special_price' => wpsc_currency_display( $special_price ), 'sku' => $sku, 'stock' => $stock );
|
1291 |
+
echo '(' . json_encode( $results ) . ')';
|
1292 |
+
die();
|
1293 |
+
} else {
|
1294 |
+
echo '({"error":"' . __( 'Error updating product', 'wp-e-commerce' ) . '", "id": "'. esc_js( $_POST['id'] ) .'"})';
|
1295 |
+
}
|
1296 |
+
die();
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
/**
|
1300 |
+
* @todo docs
|
1301 |
+
*
|
1302 |
+
* @uses add_meta_box Allows addition of metaboxes to the wpsc_add_meta_boxes admin
|
1303 |
+
*/
|
1304 |
+
function wpsc_add_meta_boxes(){
|
1305 |
+
add_meta_box( 'dashboard_right_now', __( 'Current Month', 'wp-e-commerce' ), 'wpsc_right_now', 'dashboard_page_wpsc-sales-logs', 'top' );
|
1306 |
+
}
|
1307 |
+
|
1308 |
+
/**
|
1309 |
+
* Displays notice if user has Great Britain selected as their base country
|
1310 |
+
* Since 3.8.9, we have deprecated Great Britain in favor of the UK
|
1311 |
+
*
|
1312 |
+
* @since 3.8.9
|
1313 |
+
* @access private
|
1314 |
+
* @link http://code.google.com/p/wp-e-commerce/issues/detail?id=1079
|
1315 |
+
*
|
1316 |
+
* @uses get_option() Retrieves option from the WordPress database
|
1317 |
+
* @uses get_outdate_isocodes() Returns outdated isocodes
|
1318 |
+
* @uses admin_url() Returns admin_url of the site
|
1319 |
+
*
|
1320 |
+
* @return string The admin notices for deprecated countries
|
1321 |
+
*/
|
1322 |
+
function _wpsc_action_admin_notices_deprecated_countries_notice() {
|
1323 |
+
$base_country = get_option( 'base_country' );
|
1324 |
+
|
1325 |
+
if ( ! in_array( $base_country, WPSC_Country::get_outdated_isocodes() ) )
|
1326 |
+
return;
|
1327 |
+
|
1328 |
+
switch ( $base_country ) {
|
1329 |
+
case 'YU':
|
1330 |
+
$message = __( 'Yugoslavia is no longer a valid official country name according to <a href="%1$s">ISO 3166</a> while both Serbia and Montenegro have been added to the country list.<br /> As a result, we highly recommend changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wp-e-commerce' );
|
1331 |
+
break;
|
1332 |
+
case 'UK':
|
1333 |
+
$message = __( 'Prior to WP eCommerce 3.8.9, in your database, United Kingdom\'s country code is UK and you have already selected that country code as the base country. However, now that you\'re using WP eCommerce version %3$s, it is recommended that you change your base country to the official "GB" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "UK" item will be marked as "U.K. (legacy)" on the country drop down list. Simply switch to the official "United Kingdom (ISO 3166)" to use the "GB" country code.' , 'wp-e-commerce' );
|
1334 |
+
break;
|
1335 |
+
case 'AN':
|
1336 |
+
$message = __( 'Netherlands Antilles is no longer a valid official country name according to <a href="%1$s">ISO 3166</a>.<br />Please consider changing your <em>Base Country</em> to reflect this change on the <a href="%2$s">General Settings</a> page.', 'wp-e-commerce' );
|
1337 |
+
case 'TP':
|
1338 |
+
$message = __( 'Prior to WP eCommerce 3.8.9, in your database, East Timor\'s country code is TP and you have already selected that country code as the base country. However, now that you\'re using WP eCommerce version %3$s, it is recommended that you change your base country to the official "TL" country code, according to <a href="%1$s">ISO 3166</a>.<br /> Please go to <a href="%2$s">General Settings</a> page to make this change.<br />The legacy "TP" item will be marked as "East Timor (legacy)" on the country drop down list. Simply switch to the official "Timor-Leste (ISO 3166)" to use the "TL" country code.' , 'wp-e-commerce' );
|
1339 |
+
break;
|
1340 |
+
}
|
1341 |
+
|
1342 |
+
$message = sprintf(
|
1343 |
+
/* message */ $message,
|
1344 |
+
/* %1$s */ 'http://en.wikipedia.org/wiki/ISO_3166-1',
|
1345 |
+
/* %2$s */ admin_url( 'options-general.php?page=wpsc-settings&tab=general' ),
|
1346 |
+
/* %3$s */ WPSC_VERSION
|
1347 |
+
);
|
1348 |
+
echo '<div id="wpsc-warning" class="error"><p>' . $message . '</p></div>';
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
add_action( 'admin_notices' , '_wpsc_action_admin_notices_deprecated_countries_notice' );
|
1352 |
+
add_action( 'wp_ajax_category_sort_order' , 'wpsc_ajax_set_category_order' );
|
1353 |
+
add_action( 'wp_ajax_variation_sort_order', 'wpsc_ajax_set_variation_order' );
|
1354 |
+
add_action( 'wp_ajax_wpsc_ie_save' , 'wpsc_ajax_ie_save' );
|
1355 |
+
add_action( 'in_admin_header' , 'wpsc_add_meta_boxes' );
|
1356 |
+
|
1357 |
+
/**
|
1358 |
+
* Deletes file associated with a product.
|
1359 |
+
*
|
1360 |
+
* @access private
|
1361 |
+
*
|
1362 |
+
* @uses $wpdb WordPress database object for queries
|
1363 |
+
* @uses prepare() Prepares a database query by escaping
|
1364 |
+
* @uses wp_delete_post() Removes a post attachment or page*
|
1365 |
+
*
|
1366 |
+
* @param int $product_id req The id of the product
|
1367 |
+
* @param string $file_name req The string
|
1368 |
+
*
|
1369 |
+
* @return mixed
|
1370 |
+
*
|
1371 |
+
*/
|
1372 |
+
function _wpsc_delete_file( $product_id, $file_name ) {
|
1373 |
+
global $wpdb;
|
1374 |
+
|
1375 |
+
$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 );
|
1376 |
+
$product_id_to_delete = $wpdb->get_var( $sql );
|
1377 |
+
|
1378 |
+
//Delete wpsc_download_status entry for this file
|
1379 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM `".WPSC_TABLE_DOWNLOAD_STATUS."` WHERE `fileid`=%d AND `product_id` = %d", $product_id_to_delete, $product_id ) );
|
1380 |
+
|
1381 |
+
return wp_delete_post( $product_id_to_delete, true );
|
1382 |
+
}
|
1383 |
+
|
1384 |
+
/**
|
1385 |
+
* @todo docs
|
1386 |
+
*
|
1387 |
+
* @access private
|
1388 |
+
*
|
1389 |
+
* @uses add_query_arg() Adds argument to the WordPress query
|
1390 |
+
* @uses update_option() Updates an option in the WordPress database given string and value
|
1391 |
+
* @uses get_option() Gets option from the database given string
|
1392 |
+
*/
|
1393 |
+
function _wpsc_admin_notices_3dot8dot9() {
|
1394 |
+
$message = '<p>' . __( 'You are currently using WP eCommerce. There have been major changes in WP eCommerce 3.8.9, so backward-compatibility with existing plugins might not always be guaranteed. If you are unsure, please roll back to 3.8.8.5, and set up a test site with 3.8.9 to make sure WP eCommerce 3.8.9 is compatible with your existing themes and plugins.<br />If you find any incompatibility issues, please <a href="%1$s">report them to us</a> as well as the other plugins or themes\' developers.' , 'wp-e-commerce' ) . '</p>';
|
1395 |
+
$message .= "\n<p>" . __( '<a href="%2$s">Hide this warning</a>', 'wp-e-commerce' ) . '</p>';
|
1396 |
+
$message = sprintf(
|
1397 |
+
$message,
|
1398 |
+
'https://wpecommerce.org/wp-e-commerce-3-8-9-compatibility-issues/',
|
1399 |
+
esc_url( add_query_arg( 'dismiss_389_upgrade_notice', 1 ) )
|
1400 |
+
);
|
1401 |
+
|
1402 |
+
echo '<div id="wpsc-3.8.9-notice" class="error">' . $message . '</div>';
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
/**
|
1406 |
+
* Checks to ensure that shipping is enabled, and one or both of the shipping/billing states are not displayed.
|
1407 |
+
* If those condtions are met, and the user has not previously dismissed the notice, then we notify them
|
1408 |
+
* that the shipping calculator now depend on those fields.
|
1409 |
+
*
|
1410 |
+
* @access private
|
1411 |
+
*
|
1412 |
+
* @uses add_query_arg() Adds argument to the WordPress query
|
1413 |
+
* @uses update_option() Updates an option in the WordPress database given string and value
|
1414 |
+
* @uses get_option() Gets option from the database given string
|
1415 |
+
*/
|
1416 |
+
function _wpsc_admin_notices_3_8_14_1() {
|
1417 |
+
|
1418 |
+
if ( get_option( 'do_not_use_shipping' ) ) {
|
1419 |
+
return;
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
global $wpdb;
|
1423 |
+
|
1424 |
+
$state_visibility = $wpdb->get_var( "SELECT COUNT(active) FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE unique_name IN ( 'billingstate', 'shippingstate' ) AND active = '1'" );
|
1425 |
+
|
1426 |
+
if ( '2' === $state_visibility ) {
|
1427 |
+
return;
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
$message = '<p>' . __( 'WP eCommerce has been updated, please confirm the checkout field display
|
1431 |
+
settings are correct for your store.<br><br><i>The visibility of the checkout billing and shipping
|
1432 |
+
drop downs that show states and provinces is now controlled by the "billingstate" and "shippingstate"
|
1433 |
+
options set in the <b>Store Settings</b> on the <b>Checkout</b> tab. Prior versions used
|
1434 |
+
the "billingcountry" and "shippingcountry" settings to control the visibility of the drop downs.</i>' , 'wp-e-commerce' ) . '</p>';
|
1435 |
+
$message .= "\n<p>" . __( '<a href="%s">Hide this warning</a>', 'wp-e-commerce' ) . '</p>';
|
1436 |
+
$message = sprintf(
|
1437 |
+
$message,
|
1438 |
+
esc_url( add_query_arg( 'dismiss_3_8_14_1_upgrade_notice', 1 ) )
|
1439 |
+
);
|
1440 |
+
|
1441 |
+
echo '<div id="wpsc-3-8-14-1-notice" class="error">' . $message . '</div>';
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
if ( ! get_option( 'wpsc_hide_3_8_14_1_notices' ) ) {
|
1445 |
+
add_action( 'admin_notices', '_wpsc_admin_notices_3_8_14_1' );
|
1446 |
+
|
1447 |
+
if ( isset( $_REQUEST['dismiss_3_8_14_1_upgrade_notice'] ) ) {
|
1448 |
+
update_option( 'wpsc_hide_3_8_14_1_notices', true );
|
1449 |
+
}
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
/**
|
1453 |
+
* @todo docs
|
1454 |
+
* @access private
|
1455 |
+
*
|
1456 |
+
* @uses add_query_arg() Adds argument to the WordPress query
|
1457 |
+
* @uses update_option() Updates an option in the WordPress database given string and value
|
1458 |
+
* @uses get_option() Gets option from the database given string
|
1459 |
+
*/
|
1460 |
+
function _wpsc_admin_notices_3dot8dot11() {
|
1461 |
+
$message = '<p>' . __( 'You are currently using WPeC %1$s. We introduced a regression in WPeC 3.8.10 which affects your customer user account page. We have included a fix for a <a href="%2$s">bug on the User Account management page</a>. We are able to fix this automatically on most sites, but it appears that you have made changes to your wpsc-user-log.php page. For that reason, we have some <a href="%3$s">simple instructions for you to follow</a> to resolve the issue. We are sorry for the inconvenience.' , 'wp-e-commerce' ) . '</p>';
|
1462 |
+
$message .= "\n<p>" . __( '<a href="%4$s">Hide this warning</a>', 'wp-e-commerce' ) . '</p>';
|
1463 |
+
$message = sprintf(
|
1464 |
+
$message,
|
1465 |
+
WPSC_VERSION,
|
1466 |
+
'https://github.com/wp-e-commerce/WP-e-Commerce/issues/359',
|
1467 |
+
'http://docs.wpecommerce.org/documentation/3-8-11-user-logs',
|
1468 |
+
esc_url( add_query_arg( 'dismiss_3811_upgrade_notice', 1 ) )
|
1469 |
+
);
|
1470 |
+
|
1471 |
+
echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
if ( isset( $_REQUEST['dismiss_3811_upgrade_notice'] ) )
|
1475 |
+
update_option( '_wpsc_3811_user_log_notice', false );
|
1476 |
+
|
1477 |
+
if ( get_option( '_wpsc_3811_user_log_notice' ) )
|
1478 |
+
add_action( 'admin_notices', '_wpsc_admin_notices_3dot8dot11' );
|
1479 |
+
|
1480 |
+
function _wpsc_notify_google_checkout_deprecation() {
|
1481 |
+
$gateways = get_option( 'custom_gateway_options', array() );
|
1482 |
+
|
1483 |
+
if ( false !== ( $key = array_search( 'google', $gateways ) ) ) {
|
1484 |
+
unset( $gateways[ $key ] );
|
1485 |
+
}
|
1486 |
+
|
1487 |
+
if ( empty( $gateways ) ) {
|
1488 |
+
$gateways[] = 'wpsc_merchant_testmode';
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
update_option( 'custom_gateway_options', $gateways );
|
1492 |
+
|
1493 |
+
$message = '<p>' . __( 'Effective November 20th, 2013, Google Checkout was shut down and is no longer processing payments. You are seeing this warning because it appears that Google Checkout was your payment gateway processor. If it was your sole processor, we have enabled the Test Gateway to ensure that orders are coming through on your site, but we highly recommend enabling a proper gateway. If you have no preference, we highly recommend Stripe.' , 'wp-e-commerce' ) . '</p>';
|
1494 |
+
|
1495 |
+
echo '<div id="wpsc-3.8.11-notice" class="error">' . $message . '</div>';
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
if ( in_array( 'google', get_option( 'custom_gateway_options', array() ) ) ) {
|
1499 |
+
add_action( 'admin_notices', '_wpsc_notify_google_checkout_deprecation' );
|
1500 |
+
}
|
1501 |
+
|
1502 |
+
/**
|
1503 |
+
* Adds links to premium support and documentation on WPeCommerce.org
|
1504 |
+
*
|
1505 |
+
* @since 3.9.0
|
1506 |
+
*
|
1507 |
+
* @param array $links Original links
|
1508 |
+
* @return array $links Updated links
|
1509 |
+
*/
|
1510 |
+
function wpsc_support_links( $links ) {
|
1511 |
+
$links[] = sprintf( '<a href="%s">%s</a>', _x( 'https://wpecommerce.org/support/', 'Support URL', 'wp-e-commerce' ), __( 'Support', 'wp-e-commerce' ) );
|
1512 |
+
$links[] = sprintf( '<a href="%s">%s</a>', _x( 'http://docs.wpecommerce.org/', 'Documentation URL', 'wp-e-commerce' ), __( 'Documentation', 'wp-e-commerce' ) );
|
1513 |
+
|
1514 |
+
return $links;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
add_filter( 'plugin_action_links_' . WPSC_PLUGIN_BASENAME, 'wpsc_support_links' );
|
1518 |
+
|
1519 |
+
/**
|
1520 |
+
* Adds removable query args, for compatibility with dismissable notices.
|
1521 |
+
*
|
1522 |
+
* @param array $args Array of removable query args.
|
1523 |
+
*
|
1524 |
+
* @since 4.0.0
|
1525 |
+
*
|
1526 |
+
* @return array $args Array of removable query args.
|
1527 |
+
*/
|
1528 |
+
function wpsc_removable_query_args( $args ) {
|
1529 |
+
$args[] = 'shipping_disabled';
|
1530 |
+
return $args;
|
1531 |
+
}
|
1532 |
+
|
1533 |
+
add_filter( 'removable_query_args', 'wpsc_removable_query_args' );
|
1534 |
+
|
1535 |
+
/**
|
1536 |
+
* Modify bulk post messages.
|
1537 |
+
*
|
1538 |
+
* @param array $bulk_messages Array of bulk messages.
|
1539 |
+
* @param int $bulk_counts The amount of messages affected.
|
1540 |
+
*
|
1541 |
+
* @since 4.0.0
|
1542 |
+
*
|
1543 |
+
* @return array Array of bulk messages.
|
1544 |
+
*/
|
1545 |
+
function wpsc_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
|
1546 |
+
$bulk_messages['wpsc-product'] = array(
|
1547 |
+
'updated' => _n( '%s product updated.', '%s products updated.', $bulk_counts['updated'], 'wp-e-commerce' ),
|
1548 |
+
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 product not updated, somebody is editing it.', 'wp-e-commerce' ) :
|
1549 |
+
_n( '%s product not updated, somebody is editing it.', '%s products not updated, somebody is editing them.', $bulk_counts['locked'], 'wp-e-commerce' ),
|
1550 |
+
'deleted' => _n( '%s product permanently deleted.', '%s products permanently deleted.', $bulk_counts['deleted'], 'wp-e-commerce' ),
|
1551 |
+
'trashed' => _n( '%s product moved to the Trash.', '%s products moved to the Trash.', $bulk_counts['trashed'], 'wp-e-commerce' ),
|
1552 |
+
'untrashed' => _n( '%s product restored from the Trash.', '%s products restored from the Trash.', $bulk_counts['untrashed'], 'wp-e-commerce' ),
|
1553 |
+
);
|
1554 |
+
|
1555 |
+
return $bulk_messages;
|
1556 |
+
}
|
1557 |
+
|
1558 |
+
add_filter( 'bulk_post_updated_messages', 'wpsc_bulk_updated_messages', 10, 2 );
|
1559 |
+
|
1560 |
+
/**
|
1561 |
+
* Add rating links to the admin dashboard
|
1562 |
+
*
|
1563 |
+
* @since 3.12
|
1564 |
+
* @global string $typenow
|
1565 |
+
* @param string $footer_text The existing footer text
|
1566 |
+
* @return string Changed $footer_text
|
1567 |
+
*/
|
1568 |
+
function wpsc_admin_rate_us( $footer_text ) {
|
1569 |
+
global $typenow;
|
1570 |
+
|
1571 |
+
if ( $typenow == 'wpsc-product' ) {
|
1572 |
+
$rate_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">WP eCommerce</a>! Please <a href="%2$s" target="_blank">rate us</a> on <a href="%2$s" target="_blank">WordPress.org</a>', 'wp-e-commerce' ),
|
1573 |
+
'https://wpecommerce.org',
|
1574 |
+
'https://wordpress.org/support/plugin/wp-e-commerce/reviews/?filter=5#new-post'
|
1575 |
+
);
|
1576 |
+
return str_replace( '</span>', '', $footer_text ) . ' | ' . $rate_text . '</span>';
|
1577 |
+
} else {
|
1578 |
+
return $footer_text;
|
1579 |
+
}
|
1580 |
+
}
|
1581 |
+
add_filter( 'admin_footer_text', 'wpsc_admin_rate_us' );
|
trunk/wpsc-admin/ajax-and-init.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WP eCommerce Admin AJAX functions
|
5 |
+
*
|
6 |
+
* These are the WPSC Admin AJAX functions
|
7 |
+
*
|
8 |
+
* @package wp-e-commerce
|
9 |
+
* @since 3.7.0
|
10 |
+
*
|
11 |
+
* @uses update_option() Updates option in the database given key and value
|
12 |
+
* @uses wp_delete_term() Removes term from the database
|
13 |
+
* @uses fetch_rss() DEPRECATED
|
14 |
+
* @uses wpsc_member_dedeactivate_subscriptions() @todo docs
|
15 |
+
* @uses wpsc_member_deactivate_subscriptions() @todo docs
|
16 |
+
* @uses wpsc_update_purchase_log_status() Updates the status of the logs for a purchase
|
17 |
+
* @uses transaction_results() Main function for creating purchase reports
|
18 |
+
* @uses wpsc_find_purchlog_status_name() Finds name of given status
|
19 |
+
*/
|
20 |
+
function wpsc_admin_ajax() {
|
21 |
+
|
22 |
+
if ( ! wpsc_is_store_admin() ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
global $wpdb;
|
27 |
+
|
28 |
+
if ( isset( $_POST['save_image_upload_state'] ) && $_POST['save_image_upload_state'] == 'true' && is_numeric( $_POST['image_upload_state'] ) ) {
|
29 |
+
$upload_state = (int)(bool)$_POST['image_upload_state'];
|
30 |
+
update_option( 'wpsc_use_flash_uploader', $upload_state );
|
31 |
+
exit( "done" );
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( isset( $_POST['remove_variation_value'] ) && $_POST['remove_variation_value'] == "true" && is_numeric( $_POST['variation_value_id'] ) ) {
|
35 |
+
$value_id = absint( $_GET['variation_value_id'] );
|
36 |
+
echo wp_delete_term( $value_id, 'wpsc-variation' );
|
37 |
+
exit();
|
38 |
+
}
|
39 |
+
|
40 |
+
if ( isset( $_REQUEST['log_state'] ) && $_REQUEST['log_state'] == "true" && is_numeric( $_POST['id'] ) && is_numeric( $_POST['value'] ) ) {
|
41 |
+
$newvalue = $_POST['value'];
|
42 |
+
if ( $_REQUEST['suspend'] == 'true' ) {
|
43 |
+
if ( $_REQUEST['value'] == 1 && function_exists('wpsc_member_dedeactivate_subscriptions'))
|
44 |
+
wpsc_member_dedeactivate_subscriptions( $_POST['id'] );
|
45 |
+
elseif( function_exists('wpsc_member_deactivate_subscriptions'))
|
46 |
+
wpsc_member_deactivate_subscriptions( $_POST['id'] );
|
47 |
+
|
48 |
+
exit();
|
49 |
+
} else {
|
50 |
+
|
51 |
+
$log_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id` = '%d' LIMIT 1", $_POST['id'] ), ARRAY_A );
|
52 |
+
if ( ($newvalue == 2) && function_exists( 'wpsc_member_activate_subscriptions' ) ) {
|
53 |
+
wpsc_member_activate_subscriptions( $_POST['id'] );
|
54 |
+
}
|
55 |
+
|
56 |
+
wpsc_update_purchase_log_status( $_POST['id'], $newvalue );
|
57 |
+
|
58 |
+
if ( ($newvalue > $log_data['processed']) && ($log_data['processed'] < 2) ) {
|
59 |
+
transaction_results( $log_data['sessionid'], false );
|
60 |
+
}
|
61 |
+
|
62 |
+
$status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
|
63 |
+
echo "document.getElementById(\"form_group_" . absint( $_POST['id'] ) . "_text\").innerHTML = '" . $status_name . "';\n";
|
64 |
+
|
65 |
+
|
66 |
+
$year = date( "Y" );
|
67 |
+
$month = date( "m" );
|
68 |
+
$start_timestamp = mktime( 0, 0, 0, $month, 1, $year );
|
69 |
+
$end_timestamp = mktime( 0, 0, 0, ($month + 1 ), 0, $year );
|
70 |
+
|
71 |
+
echo "document.getElementById(\"log_total_month\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price( $start_timestamp, $end_timestamp ) ) ) . "';\n";
|
72 |
+
echo "document.getElementById(\"log_total_absolute\").innerHTML = '" . addslashes( wpsc_currency_display( admin_display_total_price() ) ) . "';\n";
|
73 |
+
exit();
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( isset( $_REQUEST['ajax'] ) && isset( $_REQUEST['admin'] ) && ($_REQUEST['ajax'] == "true") && ($_REQUEST['admin'] == "true") )
|
79 |
+
add_action( 'admin_init', 'wpsc_admin_ajax' );
|
80 |
+
|
81 |
+
/**
|
82 |
+
* The function that changes the main currency in the DB
|
83 |
+
*
|
84 |
+
* @uses $wpdb WordPress database object for queries
|
85 |
+
*/
|
86 |
+
function wpsc_change_currency() {
|
87 |
+
|
88 |
+
if ( ! wpsc_is_store_admin() ) {
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
|
92 |
+
global $wpdb;
|
93 |
+
|
94 |
+
if ( is_numeric( $_POST['currencyid'] ) ) {
|
95 |
+
$currency_data = $wpdb->get_results( $wpdb->prepare( "SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`=%d LIMIT 1", $_POST['currencyid'] ), ARRAY_A );
|
96 |
+
$price_out = null;
|
97 |
+
if ( $currency_data[0]['symbol'] != '' ) {
|
98 |
+
$currency_sign = $currency_data[0]['symbol_html'];
|
99 |
+
} else {
|
100 |
+
$currency_sign = $currency_data[0]['code'];
|
101 |
+
}
|
102 |
+
echo $currency_sign;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_currency') )
|
106 |
+
add_action( 'admin_init', 'wpsc_change_currency' );
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @todo docs
|
110 |
+
* @uses $wpdb WordPress database object for queries
|
111 |
+
*/
|
112 |
+
function wpsc_rearrange_images() {
|
113 |
+
|
114 |
+
if ( ! wpsc_is_store_admin() ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
global $wpdb;
|
119 |
+
$images = explode( ",", $_POST['order'] );
|
120 |
+
$product_id = absint( $_POST['product_id'] );
|
121 |
+
$timestamp = time();
|
122 |
+
|
123 |
+
$new_main_image = null;
|
124 |
+
$have_set_first_item = false;
|
125 |
+
$i = 0;
|
126 |
+
foreach ( $images as $image ) {
|
127 |
+
if ( $image > 0 ) {
|
128 |
+
$wpdb->update(
|
129 |
+
$wpdb->posts,
|
130 |
+
array(
|
131 |
+
'menu_order' => $i
|
132 |
+
),
|
133 |
+
array(
|
134 |
+
'ID' => $image
|
135 |
+
),
|
136 |
+
'%d',
|
137 |
+
'%d'
|
138 |
+
);
|
139 |
+
$i++;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
$output = wpsc_main_product_image_menu( $product_id );
|
143 |
+
echo "image_menu = '';\n\r";
|
144 |
+
echo "image_id = '" . $new_main_image . "';\n\r";
|
145 |
+
exit();
|
146 |
+
}
|
147 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'rearrange_images') )
|
148 |
+
add_action( 'admin_init', 'wpsc_rearrange_images' );
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @todo docs
|
152 |
+
*
|
153 |
+
* @uses $wpdb WordPress database object for queries
|
154 |
+
* @uses $wp_rewrite Global variable instance of the WP_Rewrite Class
|
155 |
+
* @uses wp_get_referer() Retrieve referer from '_wp_http_referer' or HTTP referer.
|
156 |
+
* @uses add_query_arg() Retrieve a modified URL query string.
|
157 |
+
* @uses wp_redirect() Redirects to string given as argument
|
158 |
+
*/
|
159 |
+
function wpsc_clean_categories() {
|
160 |
+
|
161 |
+
if ( ! wpsc_is_store_admin() ) {
|
162 |
+
return;
|
163 |
+
}
|
164 |
+
|
165 |
+
global $wpdb, $wp_rewrite;
|
166 |
+
$sql_query = "SELECT `id`, `name`, `active` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`";
|
167 |
+
$sql_data = $wpdb->get_results( $sql_query, ARRAY_A );
|
168 |
+
foreach ( (array)$sql_data as $datarow ) {
|
169 |
+
if ( $datarow['active'] == 1 ) {
|
170 |
+
$tidied_name = strtolower( trim( $datarow['name'] ) );
|
171 |
+
$url_name = sanitize_title( $tidied_name );
|
172 |
+
$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 );
|
173 |
+
$extension_number = '';
|
174 |
+
|
175 |
+
if ( $similar_names['count'] > 0 )
|
176 |
+
$extension_number = (int)$similar_names['max_number'] + 2;
|
177 |
+
|
178 |
+
$url_name .= $extension_number;
|
179 |
+
|
180 |
+
$wpdb->update(
|
181 |
+
WPSC_TABLE_PRODUCT_CATEGORIES,
|
182 |
+
array(
|
183 |
+
'nice-name' => $url_name
|
184 |
+
),
|
185 |
+
array(
|
186 |
+
'id' => $datarow['id']
|
187 |
+
),
|
188 |
+
'%s',
|
189 |
+
'%d'
|
190 |
+
);
|
191 |
+
|
192 |
+
} else if ( $datarow['active'] == 0 ) {
|
193 |
+
$wpdb->update(
|
194 |
+
WPSC_TABLE_PRODUCT_CATEGORIES,
|
195 |
+
array(
|
196 |
+
'nice-name' => ''
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'id' => $datarow['id']
|
200 |
+
),
|
201 |
+
'%s',
|
202 |
+
'%d'
|
203 |
+
);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
$wp_rewrite->flush_rules();
|
207 |
+
$sendback = wp_get_referer();
|
208 |
+
|
209 |
+
if ( isset( $updated ) ) {
|
210 |
+
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
211 |
+
}
|
212 |
+
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) ) {
|
213 |
+
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
214 |
+
}
|
215 |
+
|
216 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
217 |
+
|
218 |
+
exit();
|
219 |
+
}
|
220 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clean_categories') )
|
221 |
+
add_action( 'admin_init', 'wpsc_clean_categories' );
|
trunk/wpsc-admin/ajax.php
ADDED
@@ -0,0 +1,1342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function _wpsc_ajax_purchase_log_refund_items() {
|
3 |
+
if ( isset( $_POST['order_id'] ) ) {
|
4 |
+
|
5 |
+
_wpsc_ajax_verify_nonce( 'purchase_log_refund_items' );
|
6 |
+
|
7 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
8 |
+
die( -1 );
|
9 |
+
}
|
10 |
+
|
11 |
+
$order_id = absint( $_POST['order_id'] );
|
12 |
+
$refund_reason = isset( $_POST['refund_reason'] ) ? sanitize_text_field( $_POST['refund_reason'] ) : '';
|
13 |
+
$refund_amount = isset( $_POST['refund_amount'] ) ? sanitize_text_field( $_POST['refund_amount'] ) : false;
|
14 |
+
$manual = $_POST['api_refund'] === 'true' ? false : true;
|
15 |
+
$response_data = array();
|
16 |
+
|
17 |
+
$log = new WPSC_Purchase_Log( $order_id );
|
18 |
+
$gateway_id = $log->get( 'gateway' );
|
19 |
+
$gateway = wpsc_get_payment_gateway( $gateway_id );
|
20 |
+
|
21 |
+
try {
|
22 |
+
// Validate that the refund can occur
|
23 |
+
$refund_amount = $refund_amount ? $refund_amount : $log->get( 'totalprice' );
|
24 |
+
|
25 |
+
if ( wpsc_payment_gateway_supports( $gateway_id, 'refunds' ) ) {
|
26 |
+
// Send api request to process refund. Returns Refund transaction ID
|
27 |
+
$result = $gateway->process_refund( $order_id, $refund_amount, $refund_reason, $manual );
|
28 |
+
|
29 |
+
do_action( 'wpsc_refund_processed', $log, $result, $refund_amount, $refund_reason );
|
30 |
+
|
31 |
+
if ( is_wp_error( $result ) ) {
|
32 |
+
throw new Exception( $result->get_error_message() );
|
33 |
+
} elseif ( ! $result ) {
|
34 |
+
throw new Exception( __( 'Refund failed', 'wp-e-commerce' ) );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( $log->get_remaining_refund() > 0 ) {
|
39 |
+
/**
|
40 |
+
* wpsc_order_partially_refunded.
|
41 |
+
*
|
42 |
+
* @since 4.0.0
|
43 |
+
*/
|
44 |
+
do_action( 'wpsc_order_partially_refunded', $log );
|
45 |
+
$response_data['status'] = 'partially_refunded';
|
46 |
+
|
47 |
+
} else {
|
48 |
+
/**
|
49 |
+
* wpsc_order_fully_refunded.
|
50 |
+
*
|
51 |
+
* @since 4.0.0
|
52 |
+
*/
|
53 |
+
do_action( 'wpsc_order_fully_refunded', $log );
|
54 |
+
$response_data['status'] = 'fully_refunded';
|
55 |
+
}
|
56 |
+
|
57 |
+
wp_send_json_success( $response_data );
|
58 |
+
|
59 |
+
} catch ( Exception $e ) {
|
60 |
+
wp_send_json_error( array( 'error' => $e->getMessage() ) );
|
61 |
+
}
|
62 |
+
}
|
63 |
+
return new WP_Error( 'wpsc_ajax_invalid_purchase_log_refund_items', __( 'Refund failed.', 'wp-e-commerce' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Verify nonce of an AJAX request
|
68 |
+
*
|
69 |
+
* @since 3.8.9
|
70 |
+
* @access private
|
71 |
+
*
|
72 |
+
* @uses WP_Error WordPress Error Class
|
73 |
+
* @uses wp_verify_nonce() Verify that correct nonce was used with time limit.
|
74 |
+
*
|
75 |
+
* @param string $ajax_action Name of AJAX action
|
76 |
+
* @return WP_Error|boolean True if nonce is valid. WP_Error if otherwise.
|
77 |
+
*/
|
78 |
+
function _wpsc_ajax_verify_nonce( $ajax_action ) {
|
79 |
+
// nonce can be passed with name wpsc_nonce or _wpnonce
|
80 |
+
$nonce = '';
|
81 |
+
|
82 |
+
if ( isset( $_REQUEST['nonce'] ) )
|
83 |
+
$nonce = $_REQUEST['nonce'];
|
84 |
+
elseif ( isset( $_REQUEST['_wpnonce'] ) )
|
85 |
+
$nonce = $_REQUEST['_wpnonce'];
|
86 |
+
else
|
87 |
+
return _wpsc_error_invalid_nonce();
|
88 |
+
|
89 |
+
// validate nonce
|
90 |
+
if ( ! wp_verify_nonce( $nonce, 'wpsc_ajax_' . $ajax_action ) )
|
91 |
+
return _wpsc_error_invalid_nonce();
|
92 |
+
|
93 |
+
return true;
|
94 |
+
}
|
95 |
+
|
96 |
+
function _wpsc_error_invalid_nonce() {
|
97 |
+
return new WP_Error( 'wpsc_ajax_invalid_nonce', __( 'Your session has expired. Please refresh the page and try again.', 'wp-e-commerce' ) );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Verify AJAX callback and call it if it exists.
|
102 |
+
*
|
103 |
+
* @since 3.8.9
|
104 |
+
* @access private
|
105 |
+
*
|
106 |
+
* @uses WP_Error WordPress Error object
|
107 |
+
*
|
108 |
+
* @param string $ajax_action Name of AJAX action
|
109 |
+
* @return WP_Error|array Array of response args if callback is valid. WP_Error if otherwise.
|
110 |
+
*/
|
111 |
+
function _wpsc_ajax_fire_callback( $ajax_action ) {
|
112 |
+
// if callback exists, call it and output JSON response
|
113 |
+
$callback = "_wpsc_ajax_{$ajax_action}";
|
114 |
+
|
115 |
+
if ( is_callable( $callback ) )
|
116 |
+
$result = call_user_func( $callback );
|
117 |
+
else
|
118 |
+
$result = new WP_Error( 'wpsc_invalid_ajax_callback', __( 'Invalid AJAX callback.', 'wp-e-commerce' ) );
|
119 |
+
|
120 |
+
return $result;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* AJAX handler for all WPEC ajax requests.
|
125 |
+
*
|
126 |
+
* This function automates nonce checking and outputs JSON response.
|
127 |
+
*
|
128 |
+
* @since 3.8.9
|
129 |
+
* @access private
|
130 |
+
*
|
131 |
+
* @uses _wpsc_ajax_fire_callback() Verify ajax callback if it exists
|
132 |
+
* @uses _wpsc_ajax_verify_nonce() Verify nonce of an ajax request
|
133 |
+
* @uses is_wp_error() Check whether variable is a WordPress Error.
|
134 |
+
*
|
135 |
+
* @return array $output json encoded response
|
136 |
+
*/
|
137 |
+
function _wpsc_ajax_handler() {
|
138 |
+
$ajax_action = str_replace( '-', '_', $_REQUEST['wpsc_action'] );
|
139 |
+
|
140 |
+
if ( is_callable( '_wpsc_ajax_verify_' . $ajax_action ) ) {
|
141 |
+
$result = call_user_func( '_wpsc_ajax_verify_' . $ajax_action );
|
142 |
+
} else {
|
143 |
+
$result = _wpsc_ajax_verify_nonce( $ajax_action );
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( ! is_wp_error( $result ) ) {
|
147 |
+
$result = _wpsc_ajax_fire_callback( $ajax_action );
|
148 |
+
}
|
149 |
+
|
150 |
+
$output = array(
|
151 |
+
'is_successful' => false,
|
152 |
+
);
|
153 |
+
|
154 |
+
if ( is_wp_error( $result ) ) {
|
155 |
+
$output['error'] = array(
|
156 |
+
'code' => $result->get_error_code(),
|
157 |
+
'messages' => $result->get_error_messages(),
|
158 |
+
'data' => $result->get_error_data(),
|
159 |
+
);
|
160 |
+
} else {
|
161 |
+
$output['is_successful'] = true;
|
162 |
+
$output['obj'] = $result;
|
163 |
+
}
|
164 |
+
|
165 |
+
echo json_encode( $output );
|
166 |
+
exit;
|
167 |
+
}
|
168 |
+
add_action( 'wp_ajax_wpsc_ajax', '_wpsc_ajax_handler' );
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Checks if WPSC is doing ajax
|
172 |
+
*
|
173 |
+
* @param string $action req The action we're checking
|
174 |
+
* @return bool True if doing ajax
|
175 |
+
*/
|
176 |
+
function wpsc_is_doing_ajax( $action = '' ) {
|
177 |
+
$ajax = defined( 'DOING_AJAX' ) && DOING_AJAX && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'wpsc_ajax';
|
178 |
+
|
179 |
+
if ( $action ) {
|
180 |
+
$ajax = $ajax && ! empty( $_REQUEST['wpsc_action'] ) && $action == str_replace( '-', '_', $_REQUEST['wpsc_action'] );
|
181 |
+
}
|
182 |
+
|
183 |
+
return $ajax;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Helper function that generates nonce for an AJAX action. Basically just a wrapper of
|
188 |
+
* wp_create_nonce() but automatically add prefix.
|
189 |
+
*
|
190 |
+
* @since 3.8.9
|
191 |
+
* @access private
|
192 |
+
*
|
193 |
+
* @uses wp_create_nonce() Creates a random one time use token
|
194 |
+
*
|
195 |
+
* @param string $action AJAX action without prefix
|
196 |
+
* @return string The generated nonce.
|
197 |
+
*/
|
198 |
+
function _wpsc_create_ajax_nonce( $ajax_action ) {
|
199 |
+
return wp_create_nonce( "wpsc_ajax_{$ajax_action}" );
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Add new variation set via AJAX.
|
204 |
+
*
|
205 |
+
* If the variation set name is the same as an existing variation set,
|
206 |
+
* the children variant terms will be added inside that existing set.
|
207 |
+
*
|
208 |
+
* @since 3.8.8
|
209 |
+
* @access private
|
210 |
+
*
|
211 |
+
* @uses term_exists() Returns true if term exists
|
212 |
+
* @uses get_term() Gets all term data by term_id
|
213 |
+
* @uses wp_insert_term() Inserts a term to the WordPress database
|
214 |
+
* @uses is_wp_error() Checks whether variable is a WordPress error
|
215 |
+
* @uses WP_Error WordPress Error class
|
216 |
+
* @uses clean_term_cache() Will remove all of the term ids from the cache.
|
217 |
+
* @uses delete_option() Deletes option from the database
|
218 |
+
* @uses wp_cache_set() Saves the data to the cache.
|
219 |
+
* @uses _get_term_hierarchy() Retrieves children of taxonomy as Term IDs.
|
220 |
+
* @uses wp_terms_checklist() Output an unordered list of checkbox <input> elements labelled
|
221 |
+
* @uses WPSC_Walker_Variation_Checklist Walker variation checklist
|
222 |
+
*
|
223 |
+
* @return array Response args
|
224 |
+
*/
|
225 |
+
function _wpsc_ajax_add_variation_set() {
|
226 |
+
$new_variation_set = $_POST['variation_set'];
|
227 |
+
$variants = preg_split( '/\s*,\s*/', $_POST['variants'] );
|
228 |
+
|
229 |
+
$return = array();
|
230 |
+
|
231 |
+
$parent_term_exists = term_exists( $new_variation_set, 'wpsc-variation' );
|
232 |
+
|
233 |
+
// only use an existing parent ID if the term is not a child term
|
234 |
+
if ( $parent_term_exists ) {
|
235 |
+
$parent_term = get_term( $parent_term_exists['term_id'], 'wpsc-variation' );
|
236 |
+
if ( $parent_term->parent == '0' )
|
237 |
+
$variation_set_id = $parent_term_exists['term_id'];
|
238 |
+
}
|
239 |
+
|
240 |
+
if ( empty( $variation_set_id ) ) {
|
241 |
+
$results = wp_insert_term( apply_filters( 'wpsc_new_variation_set', $new_variation_set ), 'wpsc-variation' );
|
242 |
+
if ( is_wp_error( $results ) )
|
243 |
+
return $results;
|
244 |
+
$variation_set_id = $results['term_id'];
|
245 |
+
}
|
246 |
+
|
247 |
+
if ( empty( $variation_set_id ) )
|
248 |
+
return new WP_Error( 'wpsc_invalid_variation_id', __( 'Cannot retrieve the variation set in order to proceed.', 'wp-e-commerce' ) );
|
249 |
+
|
250 |
+
foreach ( $variants as $variant ) {
|
251 |
+
$results = wp_insert_term( apply_filters( 'wpsc_new_variant', $variant, $variation_set_id ), 'wpsc-variation', array( 'parent' => $variation_set_id ) );
|
252 |
+
|
253 |
+
if ( is_wp_error( $results ) )
|
254 |
+
return $results;
|
255 |
+
|
256 |
+
$inserted_variants[] = $results['term_id'];
|
257 |
+
}
|
258 |
+
|
259 |
+
require_once( 'includes/walker-variation-checklist.php' );
|
260 |
+
|
261 |
+
if ( ! version_compare( $GLOBALS['wp_version'], '3.8.3', '>' ) ) {
|
262 |
+
|
263 |
+
/* --- DIRTY HACK START --- */
|
264 |
+
/*
|
265 |
+
There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485. Fixed in 3.9.
|
266 |
+
The next 3 lines will delete children term cache for wpsc-variation.
|
267 |
+
Without this hack, the new child variations won't be displayed on "Variations" page and
|
268 |
+
also won't be displayed in wp_terms_checklist() call below.
|
269 |
+
*/
|
270 |
+
clean_term_cache( $variation_set_id, 'wpsc-variation' );
|
271 |
+
delete_option('wpsc-variation_children');
|
272 |
+
wp_cache_set( 'last_changed', 1, 'terms' );
|
273 |
+
_get_term_hierarchy('wpsc-variation');
|
274 |
+
/* --- DIRTY HACK END --- */
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
ob_start();
|
279 |
+
|
280 |
+
wp_terms_checklist( (int) $_POST['post_id'], array(
|
281 |
+
'taxonomy' => 'wpsc-variation',
|
282 |
+
'descendants_and_self' => $variation_set_id,
|
283 |
+
'walker' => new WPSC_Walker_Variation_Checklist( $inserted_variants ),
|
284 |
+
'checked_ontop' => false,
|
285 |
+
) );
|
286 |
+
|
287 |
+
$content = ob_get_clean();
|
288 |
+
|
289 |
+
$return = array(
|
290 |
+
'variation_set_id' => $variation_set_id,
|
291 |
+
'inserted_variants' => $inserted_variants,
|
292 |
+
'content' => $content,
|
293 |
+
);
|
294 |
+
|
295 |
+
return $return;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Display gateway settings form via AJAX
|
300 |
+
*
|
301 |
+
* @since 3.8.9
|
302 |
+
* @access private
|
303 |
+
*
|
304 |
+
* @uses WPSC_Settings_Tab_Gateway
|
305 |
+
* @uses WPSC_Settings_Tab_Gateway::display_payment_gateway_settings_form() Displays payment gateway form
|
306 |
+
*
|
307 |
+
* @return array Response args
|
308 |
+
*/
|
309 |
+
function _wpsc_ajax_payment_gateway_settings_form() {
|
310 |
+
|
311 |
+
require_once( 'settings-page.php' );
|
312 |
+
require_once( 'includes/settings-tabs/gateway.php' );
|
313 |
+
|
314 |
+
$return = array();
|
315 |
+
ob_start();
|
316 |
+
$tab = new WPSC_Settings_Tab_Gateway();
|
317 |
+
$tab->display_payment_gateway_settings_form();
|
318 |
+
$return['content'] = ob_get_clean();
|
319 |
+
|
320 |
+
return $return;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Display shipping module settings form via AJAX
|
325 |
+
*
|
326 |
+
* @since 3.8.9
|
327 |
+
* @access private
|
328 |
+
*
|
329 |
+
* @uses WPSC_Settings_Table_Shipping
|
330 |
+
* @uses WPSC_Settings_Table_Shipping::display_shipping_module_settings_form() Displays shipping module form
|
331 |
+
*
|
332 |
+
* @return array $return Response args
|
333 |
+
*/
|
334 |
+
function _wpsc_ajax_shipping_module_settings_form() {
|
335 |
+
require_once( 'settings-page.php' );
|
336 |
+
require_once( 'includes/settings-tabs/shipping.php' );
|
337 |
+
|
338 |
+
$return = array();
|
339 |
+
ob_start();
|
340 |
+
$tab = new WPSC_Settings_Tab_Shipping();
|
341 |
+
$tab->display_shipping_module_settings_form();
|
342 |
+
$return['content'] = ob_get_clean();
|
343 |
+
|
344 |
+
return $return;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Display settings tab via AJAX
|
349 |
+
*
|
350 |
+
* @since 3.8.9
|
351 |
+
* @access private
|
352 |
+
*
|
353 |
+
* @uses WPSC_Settings_Page
|
354 |
+
* @uses WPSC_Settings_Page::display_current_tab() Shows current tab of settings page
|
355 |
+
*
|
356 |
+
* @return array $return Response args
|
357 |
+
*/
|
358 |
+
function _wpsc_ajax_navigate_settings_tab() {
|
359 |
+
require_once( 'settings-page.php' );
|
360 |
+
|
361 |
+
$return = array();
|
362 |
+
ob_start();
|
363 |
+
$settings_page = new WPSC_Settings_Page( $_POST['tab'] );
|
364 |
+
$settings_page->display_current_tab();
|
365 |
+
$return['content'] = ob_get_clean();
|
366 |
+
|
367 |
+
return $return;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Display base region list in Store Settings -> General
|
372 |
+
*
|
373 |
+
* @since 3.8.9
|
374 |
+
* @access private
|
375 |
+
*
|
376 |
+
* @uses WPSC_Settings_Tab_General
|
377 |
+
* @uses WPSC_Settings_Tab_General::display_region_drop_down() Shows region dropdown
|
378 |
+
*
|
379 |
+
* @return array $return Response args
|
380 |
+
*/
|
381 |
+
function _wpsc_ajax_display_region_list() {
|
382 |
+
require_once( 'settings-page.php' );
|
383 |
+
require_once( 'includes/settings-tabs/general.php' );
|
384 |
+
|
385 |
+
$return = array();
|
386 |
+
ob_start();
|
387 |
+
$tab = new WPSC_Settings_Tab_General();
|
388 |
+
$tab->display_region_drop_down();
|
389 |
+
$return['content'] = ob_get_clean();
|
390 |
+
|
391 |
+
return $return;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Save tracking ID of a sales log.
|
396 |
+
*
|
397 |
+
* @since 3.8.9
|
398 |
+
* @access private
|
399 |
+
*
|
400 |
+
* @uses WP_Error WordPress Error class
|
401 |
+
*
|
402 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise.
|
403 |
+
*/
|
404 |
+
function _wpsc_ajax_purchase_log_save_tracking_id() {
|
405 |
+
global $wpdb;
|
406 |
+
|
407 |
+
$result = $wpdb->update(
|
408 |
+
WPSC_TABLE_PURCHASE_LOGS,
|
409 |
+
array(
|
410 |
+
'track_id' => $_POST['value']
|
411 |
+
),
|
412 |
+
array(
|
413 |
+
'id' => $_POST['log_id']
|
414 |
+
),
|
415 |
+
'%s',
|
416 |
+
'%d'
|
417 |
+
);
|
418 |
+
|
419 |
+
if ( ! $result )
|
420 |
+
return new WP_Error( 'wpsc_cannot_save_tracking_id', __( "Couldn't save tracking ID of the transaction. Please try again.", 'wp-e-commerce' ) );
|
421 |
+
|
422 |
+
$return = array(
|
423 |
+
'rows_affected' => $result,
|
424 |
+
'id' => $_POST['log_id'],
|
425 |
+
'track_id' => $_POST['value'],
|
426 |
+
);
|
427 |
+
|
428 |
+
return $return;
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Send sales log tracking email via AJAX
|
433 |
+
*
|
434 |
+
* @since 3.8.9
|
435 |
+
* @access private
|
436 |
+
*
|
437 |
+
* @uses $wpdb WordPress database object for queries
|
438 |
+
* @uses get_option() Gets option from DB given key
|
439 |
+
* @uses add_filter() Calls 'wp_mail_from' which can replace the from email address
|
440 |
+
* @uses add_filter() Calls 'wp_mail_from_name' allows replacement of the from name on WordPress emails
|
441 |
+
* @uses wp_mail() All the emailses in WordPress are sent through this function
|
442 |
+
* @uses WP_Error WordPress Error class
|
443 |
+
*
|
444 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
445 |
+
*/
|
446 |
+
function _wpsc_ajax_purchase_log_send_tracking_email() {
|
447 |
+
global $wpdb;
|
448 |
+
|
449 |
+
$id = absint( $_POST['log_id'] );
|
450 |
+
$sql = $wpdb->prepare( "SELECT `track_id` FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE `id`=%d LIMIT 1", $id );
|
451 |
+
$trackingid = $wpdb->get_var( $sql );
|
452 |
+
|
453 |
+
$message = get_option( 'wpsc_trackingid_message' );
|
454 |
+
$message = str_replace( '%trackid%', $trackingid, $message );
|
455 |
+
$message = str_replace( '%shop_name%', get_option( 'blogname' ), $message );
|
456 |
+
|
457 |
+
$email = wpsc_get_buyers_email( $id );
|
458 |
+
|
459 |
+
$subject = get_option( 'wpsc_trackingid_subject' );
|
460 |
+
$subject = str_replace( '%shop_name%', get_option( 'blogname' ), $subject );
|
461 |
+
|
462 |
+
add_filter( 'wp_mail_from', 'wpsc_replace_reply_address', 0 );
|
463 |
+
add_filter( 'wp_mail_from_name', 'wpsc_replace_reply_name', 0 );
|
464 |
+
|
465 |
+
$result = wp_mail( $email, $subject, $message);
|
466 |
+
|
467 |
+
if ( ! $result ) {
|
468 |
+
return new WP_Error( 'wpsc_cannot_send_tracking_email', __( "Couldn't send tracking email. Please try again.", 'wp-e-commerce' ) );
|
469 |
+
}
|
470 |
+
|
471 |
+
$return = array(
|
472 |
+
'id' => $id,
|
473 |
+
'tracking_id' => $trackingid,
|
474 |
+
'subject' => $subject,
|
475 |
+
'message' => $message,
|
476 |
+
'email' => $email
|
477 |
+
);
|
478 |
+
|
479 |
+
return $return;
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Do purchase log action link via AJAX
|
484 |
+
*
|
485 |
+
* @since 3.9.0
|
486 |
+
* @access private
|
487 |
+
*
|
488 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
489 |
+
*/
|
490 |
+
function _wpsc_ajax_purchase_log_action_link() {
|
491 |
+
|
492 |
+
if ( isset( $_POST['log_id'] ) && isset( $_POST['purchase_log_action_link'] ) && isset( $_POST['purchase_log_action_nonce'] ) ) {
|
493 |
+
|
494 |
+
$log_id = absint( $_POST['log_id'] );
|
495 |
+
$purchase_log_action_link = sanitize_key( $_POST['purchase_log_action_link'] );
|
496 |
+
|
497 |
+
// Verify action nonce
|
498 |
+
if ( wp_verify_nonce( $_POST['purchase_log_action_nonce'], 'wpsc_purchase_log_action_ajax_' . $purchase_log_action_link ) ) {
|
499 |
+
|
500 |
+
// Expected to receive success = true by default, or false on error.
|
501 |
+
$return = apply_filters( 'wpsc_purchase_log_action_ajax-' . $purchase_log_action_link, array( 'success' => null ), $log_id );
|
502 |
+
|
503 |
+
} else {
|
504 |
+
$return = _wpsc_error_invalid_nonce();
|
505 |
+
}
|
506 |
+
|
507 |
+
if ( ! is_wp_error( $return ) ) {
|
508 |
+
$return['log_id'] = $log_id;
|
509 |
+
$return['purchase_log_action_link'] = $purchase_log_action_link;
|
510 |
+
$return['success'] = isset( $return['success'] ) ? (bool) $return['success'] : null;
|
511 |
+
}
|
512 |
+
|
513 |
+
return $return;
|
514 |
+
|
515 |
+
}
|
516 |
+
|
517 |
+
return new WP_Error( 'wpsc_ajax_invalid_purchase_log_action', __( 'Purchase log action failed.', 'wp-e-commerce' ) );
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
/**
|
522 |
+
* Remove purchase log item.
|
523 |
+
*
|
524 |
+
* @since 4.0
|
525 |
+
* @access private
|
526 |
+
*
|
527 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
528 |
+
*/
|
529 |
+
function _wpsc_ajax_remove_log_item() {
|
530 |
+
|
531 |
+
if ( isset( $_POST['item_id'], $_POST['log_id'] ) ) {
|
532 |
+
|
533 |
+
$item_id = absint( $_POST['item_id'] );
|
534 |
+
$log_id = absint( $_POST['log_id'] );
|
535 |
+
$log = new WPSC_Purchase_Log( $log_id );
|
536 |
+
|
537 |
+
if ( $log->remove_item( $item_id ) ) {
|
538 |
+
return _wpsc_init_log_items( $log );
|
539 |
+
}
|
540 |
+
}
|
541 |
+
|
542 |
+
return new WP_Error( 'wpsc_ajax_invalid_remove_log_item', __( 'Removing log item failed.', 'wp-e-commerce' ) );
|
543 |
+
}
|
544 |
+
|
545 |
+
/**
|
546 |
+
* Update purchase log item quantity.
|
547 |
+
*
|
548 |
+
* @since 4.0
|
549 |
+
* @access private
|
550 |
+
*
|
551 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
552 |
+
*/
|
553 |
+
function _wpsc_ajax_update_log_item_qty() {
|
554 |
+
|
555 |
+
if ( isset( $_POST['item_id'], $_POST['log_id'], $_POST['qty'] ) ) {
|
556 |
+
|
557 |
+
if ( empty( $_POST['qty'] ) ) {
|
558 |
+
return _wpsc_ajax_remove_log_item();
|
559 |
+
}
|
560 |
+
|
561 |
+
$item_id = absint( $_POST['item_id'] );
|
562 |
+
$log_id = absint( $_POST['log_id'] );
|
563 |
+
$log = new WPSC_Purchase_Log( $log_id );
|
564 |
+
$result = $log->update_item( $item_id, array( 'quantity' => absint( $_POST['qty'] ) ) );
|
565 |
+
|
566 |
+
if ( 0 === $result ) {
|
567 |
+
return true;
|
568 |
+
} elseif ( false !== $result ) {
|
569 |
+
return _wpsc_init_log_items( $log );
|
570 |
+
}
|
571 |
+
}
|
572 |
+
|
573 |
+
return new WP_Error( 'wpsc_ajax_invalid_update_log_item_qty', __( 'Updating log item quantity failed.', 'wp-e-commerce' ) );
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Add purchase log item.
|
578 |
+
*
|
579 |
+
* @since 4.0
|
580 |
+
* @access private
|
581 |
+
*
|
582 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
583 |
+
*/
|
584 |
+
function _wpsc_ajax_add_log_item() {
|
585 |
+
global $wpsc_cart;
|
586 |
+
|
587 |
+
if (
|
588 |
+
isset( $_POST['product_ids'], $_POST['log_id'] )
|
589 |
+
&& is_array( $_POST['product_ids'] )
|
590 |
+
&& ! empty( $_POST['product_ids'] )
|
591 |
+
) {
|
592 |
+
|
593 |
+
$existing = isset( $_POST['existing'] ) && is_array( $_POST['existing'] )
|
594 |
+
? array_map( 'absint', $_POST['existing'] )
|
595 |
+
: false;
|
596 |
+
|
597 |
+
$item_ids = array();
|
598 |
+
$log = null;
|
599 |
+
|
600 |
+
foreach ( $_POST['product_ids'] as $product_id ) {
|
601 |
+
$product_id = absint( $product_id );
|
602 |
+
$log_id = absint( $_POST['log_id'] );
|
603 |
+
$log = new WPSC_Purchase_Log( $log_id );
|
604 |
+
|
605 |
+
// Is product is already in item list?
|
606 |
+
if ( $existing && in_array( $product_id, $existing, true ) ) {
|
607 |
+
$item = $log->get_item_from_product_id( $product_id );
|
608 |
+
if ( $item ) {
|
609 |
+
// Update item quantity...
|
610 |
+
$log->update_item( $item->id, array( 'quantity' => ++$item->quantity ) );
|
611 |
+
// And move on.
|
612 |
+
continue;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
$item = new wpsc_cart_item( $product_id, array(), $wpsc_cart );
|
617 |
+
$item_id = $item->save_to_db( $log_id );
|
618 |
+
$item_ids[] = absint( $item_id );
|
619 |
+
}
|
620 |
+
|
621 |
+
return _wpsc_init_log_items( $log, $item_ids );
|
622 |
+
}
|
623 |
+
|
624 |
+
return new WP_Error( 'wpsc_ajax_invalid_add_log_item', __( 'Adding log item failed.', 'wp-e-commerce' ) );
|
625 |
+
}
|
626 |
+
|
627 |
+
function _wpsc_init_log_items( WPSC_Purchase_Log $log, $item_ids = array() ) {
|
628 |
+
$log->init_items();
|
629 |
+
|
630 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
|
631 |
+
|
632 |
+
$html = '';
|
633 |
+
$htmls = array();
|
634 |
+
$htmls[] = array();
|
635 |
+
|
636 |
+
while ( wpsc_have_purchaselog_details() ) {
|
637 |
+
wpsc_the_purchaselog_item();
|
638 |
+
|
639 |
+
ob_start();
|
640 |
+
WPSC_Purchase_Log_Page::purchase_log_cart_item( $log->can_edit() );
|
641 |
+
$cart_item = ob_get_clean();
|
642 |
+
|
643 |
+
$htmls[ wpsc_purchaselog_details_id() ] = $cart_item;
|
644 |
+
if ( ! empty( $item_ids ) && in_array( absint( wpsc_purchaselog_details_id() ), $item_ids, true ) ) {
|
645 |
+
$html .= $cart_item;
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
return array(
|
650 |
+
'quantities' => wp_list_pluck( $log->get_items(), 'quantity', 'id' ),
|
651 |
+
'html' => $html,
|
652 |
+
'htmls' => $htmls,
|
653 |
+
'discount_data' => wpsc_purchlog_has_discount_data() ? esc_html__( 'Coupon Code', 'wp-e-commerce' ) . ': ' . wpsc_display_purchlog_discount_data() : '',
|
654 |
+
'discount' => wpsc_display_purchlog_discount(),
|
655 |
+
'total_taxes' => wpsc_display_purchlog_taxes(),
|
656 |
+
'total_shipping' => wpsc_display_purchlog_shipping( false, true ),
|
657 |
+
'final_total' => wpsc_display_purchlog_totalprice(),
|
658 |
+
);
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* Edit log contact details.
|
663 |
+
*
|
664 |
+
* @since 4.0
|
665 |
+
* @access private
|
666 |
+
*
|
667 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
668 |
+
*/
|
669 |
+
function _wpsc_ajax_edit_contact_details() {
|
670 |
+
|
671 |
+
if ( isset( $_POST['log_id'], $_POST['fields'] ) && ! empty( $_POST['fields'] ) ) {
|
672 |
+
|
673 |
+
// Parse the URL query string of the fields array.
|
674 |
+
parse_str( $_POST['fields'], $fields );
|
675 |
+
|
676 |
+
$log_id = absint( $_POST['log_id'] );
|
677 |
+
$log = new WPSC_Purchase_Log( $log_id );
|
678 |
+
|
679 |
+
if ( isset( $fields['wpsc_checkout_details'] ) && is_array( $fields['wpsc_checkout_details'] ) ) {
|
680 |
+
$details = wp_unslash( $fields['wpsc_checkout_details'] );
|
681 |
+
|
682 |
+
// Save the new/updated contact details.
|
683 |
+
WPSC_Checkout_Form_Data::save_form(
|
684 |
+
$log,
|
685 |
+
WPSC_Checkout_Form::get()->get_fields(),
|
686 |
+
array_map( 'sanitize_text_field', $details ),
|
687 |
+
false
|
688 |
+
);
|
689 |
+
|
690 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
|
691 |
+
|
692 |
+
$log->init_items();
|
693 |
+
|
694 |
+
// Fetch the shipping/billing formatted output.
|
695 |
+
|
696 |
+
ob_start();
|
697 |
+
WPSC_Purchase_Log_Page::shipping_address_output();
|
698 |
+
$shipping = ob_get_clean();
|
699 |
+
|
700 |
+
ob_start();
|
701 |
+
WPSC_Purchase_Log_Page::billing_address_output();
|
702 |
+
$billing = ob_get_clean();
|
703 |
+
|
704 |
+
ob_start();
|
705 |
+
WPSC_Purchase_Log_Page::payment_details_output();
|
706 |
+
$payment = ob_get_clean();
|
707 |
+
|
708 |
+
return compact( 'shipping', 'billing', 'payment' );
|
709 |
+
|
710 |
+
}
|
711 |
+
|
712 |
+
}
|
713 |
+
|
714 |
+
return new WP_Error( 'wpsc_ajax_invalid_edit_contact_details', __( 'Failed to update contact details for log.', 'wp-e-commerce' ) );
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* Add a note to a log.
|
719 |
+
*
|
720 |
+
* @since 4.0
|
721 |
+
* @access private
|
722 |
+
*
|
723 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
724 |
+
*/
|
725 |
+
function _wpsc_ajax_add_note() {
|
726 |
+
|
727 |
+
if ( isset( $_POST['log_id'], $_POST['note'] ) && ! empty( $_POST['note'] ) ) {
|
728 |
+
|
729 |
+
$result = wpsc_purchlogs_update_notes(
|
730 |
+
absint( $_POST['log_id'] ),
|
731 |
+
wp_kses_post( wp_unslash( $_POST['note'] ) )
|
732 |
+
);
|
733 |
+
|
734 |
+
if ( $result instanceof WPSC_Purchase_Log_Notes ) {
|
735 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/display-sales-logs.php' );
|
736 |
+
|
737 |
+
$data = $result->get_data();
|
738 |
+
$keys = array_keys( $data );
|
739 |
+
$note_id = end( $keys );
|
740 |
+
$note_args = end( $data );
|
741 |
+
|
742 |
+
ob_start();
|
743 |
+
WPSC_Purchase_Log_Page::note_output( $result, $note_id, $note_args );
|
744 |
+
$row = ob_get_clean();
|
745 |
+
|
746 |
+
return $row;
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
return new WP_Error( 'wpsc_ajax_invalid_add_note', __( 'Failed adding log note.', 'wp-e-commerce' ) );
|
751 |
+
}
|
752 |
+
|
753 |
+
/**
|
754 |
+
* Delete a note from a log.
|
755 |
+
*
|
756 |
+
* @since 4.0
|
757 |
+
* @access private
|
758 |
+
*
|
759 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
760 |
+
*/
|
761 |
+
function _wpsc_ajax_delete_note() {
|
762 |
+
|
763 |
+
if ( isset( $_POST['log_id'], $_POST['note'] ) && is_numeric( $_POST['note'] ) ) {
|
764 |
+
|
765 |
+
$notes = wpsc_get_order_notes( absint( $_POST['log_id'] ) );
|
766 |
+
$notes->remove( absint( $_POST['note'] ) )->save();
|
767 |
+
|
768 |
+
return true;
|
769 |
+
}
|
770 |
+
|
771 |
+
return new WP_Error( 'wpsc_ajax_invalid_delete_note', __( 'Failed to delete log note.', 'wp-e-commerce' ) );
|
772 |
+
}
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Search for products.
|
776 |
+
*
|
777 |
+
* @since 4.0
|
778 |
+
* @access private
|
779 |
+
*
|
780 |
+
* @return array|WP_Error $return Response args if successful, WP_Error if otherwise
|
781 |
+
*/
|
782 |
+
function _wpsc_ajax_search_products() {
|
783 |
+
$pt_object = get_post_type_object( 'wpsc-product' );
|
784 |
+
|
785 |
+
$s = wp_unslash( $_POST['search'] );
|
786 |
+
$args = array(
|
787 |
+
'post_type' => 'wpsc-product',
|
788 |
+
'post_status' => array( 'publish', 'inherit' ),
|
789 |
+
'posts_per_page' => 50,
|
790 |
+
);
|
791 |
+
if ( '' !== $s ) {
|
792 |
+
$args['s'] = $s;
|
793 |
+
}
|
794 |
+
|
795 |
+
$posts = get_posts( $args );
|
796 |
+
|
797 |
+
if ( ! $posts ) {
|
798 |
+
return new WP_Error( 'wpsc_ajax_invalid_search_products', __( 'No items found.', 'wp-e-commerce' ) );
|
799 |
+
}
|
800 |
+
|
801 |
+
$alt = '';
|
802 |
+
foreach ( $posts as $post ) {
|
803 |
+
$post->title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' );
|
804 |
+
$alt = ( 'alternate' === $alt ) ? '' : 'alternate';
|
805 |
+
|
806 |
+
$post->status = $post->post_status;
|
807 |
+
|
808 |
+
switch ( $post->post_status ) {
|
809 |
+
case 'publish' :
|
810 |
+
case 'private' :
|
811 |
+
$post->status = __( 'Published' );
|
812 |
+
break;
|
813 |
+
case 'future' :
|
814 |
+
$post->status = __( 'Scheduled' );
|
815 |
+
break;
|
816 |
+
case 'pending' :
|
817 |
+
$post->status = __( 'Pending Review' );
|
818 |
+
break;
|
819 |
+
case 'draft' :
|
820 |
+
$post->status = __( 'Draft' );
|
821 |
+
break;
|
822 |
+
default :
|
823 |
+
$post->status = $post->post_status;
|
824 |
+
break;
|
825 |
+
}
|
826 |
+
|
827 |
+
if ( '0000-00-00 00:00:00' === $post->post_date ) {
|
828 |
+
$post->time = '';
|
829 |
+
} else {
|
830 |
+
/* translators: date format in table columns, see https://secure.php.net/date */
|
831 |
+
$post->time = mysql2date( __( 'Y/m/d' ), $post->post_date );
|
832 |
+
}
|
833 |
+
|
834 |
+
$post->class = $alt;
|
835 |
+
}
|
836 |
+
|
837 |
+
return $posts;
|
838 |
+
}
|
839 |
+
|
840 |
+
/**
|
841 |
+
* Handle AJAX clear downloads lock purchase log action
|
842 |
+
*
|
843 |
+
* The _wpsc_ajax_purchase_log_action_link() function which triggers this function is nonce
|
844 |
+
* and capability checked in _wpsc_ajax_handler().
|
845 |
+
*
|
846 |
+
* @since 3.9.0
|
847 |
+
* @access private
|
848 |
+
*
|
849 |
+
* @param array $response AJAX response.
|
850 |
+
* @param int $log_id Purchase log ID.
|
851 |
+
*/
|
852 |
+
function wpsc_purchase_log_action_ajax_downloads_lock( $response, $log_id ) {
|
853 |
+
|
854 |
+
$response['success'] = wpsc_purchlog_clear_download_items( $log_id );
|
855 |
+
|
856 |
+
return $response;
|
857 |
+
|
858 |
+
}
|
859 |
+
add_action( 'wpsc_purchase_log_action_ajax-downloads_lock', 'wpsc_purchase_log_action_ajax_downloads_lock', 10, 2 );
|
860 |
+
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Handle AJAX email receipt purchase log action
|
864 |
+
*
|
865 |
+
* The _wpsc_ajax_purchase_log_action_link() function which triggers this function is nonce
|
866 |
+
* and capability checked in _wpsc_ajax_handler().
|
867 |
+
*
|
868 |
+
* @since 3.9.0
|
869 |
+
* @access private
|
870 |
+
*
|
871 |
+
* @param array $response AJAX response.
|
872 |
+
* @param int $log_id Purchase log ID.
|
873 |
+
*/
|
874 |
+
function wpsc_purchase_log_action_ajax_email_receipt( $response, $log_id ) {
|
875 |
+
|
876 |
+
$response['success'] = wpsc_purchlog_resend_email( $log_id );
|
877 |
+
|
878 |
+
return $response;
|
879 |
+
|
880 |
+
}
|
881 |
+
add_action( 'wpsc_purchase_log_action_ajax-email_receipt', 'wpsc_purchase_log_action_ajax_email_receipt', 10, 2 );
|
882 |
+
|
883 |
+
/**
|
884 |
+
* Delete an attached downloadable file via AJAX.
|
885 |
+
*
|
886 |
+
* @since 3.8.9
|
887 |
+
* @access private
|
888 |
+
*
|
889 |
+
* @uses _wpsc_delete_file() Deletes files associated with a product
|
890 |
+
* @uses WP_Error WordPress error class
|
891 |
+
*
|
892 |
+
* @return WP_Error|array $return Response args if successful, WP_Error if otherwise
|
893 |
+
*/
|
894 |
+
function _wpsc_ajax_delete_file() {
|
895 |
+
$product_id = absint( $_REQUEST['product_id'] );
|
896 |
+
$file_name = basename( $_REQUEST['file_name'] );
|
897 |
+
|
898 |
+
$result = _wpsc_delete_file( $product_id, $file_name );
|
899 |
+
|
900 |
+
if ( ! $result )
|
901 |
+
return new WP_Error( 'wpsc_cannot_delete_file', __( "Couldn't delete the file. Please try again.", 'wp-e-commerce' ) );
|
902 |
+
|
903 |
+
$return = array(
|
904 |
+
'product_id' => $product_id,
|
905 |
+
'file_name' => $file_name,
|
906 |
+
);
|
907 |
+
|
908 |
+
return $return;
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Delete a product meta via AJAX
|
913 |
+
*
|
914 |
+
* @since 3.8.9
|
915 |
+
* @access private
|
916 |
+
*
|
917 |
+
* @uses delete_meta() Deletes metadata by meta id
|
918 |
+
* @uses WP_Error WordPress error class
|
919 |
+
*
|
920 |
+
* @return WP_Error|array $return Response args if successful, WP_Error if otherwise
|
921 |
+
*/
|
922 |
+
function _wpsc_ajax_remove_product_meta() {
|
923 |
+
$meta_id = (int) $_POST['meta_id'];
|
924 |
+
if ( ! delete_meta( $meta_id ) )
|
925 |
+
return new WP_Error( 'wpsc_cannot_delete_product_meta', __( "Couldn't delete product meta. Please try again.", 'wp-e-commerce' ) );
|
926 |
+
|
927 |
+
return array( 'meta_id' => $meta_id );
|
928 |
+
}
|
929 |
+
|
930 |
+
/**
|
931 |
+
* Modify a purchase log's status.
|
932 |
+
*
|
933 |
+
* @since 3.8.9
|
934 |
+
* @access private
|
935 |
+
*
|
936 |
+
* @uses wpsc_purchlog_edit_status() Edits purchase log status
|
937 |
+
* @uses WP_Error WordPress Error class
|
938 |
+
* @uses WPSC_Purchase_Log_List_Table
|
939 |
+
* @uses WPSC_Purchase_Log_List_Table::prepare_items()
|
940 |
+
* @uses WPSC_Purchase_Log_List_Table::views()
|
941 |
+
* @uses WPSC_Purchase_Log_List_Table::display_tablenav() @todo docs
|
942 |
+
*
|
943 |
+
* @return WP_Error|array $return Response args if successful, WP_Error if otherwise.
|
944 |
+
*/
|
945 |
+
function _wpsc_ajax_change_purchase_log_status() {
|
946 |
+
$result = wpsc_purchlog_edit_status( $_POST['id'], $_POST['new_status'] );
|
947 |
+
if ( ! $result )
|
948 |
+
return new WP_Error( 'wpsc_cannot_edit_purchase_log_status', __( "Couldn't modify purchase log's status. Please try again.", 'wp-e-commerce' ) );
|
949 |
+
|
950 |
+
$args = array();
|
951 |
+
|
952 |
+
$args['screen'] = 'dashboard_page_wpsc-sales-logs';
|
953 |
+
|
954 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-list-table-class.php' );
|
955 |
+
$purchaselog_table = new WPSC_Purchase_Log_List_Table( $args );
|
956 |
+
$purchaselog_table->prepare_items();
|
957 |
+
|
958 |
+
ob_start();
|
959 |
+
$purchaselog_table->views();
|
960 |
+
$views = ob_get_clean();
|
961 |
+
|
962 |
+
ob_start();
|
963 |
+
$purchaselog_table->display_tablenav( 'top' );
|
964 |
+
$tablenav_top = ob_get_clean();
|
965 |
+
|
966 |
+
ob_start();
|
967 |
+
$purchaselog_table->display_tablenav( 'bottom' );
|
968 |
+
$tablenav_bottom = ob_get_clean();
|
969 |
+
|
970 |
+
$return = array(
|
971 |
+
'id' => $_POST['id'],
|
972 |
+
'new_status' => $_POST['new_status'],
|
973 |
+
'views' => $views,
|
974 |
+
'tablenav_top' => $tablenav_top,
|
975 |
+
'tablenav_bottom' => $tablenav_bottom,
|
976 |
+
);
|
977 |
+
|
978 |
+
return $return;
|
979 |
+
}
|
980 |
+
|
981 |
+
/**
|
982 |
+
* Save product ordering after drag-and-drop sorting
|
983 |
+
*
|
984 |
+
* @since 3.8.9
|
985 |
+
* @access private
|
986 |
+
*
|
987 |
+
* @uses $wpdb WordPress database object for use in queries
|
988 |
+
* @uses wp_update_post() Updates post based on passed $args. Needs a post_id
|
989 |
+
* @uses WP_Error WordPress Error class
|
990 |
+
*
|
991 |
+
* @return WP_Error|array Response args if successful, WP_Error if otherwise
|
992 |
+
*/
|
993 |
+
function _wpsc_ajax_save_product_order() {
|
994 |
+
|
995 |
+
$products = array( );
|
996 |
+
foreach ( $_POST['post'] as $product ) {
|
997 |
+
$products[] = (int) str_replace( 'post-', '', $product );
|
998 |
+
}
|
999 |
+
|
1000 |
+
$failed = array();
|
1001 |
+
foreach ( $products as $order => $product_id ) {
|
1002 |
+
$result = wp_update_post( array(
|
1003 |
+
'ID' => $product_id,
|
1004 |
+
'menu_order' => $order,
|
1005 |
+
) );
|
1006 |
+
|
1007 |
+
if ( ! $result )
|
1008 |
+
$failed[] = $product_id;
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// Validate data before exposing to action
|
1012 |
+
$category = isset( $_POST['category_id'] ) ? get_term_by( 'slug', $_POST['category_id'], 'wpsc_product_category' ) : false;
|
1013 |
+
do_action( 'wpsc_save_product_order', $products, $category );
|
1014 |
+
|
1015 |
+
if ( ! empty( $failed ) ) {
|
1016 |
+
$error_data = array(
|
1017 |
+
'failed_ids' => $failed,
|
1018 |
+
);
|
1019 |
+
|
1020 |
+
return new WP_Error( 'wpsc_cannot_save_product_sort_order', __( "Couldn't save the products' sort order. Please try again.", 'wp-e-commerce' ), $error_data );
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
return array(
|
1024 |
+
'ids' => $products,
|
1025 |
+
);
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
/**
|
1029 |
+
* Save Category Product Order
|
1030 |
+
*
|
1031 |
+
* Note that this uses the 'term_order' field in the 'term_relationships' table to store
|
1032 |
+
* the order. Although this column presently seems to be unused by WordPress, the intention
|
1033 |
+
* is it should be used to store the order of terms associates to a post, not the order
|
1034 |
+
* of posts as we are doing. This shouldn't be an issue for WPEC unless WordPress adds a UI
|
1035 |
+
* for this. More info at http://core.trac.wordpress.org/ticket/9547
|
1036 |
+
*
|
1037 |
+
* @since 3.9
|
1038 |
+
* @access private
|
1039 |
+
*
|
1040 |
+
* @uses $wpdb WordPress database object used for queries
|
1041 |
+
*/
|
1042 |
+
function _wpsc_save_category_product_order( $products, $category ) {
|
1043 |
+
global $wpdb;
|
1044 |
+
|
1045 |
+
// Only save category product order if in category
|
1046 |
+
if ( ! $category )
|
1047 |
+
return;
|
1048 |
+
|
1049 |
+
// Save product order in term_relationships table
|
1050 |
+
foreach ( $products as $order => $product_id ) {
|
1051 |
+
$wpdb->update( $wpdb->term_relationships,
|
1052 |
+
array( 'term_order' => $order ),
|
1053 |
+
array( 'object_id' => $product_id, 'term_taxonomy_id' => $category->term_taxonomy_id ),
|
1054 |
+
array( '%d' ),
|
1055 |
+
array( '%d', '%d' )
|
1056 |
+
);
|
1057 |
+
}
|
1058 |
+
}
|
1059 |
+
add_action( 'wpsc_save_product_order', '_wpsc_save_category_product_order', 10, 2 );
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* Update Checkout fields order
|
1063 |
+
*
|
1064 |
+
* @since 3.8.9
|
1065 |
+
* @access private
|
1066 |
+
*
|
1067 |
+
* @uses $wpdb WordPress database object used for queries
|
1068 |
+
* @uses WP_Error WordPress error class
|
1069 |
+
*
|
1070 |
+
* @return array|WP_Error Response args or WP_Error
|
1071 |
+
*/
|
1072 |
+
function _wpsc_ajax_update_checkout_fields_order() {
|
1073 |
+
global $wpdb;
|
1074 |
+
|
1075 |
+
$checkout_fields = $_REQUEST['sort_order'];
|
1076 |
+
$order = 1;
|
1077 |
+
$failed = array();
|
1078 |
+
$modified = array();
|
1079 |
+
foreach ( $checkout_fields as &$checkout_field ) {
|
1080 |
+
// ignore new fields
|
1081 |
+
if ( strpos( $checkout_field, 'new-field' ) === 0 )
|
1082 |
+
continue;
|
1083 |
+
$checkout_field = absint( preg_replace('/[^0-9]+/', '', $checkout_field ) );
|
1084 |
+
$result = $wpdb->update(
|
1085 |
+
WPSC_TABLE_CHECKOUT_FORMS,
|
1086 |
+
array(
|
1087 |
+
'checkout_order' => $order
|
1088 |
+
),
|
1089 |
+
array(
|
1090 |
+
'id' => $checkout_field
|
1091 |
+
),
|
1092 |
+
'%d',
|
1093 |
+
'%d'
|
1094 |
+
);
|
1095 |
+
$order ++;
|
1096 |
+
if ( $result === false )
|
1097 |
+
$failed[] = $checkout_field;
|
1098 |
+
elseif ( $result > 0 )
|
1099 |
+
$modified[] = $checkout_field;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
if ( ! empty( $failed ) )
|
1103 |
+
return new WP_Error( 'wpsc_cannot_save_checkout_field_sort_order', __( "Couldn't save checkout field sort order. Please try again.", 'wp-e-commerce' ), array( 'failed_ids' => $failed ) );
|
1104 |
+
|
1105 |
+
return array(
|
1106 |
+
'modified' => $modified,
|
1107 |
+
);
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
/**
|
1111 |
+
* Save a downloadable file to a product
|
1112 |
+
*
|
1113 |
+
* @since 3.8.9
|
1114 |
+
* @access private
|
1115 |
+
*
|
1116 |
+
* @uses $wpdb WordPress database object for use in queries
|
1117 |
+
* @uses _wpsc_create_ajax_nonce() Creates nonce for an ajax action
|
1118 |
+
* @uses wpsc_get_mimetype() Returns mimetype of file
|
1119 |
+
* @uses wp_insert_post() Inserts post to WordPress database
|
1120 |
+
* @uses wp_nonce_url() Retrieve URL with nonce added to URL query.
|
1121 |
+
* @uses wpsc_convert_bytes() Formats bytes
|
1122 |
+
* @uses wpsc_get_extension() Gets extension of file
|
1123 |
+
* @uses esc_attr() Escapes HTML attributes
|
1124 |
+
* @uses _x() Retrieve translated string with gettext context
|
1125 |
+
*
|
1126 |
+
* @return array|WP_Error Response args if successful, WP_Error if otherwise.
|
1127 |
+
*/
|
1128 |
+
function _wpsc_ajax_upload_product_file() {
|
1129 |
+
global $wpdb;
|
1130 |
+
$product_id = absint( $_POST["product_id"] );
|
1131 |
+
$output = '';
|
1132 |
+
$delete_nonce = _wpsc_create_ajax_nonce( 'delete_file' );
|
1133 |
+
|
1134 |
+
foreach ( $_POST["select_product_file"] as $selected_file ) {
|
1135 |
+
// if we already use this file, there is no point doing anything more.
|
1136 |
+
$sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'wpsc-product-file' AND post_title = %s", $selected_file ); // TODO it's safer to select by post ID, in that case we will use get_posts()
|
1137 |
+
$file_post_data = $wpdb->get_row( $sql, ARRAY_A );
|
1138 |
+
$selected_file_path = WPSC_FILE_DIR . basename( $selected_file );
|
1139 |
+
$file_url = WPSC_FILE_URL . basename( $selected_file );
|
1140 |
+
$file_size = filesize( $selected_file_path );
|
1141 |
+
if ( empty( $file_post_data ) ) {
|
1142 |
+
$type = wpsc_get_mimetype( $selected_file_path );
|
1143 |
+
$attachment = array(
|
1144 |
+
'post_mime_type' => $type,
|
1145 |
+
'post_parent' => $product_id,
|
1146 |
+
'post_title' => $selected_file,
|
1147 |
+
'post_content' => '',
|
1148 |
+
'post_type' => "wpsc-product-file",
|
1149 |
+
'post_status' => 'inherit'
|
1150 |
+
);
|
1151 |
+
$id = wp_insert_post( $attachment );
|
1152 |
+
} else {
|
1153 |
+
// already attached
|
1154 |
+
if ( $file_post_data['post_parent'] == $product_id )
|
1155 |
+
continue;
|
1156 |
+
$type = $file_post_data["post_mime_type"];
|
1157 |
+
$url = $file_post_data["guid"];
|
1158 |
+
$title = $file_post_data["post_title"];
|
1159 |
+
$content = $file_post_data["post_content"];
|
1160 |
+
// Construct the attachment
|
1161 |
+
$attachment = array(
|
1162 |
+
'post_mime_type' => $type,
|
1163 |
+
'guid' => $url,
|
1164 |
+
'post_parent' => absint( $product_id ),
|
1165 |
+
'post_title' => $title,
|
1166 |
+
'post_content' => $content,
|
1167 |
+
'post_type' => "wpsc-product-file",
|
1168 |
+
'post_status' => 'inherit'
|
1169 |
+
);
|
1170 |
+
// Save the data
|
1171 |
+
$id = wp_insert_post( $attachment );
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
$deletion_url = wp_nonce_url( "admin.php?wpsc_admin_action=delete_file&file_name={$attachment['post_title']}&product_id={$product_id}", 'delete_file_' . $attachment['post_title'] );
|
1175 |
+
|
1176 |
+
$output .= '<tr class="wpsc_product_download_row">';
|
1177 |
+
$output .= '<td style="padding-right: 30px;">' . $attachment['post_title'] . '</td>';
|
1178 |
+
$output .= '<td>' . wpsc_convert_byte( $file_size ) . '</td>';
|
1179 |
+
$output .= '<td>.' . wpsc_get_extension( $attachment['post_title'] ) . '</td>';
|
1180 |
+
$output .= "<td><a data-file-name='" . esc_attr( $attachment['post_title'] ) . "' data-product-id='" . esc_attr( $product_id ) . "' data-nonce='" . esc_attr( $delete_nonce ) . "' class='file_delete_button' href='{$deletion_url}' >" . _x( 'Delete', 'Digital Download UI row', 'wp-e-commerce' ) . "</a></td>";
|
1181 |
+
$output .= '<td><a href=' .$file_url .'>' . _x( 'Download', 'Digital Download UI row', 'wp-e-commerce' ) . '</a></td>';
|
1182 |
+
$output .= '</tr>';
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
return array(
|
1186 |
+
'content' => $output,
|
1187 |
+
);
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
/**
|
1191 |
+
* Generate variations
|
1192 |
+
*
|
1193 |
+
* @since 3.8.9
|
1194 |
+
* @access private
|
1195 |
+
*
|
1196 |
+
* @uses wpsc_update_variations() Updates product variations given
|
1197 |
+
* @uses wpsc_admin_product_listing() DEPRECATED
|
1198 |
+
*
|
1199 |
+
* @return array|WP_Error Response args if successful, WP_Error if otherwise
|
1200 |
+
*/
|
1201 |
+
function _wpsc_ajax_update_variations() {
|
1202 |
+
$product_id = absint( $_REQUEST["product_id"] );
|
1203 |
+
wpsc_update_variations();
|
1204 |
+
|
1205 |
+
ob_start();
|
1206 |
+
wpsc_admin_product_listing( $product_id );
|
1207 |
+
$content = ob_get_clean();
|
1208 |
+
|
1209 |
+
return array( 'content' => $content );
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
/**
|
1213 |
+
* Display the shortcode generator.
|
1214 |
+
*
|
1215 |
+
* @since 3.8.9
|
1216 |
+
* @access private
|
1217 |
+
*/
|
1218 |
+
function _wpsc_action_tinymce_window() {
|
1219 |
+
require_once( WPSC_CORE_JS_PATH . '/tinymce3/window.php' );
|
1220 |
+
exit;
|
1221 |
+
}
|
1222 |
+
add_action( 'wp_ajax_wpsc_tinymce_window', '_wpsc_action_tinymce_window' );
|
1223 |
+
|
1224 |
+
/**
|
1225 |
+
* Add tax rate
|
1226 |
+
* @since 3.8.9
|
1227 |
+
* @access private
|
1228 |
+
*
|
1229 |
+
* @uses wpec_taxes_controller Contains all the logic to communicate with the taxes system
|
1230 |
+
* @uses wpec_taxes_controller::wpec_taxes::wpec_taxes_get_regions() Gets tax regions based on input country code
|
1231 |
+
* @uses wpec_taxes_controller::wpec_taxes_build_select_options() Returns HTML formatted options from input array
|
1232 |
+
* @uses wpec_taxes_controller::wpec_taxes_build_form() Builds the tax rate form
|
1233 |
+
* @uses wpec_taxes_controller::wpec_taxes::wpec_taxes_get_band_from_index() Retrieves tax band for given name
|
1234 |
+
*
|
1235 |
+
* @return array|WP_Error Response args if successful, WP_Error if otherwise
|
1236 |
+
*/
|
1237 |
+
function _wpsc_ajax_add_tax_rate() {
|
1238 |
+
//include taxes controller
|
1239 |
+
$wpec_taxes_controller = new wpec_taxes_controller;
|
1240 |
+
|
1241 |
+
switch ( $_REQUEST['wpec_taxes_action'] ) {
|
1242 |
+
case 'wpec_taxes_get_regions':
|
1243 |
+
$regions = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_regions( $_REQUEST['country_code'] );
|
1244 |
+
$key = $_REQUEST['current_key'];
|
1245 |
+
$type = $_REQUEST['taxes_type'];
|
1246 |
+
$default_option = array( 'region_code' => 'all-markets', 'name' => 'All Markets' );
|
1247 |
+
$select_settings = array(
|
1248 |
+
'id' => "{$type}-region-{$key}",
|
1249 |
+
'name' => "wpsc_options[wpec_taxes_{$type}][{$key}][region_code]",
|
1250 |
+
'class' => 'wpsc-taxes-region-drop-down'
|
1251 |
+
);
|
1252 |
+
$returnable = $wpec_taxes_controller->wpec_taxes_build_select_options( $regions, 'region_code', 'name', $default_option, $select_settings );
|
1253 |
+
break;
|
1254 |
+
}// switch
|
1255 |
+
|
1256 |
+
return array(
|
1257 |
+
'content' => $returnable,
|
1258 |
+
);
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
/**
|
1262 |
+
* Displays the WPSC product variations table
|
1263 |
+
*
|
1264 |
+
* @uses check_admin_referrer() Makes sure user was referred from another admin page
|
1265 |
+
* @uses WPSC_Product_Variations_Page The WPSC Product variations class
|
1266 |
+
* @uses WPSC_Product_Variations_Page::display() Displays the product variations page
|
1267 |
+
*/
|
1268 |
+
function wpsc_product_variations_table() {
|
1269 |
+
check_admin_referer( 'wpsc_product_variations_table' );
|
1270 |
+
set_current_screen( 'wpsc-product' );
|
1271 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-variations-page.class.php' );
|
1272 |
+
$page = new WPSC_Product_Variations_Page();
|
1273 |
+
$page->display();
|
1274 |
+
|
1275 |
+
exit;
|
1276 |
+
}
|
1277 |
+
add_action( 'wp_ajax_wpsc_product_variations_table', 'wpsc_product_variations_table' );
|
1278 |
+
|
1279 |
+
/**
|
1280 |
+
* @access private
|
1281 |
+
*
|
1282 |
+
* @uses current_user_can() Checks user capabilities given string
|
1283 |
+
* @uses delete_post_thumbnail() Deletes post thumbnail given thumbnail id
|
1284 |
+
* @uses set_post_thumbnail() Sets post thumbnail given post_id and thumbnail_id
|
1285 |
+
* @uses wpsc_the_product_thumbnail() Returns URL to the product thumbnail
|
1286 |
+
*
|
1287 |
+
* @return array $response Includes the thumbnail URL and success bool value
|
1288 |
+
*/
|
1289 |
+
function _wpsc_ajax_set_variation_product_thumbnail() {
|
1290 |
+
$response = array(
|
1291 |
+
'success' => false
|
1292 |
+
);
|
1293 |
+
|
1294 |
+
$post_ID = intval( $_POST['post_id'] );
|
1295 |
+
if ( current_user_can( 'edit_post', $post_ID ) ) {
|
1296 |
+
$thumbnail_id = intval( $_POST['thumbnail_id'] );
|
1297 |
+
|
1298 |
+
if ( $thumbnail_id == '-1' )
|
1299 |
+
delete_post_thumbnail( $post_ID );
|
1300 |
+
|
1301 |
+
set_post_thumbnail( $post_ID, $thumbnail_id );
|
1302 |
+
|
1303 |
+
$thumbnail = wpsc_the_product_thumbnail( 50, 50, $post_ID, '' );
|
1304 |
+
if ( ! $thumbnail )
|
1305 |
+
$thumbnail = WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif';
|
1306 |
+
$response['src'] = $thumbnail;
|
1307 |
+
$response['success'] = true;
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
echo json_encode( $response );
|
1311 |
+
exit;
|
1312 |
+
}
|
1313 |
+
add_action( 'wp_ajax_wpsc_set_variation_product_thumbnail', '_wpsc_ajax_set_variation_product_thumbnail' );
|
1314 |
+
|
1315 |
+
/**
|
1316 |
+
* Delete WPSC product image from gallery
|
1317 |
+
*
|
1318 |
+
* @uses check_ajax_referer() Verifies the AJAX request to prevent processing external requests
|
1319 |
+
* @uses get_post_meta() Returns meta from the specified post
|
1320 |
+
* @uses update_post_meta() Updates meta from the specified post
|
1321 |
+
*/
|
1322 |
+
function product_gallery_image_delete_action() {
|
1323 |
+
|
1324 |
+
$product_gallery = array();
|
1325 |
+
$gallery_image_id = $gallery_post_id = '';
|
1326 |
+
|
1327 |
+
$gallery_image_id = absint($_POST['product_gallery_image_id']);
|
1328 |
+
$gallery_post_id = absint($_POST['product_gallery_post_id']);
|
1329 |
+
|
1330 |
+
check_ajax_referer( 'wpsc_gallery_nonce', 'wpsc_gallery_nonce_check' );
|
1331 |
+
|
1332 |
+
$product_gallery = get_post_meta( $gallery_post_id, '_wpsc_product_gallery', true );
|
1333 |
+
|
1334 |
+
foreach ( $product_gallery as $index => $image_id ) {
|
1335 |
+
if ( $image_id == $gallery_image_id ) {
|
1336 |
+
unset( $product_gallery[$index] );
|
1337 |
+
}
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
update_post_meta( $gallery_post_id, '_wpsc_product_gallery', $product_gallery );
|
1341 |
+
}
|
1342 |
+
add_action( 'wp_ajax_product_gallery_image_delete', 'product_gallery_image_delete_action' );
|
trunk/wpsc-admin/css/admin.css
ADDED
@@ -0,0 +1,2677 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WPSC Admin CSS file
|
3 |
+
*/
|
4 |
+
|
5 |
+
table.wp-list-table .column-featured {
|
6 |
+
width: 30px;
|
7 |
+
}
|
8 |
+
|
9 |
+
table.wp-list-table .column-price,
|
10 |
+
table.wp-list-table .column-sale_price {
|
11 |
+
width: 8%;
|
12 |
+
}
|
13 |
+
|
14 |
+
table.wp-list-table .column-SKU {
|
15 |
+
width: 11%;
|
16 |
+
}
|
17 |
+
|
18 |
+
table.wp-list-table .column-stock {
|
19 |
+
width: 8%;
|
20 |
+
}
|
21 |
+
|
22 |
+
table.wp-list-table .column-weight {
|
23 |
+
width: 7%;
|
24 |
+
}
|
25 |
+
|
26 |
+
table.wp-list-table .column-cats {
|
27 |
+
width: 15%;
|
28 |
+
}
|
29 |
+
|
30 |
+
ul.variation_checkboxes li {
|
31 |
+
margin: 1px 0 3px;
|
32 |
+
}
|
33 |
+
|
34 |
+
/* This is the variation meta box stuff need to put it in the correct place - mychelle */
|
35 |
+
|
36 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td span {
|
37 |
+
display: none;
|
38 |
+
}
|
39 |
+
|
40 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.weight {
|
41 |
+
width: 81px;
|
42 |
+
}
|
43 |
+
|
44 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.stock {
|
45 |
+
width: 110px;
|
46 |
+
}
|
47 |
+
|
48 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.price {
|
49 |
+
width: 125px;
|
50 |
+
}
|
51 |
+
|
52 |
+
div#wpsc_product_variation_forms table#wpsc_product_list tbody tr td.post-title {
|
53 |
+
width: 115px;
|
54 |
+
}
|
55 |
+
|
56 |
+
.wpsc_ie_stock[disabled] {
|
57 |
+
background-color: #f6f6f6;
|
58 |
+
}
|
59 |
+
|
60 |
+
div#wpsc_add_variant_desc,
|
61 |
+
div#wpsc_add_variation_desc {
|
62 |
+
float: left;
|
63 |
+
margin: 33px 0px 30px 20px;
|
64 |
+
}
|
65 |
+
|
66 |
+
div#wpsc_add_variation_desc {
|
67 |
+
width: 300px;
|
68 |
+
}
|
69 |
+
|
70 |
+
div#wpsc_add_variant_desc {
|
71 |
+
width: 200px;
|
72 |
+
}
|
73 |
+
|
74 |
+
div#wpsc_add_variant {
|
75 |
+
float: left;
|
76 |
+
max-width: 245px;
|
77 |
+
}
|
78 |
+
|
79 |
+
div #add_new_variation {
|
80 |
+
float: left;
|
81 |
+
width: 215px;
|
82 |
+
}
|
83 |
+
|
84 |
+
input.wpsc_ie_field {
|
85 |
+
margin-bottom:10px;
|
86 |
+
}
|
87 |
+
|
88 |
+
.wpsc_ie_save {
|
89 |
+
margin-bottom: 5px;
|
90 |
+
}
|
91 |
+
|
92 |
+
.wpsc_trackingid_row {
|
93 |
+
margin-left: 20px;
|
94 |
+
}
|
95 |
+
|
96 |
+
ul.children {
|
97 |
+
padding-left: 5px;
|
98 |
+
}
|
99 |
+
|
100 |
+
.category_indenter {
|
101 |
+
float: left;
|
102 |
+
width: auto;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Dashboard Widget CSS
|
108 |
+
*/
|
109 |
+
|
110 |
+
#leftDashboard {
|
111 |
+
width: 45%;
|
112 |
+
float: left;
|
113 |
+
text-align: right;
|
114 |
+
border-right: 1px #999999 solid;
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
#leftDashboard strong {
|
119 |
+
float: left;
|
120 |
+
padding-left: 40px;
|
121 |
+
}
|
122 |
+
|
123 |
+
#rightDashboard strong {
|
124 |
+
float: left;
|
125 |
+
padding-left: 40px;
|
126 |
+
}
|
127 |
+
|
128 |
+
#rightDashboard {
|
129 |
+
width: 45%;
|
130 |
+
float: right;
|
131 |
+
text-align: right;
|
132 |
+
}
|
133 |
+
|
134 |
+
.dashboardWidgetSpecial {
|
135 |
+
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
|
136 |
+
color: #21759B;
|
137 |
+
font-size: 15px !important;
|
138 |
+
margin: 5px 0 5px 0;
|
139 |
+
}
|
140 |
+
|
141 |
+
.dashboardWidget {
|
142 |
+
color: #777777;
|
143 |
+
padding-left: 10px;
|
144 |
+
padding-right: 30px;
|
145 |
+
}
|
146 |
+
|
147 |
+
span.wpsc_quart_left {
|
148 |
+
width: 40%;
|
149 |
+
float: left;
|
150 |
+
}
|
151 |
+
|
152 |
+
p.atglance {
|
153 |
+
color: #777777;
|
154 |
+
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
|
155 |
+
font-size: 13px;
|
156 |
+
font-style: italic;
|
157 |
+
}
|
158 |
+
|
159 |
+
span.wpsc_quart_right {
|
160 |
+
width: 60%;
|
161 |
+
float: right;
|
162 |
+
text-align: right;
|
163 |
+
}
|
164 |
+
|
165 |
+
#box span {
|
166 |
+
border-bottom: 1px solid #999999;
|
167 |
+
}
|
168 |
+
|
169 |
+
p.quarterly {
|
170 |
+
color: #21759B;
|
171 |
+
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
|
172 |
+
font-size: 12px;
|
173 |
+
line-height: 140%;
|
174 |
+
margin: 5px 0;
|
175 |
+
}
|
176 |
+
|
177 |
+
/* End of dashboard widget css */
|
178 |
+
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Display Purchase log Details CSS is HERE
|
182 |
+
*/
|
183 |
+
|
184 |
+
.log-details-title-area {
|
185 |
+
}
|
186 |
+
.log-details-title-area .tablenav {
|
187 |
+
float: right;
|
188 |
+
clear: both;
|
189 |
+
margin: 0;
|
190 |
+
}
|
191 |
+
|
192 |
+
.log-details-title-area .pagination-links a {
|
193 |
+
padding: 0 0 0 8px;
|
194 |
+
}
|
195 |
+
|
196 |
+
.log-title-details {
|
197 |
+
float: left;
|
198 |
+
clear: none;
|
199 |
+
margin-top: -10px;
|
200 |
+
color: #23282d;
|
201 |
+
font-size: 23px;
|
202 |
+
}
|
203 |
+
|
204 |
+
#purchlogs_customfields {
|
205 |
+
clear: both;
|
206 |
+
}
|
207 |
+
|
208 |
+
th#date {
|
209 |
+
width: 120px;
|
210 |
+
}
|
211 |
+
|
212 |
+
th#purchid {
|
213 |
+
width: 60px;
|
214 |
+
}
|
215 |
+
|
216 |
+
th#details {
|
217 |
+
width: 100px;
|
218 |
+
}
|
219 |
+
|
220 |
+
th#track {
|
221 |
+
width: 75px;
|
222 |
+
}
|
223 |
+
|
224 |
+
th#delete {
|
225 |
+
width: 60px;
|
226 |
+
}
|
227 |
+
|
228 |
+
th#status {
|
229 |
+
width: 200px;
|
230 |
+
}
|
231 |
+
|
232 |
+
#wpsc-customer-settings-form h2 {
|
233 |
+
padding: 0 !important;
|
234 |
+
}
|
235 |
+
|
236 |
+
#wpsc-customer-settings-form label {
|
237 |
+
display: block;
|
238 |
+
}
|
239 |
+
|
240 |
+
#wpsc-customer-settings-form .button-secondary {
|
241 |
+
margin-right: 10px;
|
242 |
+
}
|
243 |
+
|
244 |
+
#wpsc_items_ordered {
|
245 |
+
clear: both;
|
246 |
+
}
|
247 |
+
|
248 |
+
#wpsc_items_ordered .widefat {
|
249 |
+
border: 0;
|
250 |
+
}
|
251 |
+
|
252 |
+
.wpsc-remove-button {
|
253 |
+
background: none;
|
254 |
+
border: none;
|
255 |
+
line-height: 1.60em;
|
256 |
+
}
|
257 |
+
|
258 |
+
.wpsc-remove-button .dashicons {
|
259 |
+
color:#a00;
|
260 |
+
}
|
261 |
+
|
262 |
+
.wpsc-add-row {
|
263 |
+
border: 1px solid #ddd;
|
264 |
+
padding: 10px 0;
|
265 |
+
border-left: 0;
|
266 |
+
border-right: 0;
|
267 |
+
}
|
268 |
+
|
269 |
+
.wpsc_item_qty {
|
270 |
+
width: 4em;
|
271 |
+
}
|
272 |
+
|
273 |
+
.wpsc_pushdown_img {
|
274 |
+
float: left;
|
275 |
+
}
|
276 |
+
|
277 |
+
.wpsc-notes {
|
278 |
+
margin: 5px 0 20px;
|
279 |
+
}
|
280 |
+
|
281 |
+
.wpsc-note {
|
282 |
+
position: relative;
|
283 |
+
padding: 1px 1em 1px;
|
284 |
+
margin: 8px 0;
|
285 |
+
}
|
286 |
+
|
287 |
+
.wpsc-note > p {
|
288 |
+
border-bottom: 1px solid #ddd;
|
289 |
+
padding-bottom: 1em;
|
290 |
+
height: 1.5em;
|
291 |
+
}
|
292 |
+
|
293 |
+
.wpsc-note .note-number {
|
294 |
+
opacity: .5;
|
295 |
+
padding-left: 5px;
|
296 |
+
}
|
297 |
+
|
298 |
+
.wpsc-note:nth-child( 2n ) {
|
299 |
+
background: #f7f7f7;
|
300 |
+
}
|
301 |
+
|
302 |
+
.wpsc-note .wpsc-remove-button {
|
303 |
+
float: right;
|
304 |
+
margin-top: -3px;
|
305 |
+
text-decoration: none;
|
306 |
+
color: #444;
|
307 |
+
}
|
308 |
+
|
309 |
+
.wpsc-note .wpsc-remove-button .spinner {
|
310 |
+
float: left;
|
311 |
+
margin-top: 0;
|
312 |
+
}
|
313 |
+
|
314 |
+
.note-submit {
|
315 |
+
display: inline-block;
|
316 |
+
}
|
317 |
+
|
318 |
+
#purchlogs_notes .inside {
|
319 |
+
margin-top: 0;
|
320 |
+
margin-bottom: 0;
|
321 |
+
}
|
322 |
+
|
323 |
+
#wpsc_purchlogitems_links {
|
324 |
+
clear: both;
|
325 |
+
}
|
326 |
+
|
327 |
+
#wpsc_purchlog_order_status {
|
328 |
+
float: right;
|
329 |
+
width: 250px;
|
330 |
+
}
|
331 |
+
|
332 |
+
#wpsc_purchlog_order_status .selector {
|
333 |
+
margin-top: -.2em;
|
334 |
+
}
|
335 |
+
|
336 |
+
/* Purchase Log Action Links */
|
337 |
+
|
338 |
+
#wpsc_purchlogitems_links a {
|
339 |
+
text-decoration: none;
|
340 |
+
line-height: 14pt;
|
341 |
+
}
|
342 |
+
|
343 |
+
#wpsc_purchlogitems_links img {
|
344 |
+
padding-top: 2px;
|
345 |
+
float: left;
|
346 |
+
}
|
347 |
+
|
348 |
+
#wpsc_purchlogitems_links li .dashicons {
|
349 |
+
margin-right: 10px;
|
350 |
+
}
|
351 |
+
|
352 |
+
#wpsc_purchlogitems_links li a {
|
353 |
+
position: relative;
|
354 |
+
}
|
355 |
+
|
356 |
+
#wpsc_purchlogitems_links li a .spinner {
|
357 |
+
display: none;
|
358 |
+
float: none;
|
359 |
+
margin: 0px;
|
360 |
+
position: absolute;
|
361 |
+
top: 0px;
|
362 |
+
left: 0px;
|
363 |
+
}
|
364 |
+
|
365 |
+
#wpsc_purchlogitems_links li a .dashicons {
|
366 |
+
color: #888;
|
367 |
+
}
|
368 |
+
|
369 |
+
#wpsc_purchlogitems_links li a .dashicons-yes {
|
370 |
+
color: #7ad03a;
|
371 |
+
}
|
372 |
+
|
373 |
+
#wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-delete .dashicons,
|
374 |
+
#wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-back .dashicons {
|
375 |
+
color: #bbb;
|
376 |
+
}
|
377 |
+
|
378 |
+
#wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-delete:hover .dashicons,
|
379 |
+
#wpsc_purchlogitems_links li a .dashicons-no {
|
380 |
+
color: #c00;
|
381 |
+
}
|
382 |
+
|
383 |
+
#wpsc_purchlogitems_links li a.wpsc-purchlog-action-link-back:hover .dashicons {
|
384 |
+
color: #888;
|
385 |
+
}
|
386 |
+
|
387 |
+
#wpsc_purchlogitems_links li a.doing {
|
388 |
+
padding-left: 30px;
|
389 |
+
}
|
390 |
+
|
391 |
+
#wpsc_purchlogitems_links li a.doing .spinner {
|
392 |
+
display: block;
|
393 |
+
}
|
394 |
+
|
395 |
+
#wpsc_purchlogitems_links li a.doing .dashicons {
|
396 |
+
display: none;
|
397 |
+
}
|
398 |
+
|
399 |
+
#wpsc_shipping_details_box {
|
400 |
+
width: 45%;
|
401 |
+
float: left;
|
402 |
+
margin: .4em;
|
403 |
+
padding: .6em;
|
404 |
+
margin-right: 5em;
|
405 |
+
}
|
406 |
+
|
407 |
+
#wpsc_billing_details_box {
|
408 |
+
width: 35%;
|
409 |
+
float: left;
|
410 |
+
margin: .4em;
|
411 |
+
padding: .6em;
|
412 |
+
}
|
413 |
+
|
414 |
+
#wpsc_shipping_details_box em.field-blank,
|
415 |
+
#wpsc_billing_details_box em.field-blank {
|
416 |
+
color: #999;
|
417 |
+
}
|
418 |
+
|
419 |
+
#wpsc_purchlog_searchbox {
|
420 |
+
width: 100%;
|
421 |
+
text-align: right;
|
422 |
+
}
|
423 |
+
|
424 |
+
.edit-log-details {
|
425 |
+
font-size: .8em;
|
426 |
+
padding-left: 5px;
|
427 |
+
}
|
428 |
+
|
429 |
+
@media screen and ( min-width: 620px ) {
|
430 |
+
#wpsc-customer-settings-form fieldset {
|
431 |
+
float: left;
|
432 |
+
min-width: 300px;
|
433 |
+
margin-right: 10px;
|
434 |
+
}
|
435 |
+
#wpsc-customer-settings-form fieldset [type="text"] {
|
436 |
+
min-width: 280px;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
.wpsc-form-actions {
|
441 |
+
clear: both;
|
442 |
+
}
|
443 |
+
|
444 |
+
#edit-shipping-billing {
|
445 |
+
padding: 18px 18px 0;
|
446 |
+
background: #fff;
|
447 |
+
border: 1px solid #e5e5e5;
|
448 |
+
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
449 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
450 |
+
clear: both;
|
451 |
+
}
|
452 |
+
|
453 |
+
#edit-shipping-billing .wpsc-form-actions {
|
454 |
+
margin-bottom: 0;
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Display Products CSS starts here
|
459 |
+
*/
|
460 |
+
|
461 |
+
.tablenav select[name="bulkAction"] {
|
462 |
+
width: 100px;
|
463 |
+
}
|
464 |
+
|
465 |
+
textarea#additional_description {
|
466 |
+
border: 1px solid #dfdfdf;
|
467 |
+
}
|
468 |
+
|
469 |
+
#poststuff h3.form_heading {
|
470 |
+
font-size: 1.1em;
|
471 |
+
margin: 40px 0px 10px 0px;
|
472 |
+
padding-left: 0px;
|
473 |
+
}
|
474 |
+
|
475 |
+
#poststuff h3.form_heading span {
|
476 |
+
font-size: 0.8em;
|
477 |
+
}
|
478 |
+
|
479 |
+
div.search-box input#page-search-input {
|
480 |
+
width: 129px;
|
481 |
+
}
|
482 |
+
|
483 |
+
#wpsc_product_list,
|
484 |
+
table.widefat {
|
485 |
+
width: 100%;
|
486 |
+
}
|
487 |
+
|
488 |
+
table.widefat .column-hidden_alerts {
|
489 |
+
display: none;
|
490 |
+
}
|
491 |
+
|
492 |
+
#wpsc_product_list .column-cb,
|
493 |
+
table.widefat .column-cb {
|
494 |
+
vertical-align: middle;
|
495 |
+
}
|
496 |
+
|
497 |
+
#wpsc_product_list .column-image,
|
498 |
+
#wpsc_product_list .product-image,
|
499 |
+
table.widefat .column-image,
|
500 |
+
table.widefat .product-image {
|
501 |
+
padding-right: 0px;
|
502 |
+
width: 42px;
|
503 |
+
}
|
504 |
+
|
505 |
+
.post-type-wpsc-product table.widefat .column-image img {
|
506 |
+
max-width: 100%;
|
507 |
+
max-height: 100%;
|
508 |
+
width: auto;
|
509 |
+
height: auto;
|
510 |
+
}
|
511 |
+
|
512 |
+
#wpsc_product_list .column-categories,
|
513 |
+
table.widefat .column-categories {
|
514 |
+
padding-right:18px;
|
515 |
+
}
|
516 |
+
|
517 |
+
#wpsc_product_list tbody tr td.column-title,
|
518 |
+
table.widefat tbody tr td.column-title {
|
519 |
+
border-right: none;
|
520 |
+
}
|
521 |
+
|
522 |
+
#wpsc_product_list tbody tr td.product-image img,
|
523 |
+
table.widefat tbody tr td.product-image img {
|
524 |
+
margin-top: 4px;
|
525 |
+
cursor: move;
|
526 |
+
}
|
527 |
+
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Product Currency and Quantity Discount Layers
|
531 |
+
*/
|
532 |
+
|
533 |
+
.wpsc-currency-layers {
|
534 |
+
clear: both;
|
535 |
+
margin: 0 0 15px 0;
|
536 |
+
padding: 15px 0 0 0;
|
537 |
+
}
|
538 |
+
|
539 |
+
.wpsc-quantity-discounts {
|
540 |
+
clear: both;
|
541 |
+
margin: 0 0 20px 0;
|
542 |
+
}
|
543 |
+
|
544 |
+
.wpsc-currency-layers table,
|
545 |
+
.wpsc-quantity-discounts table {
|
546 |
+
border-collapse: collapse;
|
547 |
+
margin: 10px 0;
|
548 |
+
width: 100%;
|
549 |
+
}
|
550 |
+
|
551 |
+
.wpsc-quantity-discounts table {
|
552 |
+
margin-top: 20px;
|
553 |
+
}
|
554 |
+
|
555 |
+
.wpsc-currency-layers th,
|
556 |
+
.wpsc-quantity-discounts th {
|
557 |
+
font-weight: normal;
|
558 |
+
text-align: left;
|
559 |
+
vertical-align: bottom;
|
560 |
+
}
|
561 |
+
|
562 |
+
.wpsc-currency-layers th.price,
|
563 |
+
.wpsc-quantity-discounts th.price {
|
564 |
+
width: 30%;
|
565 |
+
}
|
566 |
+
|
567 |
+
.wpsc-quantity-discounts th.qty {
|
568 |
+
width: 40%;
|
569 |
+
}
|
570 |
+
|
571 |
+
.wpsc-quantity-discounts td {
|
572 |
+
line-height: 28px;
|
573 |
+
}
|
574 |
+
|
575 |
+
.wpsc-quantity-discounts td.curr {
|
576 |
+
text-align: right;
|
577 |
+
}
|
578 |
+
|
579 |
+
.wpsc-currency-layers th.remove,
|
580 |
+
.wpsc-quantity-discounts th.remove {
|
581 |
+
width: 20px;
|
582 |
+
}
|
583 |
+
|
584 |
+
.wpsc-currency-layers td,
|
585 |
+
.wpsc-quantity-discounts td {
|
586 |
+
padding: 3px 2px 3px 0px;
|
587 |
+
}
|
588 |
+
|
589 |
+
.wpsc-currency-layers .newCurrency {
|
590 |
+
margin: 0px;
|
591 |
+
width: 95%;
|
592 |
+
}
|
593 |
+
|
594 |
+
.wpsc-quantity-discounts .qty input {
|
595 |
+
width: 4em;
|
596 |
+
}
|
597 |
+
|
598 |
+
.wpsc-currency-layers .newCurrPrice,
|
599 |
+
.wpsc-quantity-discounts .newCurrPrice {
|
600 |
+
width: 100%;
|
601 |
+
}
|
602 |
+
|
603 |
+
.wpsc_delete_currency_layer,
|
604 |
+
.wpsc-quantity-discounts .remove_line {
|
605 |
+
color: #bbb;
|
606 |
+
display: inline-block;
|
607 |
+
font-size: 16px;
|
608 |
+
line-height: 20px;
|
609 |
+
margin: 4px 0 0 0;
|
610 |
+
text-align: center;
|
611 |
+
width: 20px;
|
612 |
+
height: 20px;
|
613 |
+
}
|
614 |
+
|
615 |
+
.wpsc_delete_currency_layer:hover,
|
616 |
+
.wpsc-quantity-discounts .remove_line:hover {
|
617 |
+
color: #c00;
|
618 |
+
}
|
619 |
+
|
620 |
+
div.wpsc_floatleft {
|
621 |
+
width: 161px;
|
622 |
+
float: left;
|
623 |
+
}
|
624 |
+
|
625 |
+
div.wpsc_floatleft label {
|
626 |
+
line-height: 18px;
|
627 |
+
white-space: nowrap;
|
628 |
+
display: block
|
629 |
+
}
|
630 |
+
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Sortable product styling
|
634 |
+
*/
|
635 |
+
|
636 |
+
table.product_editform {
|
637 |
+
width: 100%;
|
638 |
+
}
|
639 |
+
|
640 |
+
#wpsc_product_list .ui-sortable-helper,
|
641 |
+
table.widefat .ui-sortable-helper {
|
642 |
+
width: 410px;
|
643 |
+
margin-left: -1px;
|
644 |
+
background-color: #FEFEFE;
|
645 |
+
}
|
646 |
+
|
647 |
+
#wpsc_product_list .ui-sortable-helper td,
|
648 |
+
#wpsc_product_list .ui-sortable-helper th,
|
649 |
+
table.widefat .ui-sortable-helper td,
|
650 |
+
table.widefat .ui-sortable-helper th {
|
651 |
+
border-top: 1px solid #DFDFDF;
|
652 |
+
opacity: .4;
|
653 |
+
}
|
654 |
+
|
655 |
+
.wpsc-sortable-table-placeholder td,
|
656 |
+
.product-placeholder {
|
657 |
+
border-width: 1px;
|
658 |
+
border-style: dashed;
|
659 |
+
z-index: 900;
|
660 |
+
border-color: #bbb;
|
661 |
+
background-color: #eaeaea !important;
|
662 |
+
height: 38px;
|
663 |
+
}
|
664 |
+
|
665 |
+
div#poststuff table tr td {
|
666 |
+
vertical-align: top;
|
667 |
+
}
|
668 |
+
|
669 |
+
div#poststuff textarea {
|
670 |
+
width: 100%;
|
671 |
+
}
|
672 |
+
|
673 |
+
div.admin_product_name label {
|
674 |
+
display: block;
|
675 |
+
float: left;
|
676 |
+
}
|
677 |
+
|
678 |
+
div.admin_product_name {
|
679 |
+
position: relative;
|
680 |
+
height: 30px;
|
681 |
+
background: #ffffff;
|
682 |
+
border: 1px solid #dfdfdf;
|
683 |
+
-webkit-border-radius: 6px;
|
684 |
+
-khtml-border-radius: 6px;
|
685 |
+
-moz-border-radius: 6px;
|
686 |
+
border-radius: 6px;
|
687 |
+
}
|
688 |
+
|
689 |
+
div.admin_product_name input.wpsc_product_name {
|
690 |
+
border: none;
|
691 |
+
}
|
692 |
+
|
693 |
+
div.admin_product_name a.shorttag_toggle {
|
694 |
+
position: absolute;
|
695 |
+
top: 0px;
|
696 |
+
right: 0px;
|
697 |
+
background: url(../../wpsc-core/images/info_icon.jpg) no-repeat scroll 5px 8px;
|
698 |
+
border-left: 1px solid #DFDFDF;
|
699 |
+
display: block;
|
700 |
+
height: 100%;
|
701 |
+
padding: 0px 3px 0px 3px;
|
702 |
+
width: 18px;
|
703 |
+
}
|
704 |
+
|
705 |
+
div#icon_card {
|
706 |
+
float: left;
|
707 |
+
height: 36px;
|
708 |
+
margin: 7px 8px 0 0;
|
709 |
+
width: 36px;
|
710 |
+
background: url(../../wpsc-core/images/icon32.png) no-repeat center center;
|
711 |
+
}
|
712 |
+
|
713 |
+
/* Can .admin_product_shorttags be deprecated */
|
714 |
+
|
715 |
+
div.admin_product_shorttags {
|
716 |
+
width: 93%;
|
717 |
+
min-width: 396px;
|
718 |
+
max-width: 558px;
|
719 |
+
clear: both;
|
720 |
+
padding: 6px;
|
721 |
+
font-size: 8pt;
|
722 |
+
margin: 0 0 0 6px !important;
|
723 |
+
border-left: 1px solid #DFDFDF;
|
724 |
+
border-right: 1px solid #DFDFDF;
|
725 |
+
border-bottom: 1px solid #DFDFDF;
|
726 |
+
display: none;
|
727 |
+
background-color: #ffffff;
|
728 |
+
}
|
729 |
+
|
730 |
+
#description {
|
731 |
+
margin: 0;
|
732 |
+
}
|
733 |
+
|
734 |
+
h4.product_action_link {
|
735 |
+
margin: 4px 0px 0px 0px;
|
736 |
+
display: block;
|
737 |
+
font-weight: bold;
|
738 |
+
}
|
739 |
+
|
740 |
+
|
741 |
+
/**
|
742 |
+
* Image form styling
|
743 |
+
*/
|
744 |
+
|
745 |
+
div.flash-image-uploader {
|
746 |
+
display: none;
|
747 |
+
}
|
748 |
+
|
749 |
+
#wpbody-content div.flash-image-uploader #media-items {
|
750 |
+
position: relative;
|
751 |
+
border: none;
|
752 |
+
}
|
753 |
+
|
754 |
+
#wpbody-content div.flash-image-uploader #media-items .progress {
|
755 |
+
position: static;
|
756 |
+
margin: 0 0 6px;
|
757 |
+
height: 16px;
|
758 |
+
}
|
759 |
+
|
760 |
+
.ui-selected {
|
761 |
+
border: 2px dashed #969696;
|
762 |
+
}
|
763 |
+
|
764 |
+
img.deleteButton {
|
765 |
+
display: none;
|
766 |
+
position: absolute;
|
767 |
+
top: -5px;
|
768 |
+
right: -1px;
|
769 |
+
width: 16px;
|
770 |
+
height: 16px;
|
771 |
+
cursor: pointer;
|
772 |
+
}
|
773 |
+
|
774 |
+
a.editButton {
|
775 |
+
background: #FFFFFF none repeat scroll 0%;
|
776 |
+
height: 20px;
|
777 |
+
display: none;
|
778 |
+
position: absolute;
|
779 |
+
right: 0px;
|
780 |
+
top: 0px;
|
781 |
+
padding-bottom: 3px;
|
782 |
+
padding-left: 3px;
|
783 |
+
cursor: pointer;
|
784 |
+
}
|
785 |
+
|
786 |
+
div.image_settings_box {
|
787 |
+
position: absolute;
|
788 |
+
width: 150px;
|
789 |
+
display: none;
|
790 |
+
margin: -66px 0px 0px 36px;
|
791 |
+
padding-top: 2px;
|
792 |
+
width: 252px;
|
793 |
+
z-index: 69;
|
794 |
+
}
|
795 |
+
|
796 |
+
a.thickbox img {
|
797 |
+
border: medium none;
|
798 |
+
}
|
799 |
+
|
800 |
+
img.previewimage {
|
801 |
+
cursor: move;
|
802 |
+
height: 60px;
|
803 |
+
margin-right: 4px;
|
804 |
+
width: 60px;
|
805 |
+
}
|
806 |
+
|
807 |
+
div.lower_settings_box {
|
808 |
+
width: 234px;
|
809 |
+
background-color: white;
|
810 |
+
border: 1px solid black;
|
811 |
+
border-top: 1px solid #CCCCCC;
|
812 |
+
float: right;
|
813 |
+
margin: -1px -6px 0px 0px;
|
814 |
+
padding: 2px 0 0 4px;
|
815 |
+
background-color: #EAF3FA;
|
816 |
+
}
|
817 |
+
|
818 |
+
div.upper_settings_box {
|
819 |
+
width: 250px;
|
820 |
+
background-color: white;
|
821 |
+
border: 1px solid black;
|
822 |
+
padding: 3px 1px 2px 5px;
|
823 |
+
}
|
824 |
+
|
825 |
+
div.upper_image {
|
826 |
+
float: left;
|
827 |
+
padding-left :5px;
|
828 |
+
margin-left: -5px;
|
829 |
+
margin-right: -7px;
|
830 |
+
padding-bottom: 4px;
|
831 |
+
}
|
832 |
+
|
833 |
+
div.upper_txt {
|
834 |
+
padding-left: 22px;
|
835 |
+
color: #666666;
|
836 |
+
}
|
837 |
+
|
838 |
+
div.previewimage {
|
839 |
+
position: relative;
|
840 |
+
}
|
841 |
+
|
842 |
+
tr.edit_product_image * {
|
843 |
+
z-index: 80;
|
844 |
+
}
|
845 |
+
|
846 |
+
div.browser-image-uploader h4 {
|
847 |
+
margin-bottom: 8px;
|
848 |
+
}
|
849 |
+
|
850 |
+
div.image_resize_extra_forms {
|
851 |
+
display: none;
|
852 |
+
}
|
853 |
+
|
854 |
+
#wpsc_product_category_and_tag_forms table {
|
855 |
+
width: 100%;
|
856 |
+
}
|
857 |
+
|
858 |
+
#wpsc_product_category_and_tag_forms table td.itemfirstcol {
|
859 |
+
padding-left: 3pt;
|
860 |
+
width: 50%;
|
861 |
+
}
|
862 |
+
|
863 |
+
|
864 |
+
/**
|
865 |
+
* Variations CSS starts
|
866 |
+
*/
|
867 |
+
|
868 |
+
table.product_variation_listing {
|
869 |
+
margin-bottom: 12px;
|
870 |
+
}
|
871 |
+
|
872 |
+
table.product_variation_listing th.variation_name {
|
873 |
+
color: #71A4C8;
|
874 |
+
font-style: italic;
|
875 |
+
text-align: left;
|
876 |
+
padding-bottom: 1px;
|
877 |
+
}
|
878 |
+
|
879 |
+
table.product_variation_grid {
|
880 |
+
margin-top: 12px;
|
881 |
+
}
|
882 |
+
|
883 |
+
table.product_variation_grid th.variation_name {
|
884 |
+
color: #71A4C8;
|
885 |
+
font-style: italic;
|
886 |
+
text-align: left;
|
887 |
+
padding-bottom: 1px;
|
888 |
+
}
|
889 |
+
|
890 |
+
div#edit_variations_container {
|
891 |
+
margin-top: 12px;
|
892 |
+
}
|
893 |
+
|
894 |
+
table.product_variation_grid {
|
895 |
+
border-collapse: collapse;
|
896 |
+
margin-top: 0px;
|
897 |
+
}
|
898 |
+
|
899 |
+
table.product_variation_grid tr td,
|
900 |
+
table.product_variation_grid tr th {
|
901 |
+
border: 1px solid #cccccc;
|
902 |
+
border-collapse: collapse;
|
903 |
+
text-align: left;
|
904 |
+
}
|
905 |
+
|
906 |
+
table.product_variation_grid tr th {
|
907 |
+
border-bottom: 1px solid #969696;
|
908 |
+
}
|
909 |
+
|
910 |
+
table.product_variation_grid tr th.stock {
|
911 |
+
border-bottom: 1px solid #969696;
|
912 |
+
width: 50px;
|
913 |
+
}
|
914 |
+
|
915 |
+
table.product_variation_grid tr th.price {
|
916 |
+
width: 78px;
|
917 |
+
}
|
918 |
+
|
919 |
+
table.product_variation_grid tr td.variations,
|
920 |
+
table.product_variation_grid tr th {
|
921 |
+
padding: 4px 0px 4px 10px;
|
922 |
+
}
|
923 |
+
|
924 |
+
table.product_variation_grid tr td.variations,
|
925 |
+
table.product_variation_grid tr th.variations {
|
926 |
+
width: 300px;
|
927 |
+
}
|
928 |
+
|
929 |
+
table.product_variation_grid tr td input {
|
930 |
+
padding: 0px 3px 0px 3px;
|
931 |
+
}
|
932 |
+
|
933 |
+
table.product_variation_grid tr.group_boundary td {
|
934 |
+
border-bottom: 1px solid #969696;
|
935 |
+
}
|
936 |
+
|
937 |
+
a.about_this_page_sub {
|
938 |
+
text-decoration: underline;
|
939 |
+
}
|
940 |
+
|
941 |
+
table.product_variation_grid tr td,
|
942 |
+
table.product_variation_grid tr th {
|
943 |
+
border: 1px solid #cccccc;
|
944 |
+
border-collapse: collapse;
|
945 |
+
text-align: left;
|
946 |
+
}
|
947 |
+
|
948 |
+
table.product_variation_grid tr.variation_row td {
|
949 |
+
border-bottom: none;
|
950 |
+
}
|
951 |
+
|
952 |
+
table.product_variation_grid tr.settings_row td {
|
953 |
+
border-top: none;
|
954 |
+
padding: 0px !important;
|
955 |
+
}
|
956 |
+
|
957 |
+
table.product_variation_grid tr.settings_row td div.variation_settings {
|
958 |
+
display: none;
|
959 |
+
border-top: 1px dotted #cccccc;
|
960 |
+
width: 100%;
|
961 |
+
min-height: 30px;
|
962 |
+
padding: 4px 10px;
|
963 |
+
}
|
964 |
+
|
965 |
+
table.product_variation_grid tr th {
|
966 |
+
border-bottom: 1px solid #969696;
|
967 |
+
}
|
968 |
+
|
969 |
+
table.product_variation_grid tr th.stock {
|
970 |
+
border-bottom: 1px solid #969696;
|
971 |
+
width: 50px;
|
972 |
+
}
|
973 |
+
|
974 |
+
table.product_variation_grid tr th.price {
|
975 |
+
width: 78px;
|
976 |
+
}
|
977 |
+
|
978 |
+
table.product_variation_grid tr td.variations,
|
979 |
+
table.product_variation_grid tr th {
|
980 |
+
padding: 4px 0px 4px 10px;
|
981 |
+
}
|
982 |
+
|
983 |
+
table.product_variation_grid tr td.variations,
|
984 |
+
table.product_variation_grid tr th.variations {
|
985 |
+
width: 300px;
|
986 |
+
}
|
987 |
+
|
988 |
+
table.product_variation_grid tr td input {
|
989 |
+
padding: 0px 3px 0px 3px;
|
990 |
+
}
|
991 |
+
|
992 |
+
table.product_variation_grid tr td input.checkbox {
|
993 |
+
display: block;
|
994 |
+
margin: 6px auto;
|
995 |
+
}
|
996 |
+
|
997 |
+
table.product_variation_grid tr.group_boundary td {
|
998 |
+
border-bottom: 1px solid #969696;
|
999 |
+
}
|
1000 |
+
|
1001 |
+
div#add_product_variation_details {
|
1002 |
+
margin: 1ex 0px 0px 0px;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
div#add_product_variation_details table.product_variation_grid {
|
1006 |
+
margin: 4px 0px 0px 0px;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
div.variation_checkboxes {
|
1010 |
+
margin-bottom: 4px;
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
a.variation_edit_button {
|
1014 |
+
display: block;
|
1015 |
+
height: 16px;
|
1016 |
+
width: 16px;
|
1017 |
+
margin: 4px auto 0px auto;
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
div.variation_settings div.variation_settings_contents {
|
1021 |
+
padding-left: 10px;
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
div.select_variation_file {
|
1025 |
+
padding-left: 6px;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
div.select_variation_file p {
|
1029 |
+
margin: 0 0 3px;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
div.select_variation_file p {
|
1033 |
+
margin: 0 0 3px;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
div.select_variation_file p input {
|
1037 |
+
position: relative;
|
1038 |
+
top: 2px;
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
.variation_checkboxes li {
|
1042 |
+
margin: 0;
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
.variation_checkboxes ul {
|
1046 |
+
margin-left: 30px;
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
.js .variation_checkboxes .children {
|
1050 |
+
display: none;
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
.js .variation_checkboxes .expanded .children {
|
1054 |
+
display: block;
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
.variation_checkboxes a.expand {
|
1058 |
+
background: url(arrows.png) no-repeat left -108px;
|
1059 |
+
display: inline-block;
|
1060 |
+
height: 15px;
|
1061 |
+
width: 15px;
|
1062 |
+
text-indent: -999em;
|
1063 |
+
vertical-align: middle;
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
.variation_checkboxes .expanded a.expand {
|
1067 |
+
background-position: left top;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
#add-new-variation-set {
|
1071 |
+
margin-bottom: 20px;
|
1072 |
+
display: none;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
#add-new-variation-set p {
|
1076 |
+
position: relative;
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
#add-new-variation-set p.howto {
|
1080 |
+
margin-bottom: 16px;
|
1081 |
+
}
|
1082 |
+
|
1083 |
+
#add-new-variation-set p label.focus {
|
1084 |
+
color: #666;
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
#add-new-variation-set p.error label {
|
1088 |
+
color: red;
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
#add-new-variation-set p label {
|
1092 |
+
color: #000;
|
1093 |
+
cursor: text;
|
1094 |
+
left: 6px;
|
1095 |
+
position: absolute;
|
1096 |
+
top: 4px;
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
#add-new-variation-set .text-field {
|
1100 |
+
width: 195px;
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
.variation-set-prototype {
|
1104 |
+
display: none;
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
/* Variations CSS ends */
|
1108 |
+
|
1109 |
+
div#side-sortables input[type="file"] {
|
1110 |
+
width: 250px;
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
.wpsc_product_downloads_header {
|
1114 |
+
margin: 0 0 5px;
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
.select_product_file,
|
1118 |
+
.edit_select_product_file {
|
1119 |
+
margin-bottom: 0;
|
1120 |
+
margin-top: 3px;
|
1121 |
+
overflow-x: hidden;
|
1122 |
+
overflow-y: auto;
|
1123 |
+
position: relative;
|
1124 |
+
width: 100%;
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
span.select_product_note {
|
1128 |
+
margin: 0 0 5px;
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
img.wpsc_add_download {
|
1132 |
+
display: inline;
|
1133 |
+
position: relative;
|
1134 |
+
top: 2px;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
a.file_delete_button {
|
1138 |
+
cursor: pointer;
|
1139 |
+
color: red;
|
1140 |
+
display: block;
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
a.delete_button {
|
1144 |
+
border-color: -moz-use-text-color;
|
1145 |
+
border-style: none none solid;
|
1146 |
+
border-width: medium medium 1px;
|
1147 |
+
color: #FF0000;
|
1148 |
+
font-size: 11px;
|
1149 |
+
padding: 1px 2px;
|
1150 |
+
text-decoration: none;
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
.greytext {
|
1154 |
+
color: #666666;
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
span.small_italic {
|
1158 |
+
font-style: italic;
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
/* Product details form styling ends */
|
1162 |
+
|
1163 |
+
/* Display Products CSS ends here */
|
1164 |
+
|
1165 |
+
|
1166 |
+
/**
|
1167 |
+
* Product Groups styles start here
|
1168 |
+
*/
|
1169 |
+
|
1170 |
+
td.firstcol div.postbox div.inside {
|
1171 |
+
margin: 0px;
|
1172 |
+
padding: 0px;
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
table#productpage {
|
1176 |
+
width: 100%;
|
1177 |
+
clear: both;
|
1178 |
+
border-collapse: collapse;
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
table#productpage tr td {
|
1182 |
+
vertical-align: top;
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
table#productpage tr td.secondcol {
|
1186 |
+
padding: 0px 2px 0px 16px;
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
table.category-edit {
|
1190 |
+
border-collapse: collapse;
|
1191 |
+
width: 100%;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
table.category-edit tr td {
|
1195 |
+
border: none;
|
1196 |
+
}
|
1197 |
+
table.category-edit tr td.column-title {
|
1198 |
+
width: 450px;
|
1199 |
+
}
|
1200 |
+
|
1201 |
+
div.category-image-container {
|
1202 |
+
width: 55px;
|
1203 |
+
height: 30px;
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
div.category-image-container img {
|
1207 |
+
float: left;
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
div.category-image-container img.category_indenter {
|
1211 |
+
margin-right: 3px;
|
1212 |
+
width: auto;
|
1213 |
+
float: left;
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
div#productform {
|
1217 |
+
display: none;
|
1218 |
+
width: 99.5%;
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
div#edititem27 {
|
1222 |
+
display: none;
|
1223 |
+
width: 586px;
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
div#productform table tr td {
|
1227 |
+
height: 11px !important;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
div#blank_item {
|
1231 |
+
display: block;
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
#poststuff div#blank_item h3 {
|
1235 |
+
margin-top: 0px;
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
div#additem {
|
1239 |
+
display: none;
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
div#productform td.itemfirstcol {
|
1243 |
+
padding-left: 4px;
|
1244 |
+
vertical-align: top;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
div#productform input.text,
|
1248 |
+
div#additem input.text {
|
1249 |
+
width: 386px;
|
1250 |
+
border: 1px solid #bbb;
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
table.category_forms {
|
1254 |
+
width: 100%;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
table.category_forms tr td {
|
1258 |
+
padding: 0px;
|
1259 |
+
padding-right: 8px;
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
table.category_forms tr td textarea {
|
1263 |
+
width: 386px;
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
div#edit_variation_values input.text {
|
1267 |
+
width: 286px !important;
|
1268 |
+
border: 1px solid #bbb;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
input.image_resize {
|
1272 |
+
position: relative;
|
1273 |
+
top: 4px;
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
div#additem table.additem input.wpsc_tag {
|
1277 |
+
width: 180px;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
div#additem label {
|
1281 |
+
font-style: normal;
|
1282 |
+
font-size: 0.95em;
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
.groupItem {
|
1286 |
+
border-top: 1px solid #bbb;
|
1287 |
+
width: 385px;
|
1288 |
+
height: 35px;
|
1289 |
+
clear: both;
|
1290 |
+
padding: 0px 0px 4px 0px;
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
.groupItem .itemHeader {
|
1294 |
+
width: 65px;
|
1295 |
+
line-height: 15px;
|
1296 |
+
color: #000;
|
1297 |
+
padding: 4px;
|
1298 |
+
cursor: move;
|
1299 |
+
height: 35px;
|
1300 |
+
position: relative;
|
1301 |
+
clear: both;
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
.groupItem .itemHeader a {
|
1305 |
+
margin: 4px 0px 4px 0px;
|
1306 |
+
font-weight: normal;
|
1307 |
+
font-size: 11px;
|
1308 |
+
text-decoration: none;
|
1309 |
+
}
|
1310 |
+
|
1311 |
+
.sortHelper {
|
1312 |
+
border: 3px dashed #666;
|
1313 |
+
width: auto;
|
1314 |
+
}
|
1315 |
+
|
1316 |
+
.groupWrapper p {
|
1317 |
+
height: 1px;
|
1318 |
+
overflow: hidden;
|
1319 |
+
margin: 0;
|
1320 |
+
padding: 0;
|
1321 |
+
}
|
1322 |
+
|
1323 |
+
table#productpage tr td.secondcol.product_groups_page {
|
1324 |
+
padding-left: 16px;
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
table#productpage tr td.secondcol.product_groups_page h4 {
|
1328 |
+
font-family: inherit;
|
1329 |
+
margin-top: 20px;
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
td.product_groups_page #additem .inside,
|
1333 |
+
td.product_groups_page #productform .inside {
|
1334 |
+
margin: 0px 0px 15px 0px;
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
div.editing_this_group {
|
1338 |
+
margin-top: 8px;
|
1339 |
+
margin-bottom: 8px;
|
1340 |
+
width: 100%;
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
td.product_groups_page h4 {
|
1344 |
+
margin-bottom: 1ex;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
#editorcontainer {
|
1348 |
+
clear: both;
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
td.product_groups_page td.category_presentation_settings {
|
1352 |
+
padding-bottom: 1ex;
|
1353 |
+
}
|
1354 |
+
|
1355 |
+
div.editing_this_group {
|
1356 |
+
font-size: 8pt;
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
div.editing_this_group p {
|
1360 |
+
padding: 4px 4px 4px 8px;
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
div.editing_this_group dl {
|
1364 |
+
padding: 4px 4px 4px 8px;
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
#blank_item a.add_category_link {
|
1368 |
+
display: block;
|
1369 |
+
margin: 8px 8px 8px 0px;
|
1370 |
+
text-decoration: underline;
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
div.product_group {
|
1374 |
+
margin: 12px 0px 10px 0px;
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
table#wpsc_category_list td div.subcategory img.category_indenter {
|
1378 |
+
float: left;
|
1379 |
+
margin: 8px 0px 0px 0px;
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
table#wpsc_category_list td div.subcategory table.itemlist {
|
1383 |
+
float: left;
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
label.select_categorisation_group,
|
1387 |
+
select#select_categorisation_group,
|
1388 |
+
a.add_categorisation_group,
|
1389 |
+
a.edit_categorisation_group,
|
1390 |
+
#submit_categorisation_form span {
|
1391 |
+
display: block;
|
1392 |
+
float: left;
|
1393 |
+
}
|
1394 |
+
|
1395 |
+
#submit_categorisation_form span {
|
1396 |
+
display: block;
|
1397 |
+
float: left;
|
1398 |
+
margin-left: 10px;
|
1399 |
+
}
|
1400 |
+
|
1401 |
+
#submit_categorisation_form a span {
|
1402 |
+
margin-left: 0px;
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
label.select_categorisation_group {
|
1406 |
+
padding-top: 4px;
|
1407 |
+
font-size: 11px;
|
1408 |
+
}
|
1409 |
+
|
1410 |
+
a.add_categorisation_group {
|
1411 |
+
margin-left: 10px;
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
a.edit_categorisation_group {
|
1415 |
+
margin-left: 30px;
|
1416 |
+
}
|
1417 |
+
|
1418 |
+
div#add_categorisation,
|
1419 |
+
div#edit_categorisation {
|
1420 |
+
display: none;
|
1421 |
+
border: 1px solid #BBBBBB;
|
1422 |
+
padding: 4px;
|
1423 |
+
margin-top: 6px;
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
div#add_categorisation br,
|
1427 |
+
div#edit_categorisation br {
|
1428 |
+
clear: both;
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
div#add_categorisation fieldset,
|
1432 |
+
div#edit_categorisation fieldset {
|
1433 |
+
width: 230px;
|
1434 |
+
float: left;
|
1435 |
+
border: none;
|
1436 |
+
}
|
1437 |
+
|
1438 |
+
div#add_categorisation fieldset label,
|
1439 |
+
div#edit_categorisation fieldset label {
|
1440 |
+
display: block;
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
ul.categorisation_links {
|
1444 |
+
list-style-type: none;
|
1445 |
+
clear: both;
|
1446 |
+
padding: 0px;
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
ul.categorisation_links li {
|
1450 |
+
display: block;
|
1451 |
+
float: left;
|
1452 |
+
list-style-type: none;
|
1453 |
+
margin: 0px;
|
1454 |
+
font-size: 14px;
|
1455 |
+
padding: 4px;
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
ul.categorisation_links li.selected a {
|
1459 |
+
color: #D54E21;
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
.multiple-select-container {
|
1463 |
+
margin-left: 0.5em;
|
1464 |
+
}
|
1465 |
+
|
1466 |
+
.multiple-select {
|
1467 |
+
background: white none repeat scroll 0px 0px;
|
1468 |
+
border: 1px solid #DFDFDF;
|
1469 |
+
display: inline-block;
|
1470 |
+
height: 120px;
|
1471 |
+
overflow-x: hidden;
|
1472 |
+
overflow-y: auto;
|
1473 |
+
padding: 0 0 0 5px;
|
1474 |
+
position: relative;
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
.multiple-select input {
|
1478 |
+
width: inherit;
|
1479 |
+
}
|
1480 |
+
|
1481 |
+
.multiple-select label {
|
1482 |
+
display: inherit;
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
table.category_forms a.delete_button {
|
1486 |
+
display: block;
|
1487 |
+
margin: 3px 0px 0px 8px;
|
1488 |
+
float: left;
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
table.category_forms td.last_row {
|
1492 |
+
padding: 16px 0px 0px 0px;
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
.wpsc_gold_float {
|
1496 |
+
min-width: 45%;
|
1497 |
+
float: left;
|
1498 |
+
max-width: 450px;
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
.wpsc_gold_text {
|
1502 |
+
width: 70%;
|
1503 |
+
float: left;
|
1504 |
+
clear: both;
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
.wpsc_gold_info {
|
1508 |
+
width: 30%;
|
1509 |
+
float: right;
|
1510 |
+
text-align: center;
|
1511 |
+
font-size: 20px;
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
.wpsc_gold_module {
|
1515 |
+
width: 100%;
|
1516 |
+
float: left;
|
1517 |
+
border-bottom: 1px solid #DFDFDF;
|
1518 |
+
}
|
1519 |
+
|
1520 |
+
.wpsc_gold_module strong {
|
1521 |
+
width: auto;
|
1522 |
+
float: left;
|
1523 |
+
}
|
1524 |
+
|
1525 |
+
#visitInstinct {
|
1526 |
+
float: right;
|
1527 |
+
margin: 5px 20px 0 0;
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
#product_license_box .postbox p img {
|
1531 |
+
padding-bottom: 10px;
|
1532 |
+
}
|
1533 |
+
|
1534 |
+
#product_license_box_outside {
|
1535 |
+
width: 400px;
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
#product_license_box .postbox p {
|
1539 |
+
padding-left: 4px;
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
#product_license_box .postbox {
|
1543 |
+
width: 100%;
|
1544 |
+
max-width: 500px;
|
1545 |
+
}
|
1546 |
+
|
1547 |
+
#product_license_box .postbox p {
|
1548 |
+
padding-left: 10px;
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
#product_license_box .postbox p label {
|
1552 |
+
width: 80px;
|
1553 |
+
float: left;
|
1554 |
+
}
|
1555 |
+
|
1556 |
+
a.admin_download {
|
1557 |
+
height: 26px;
|
1558 |
+
border-bottom: none;
|
1559 |
+
text-decoration: none;
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
a.admin_download img {
|
1563 |
+
margin-right: 3px;
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
a.admin_download span {
|
1567 |
+
text-decoration: underline;
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
|
1571 |
+
/**
|
1572 |
+
* Product Groups styles end here
|
1573 |
+
*/
|
1574 |
+
|
1575 |
+
.wpsc_td_note {
|
1576 |
+
padding-bottom: 0 !important;
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
.wpsc_purchaselogs_options {
|
1580 |
+
margin: 0px 0px 8px 0px;
|
1581 |
+
}
|
1582 |
+
|
1583 |
+
p.add_new_form_set_forms {
|
1584 |
+
display: none;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
td.product-image a img.attachment-thumbnail {
|
1588 |
+
height: 38px;
|
1589 |
+
width: 38px;
|
1590 |
+
}
|
1591 |
+
|
1592 |
+
#wpsc_product_category_and_tag_forms .tagchecklist {
|
1593 |
+
font-size: 11px;
|
1594 |
+
}
|
1595 |
+
|
1596 |
+
#categorydiv div {
|
1597 |
+
margin-top: 4px;
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
a.variation_handle {
|
1601 |
+
color: #CCCCCC;
|
1602 |
+
text-decoration: none;
|
1603 |
+
font-size: 15px;
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
.toplevel_page_wpsc-edit-products .wrap h2 {
|
1607 |
+
padding-bottom: 0px;
|
1608 |
+
border-bottom: 1px solid #CCC;
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
#post-body #advanced-sortables {
|
1612 |
+
margin-right: 300px
|
1613 |
+
}
|
1614 |
+
|
1615 |
+
#media-buttons #add_audio,
|
1616 |
+
#media-buttons #add_video,
|
1617 |
+
#media-buttons #add_media {
|
1618 |
+
display: none;
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
/**
|
1622 |
+
* Marketing / coupon page styling
|
1623 |
+
*/
|
1624 |
+
|
1625 |
+
div.modify_coupon {
|
1626 |
+
border: 1px solid #eeeeee;
|
1627 |
+
display: none;
|
1628 |
+
width: 100%;
|
1629 |
+
}
|
1630 |
+
|
1631 |
+
table.coupon_data {
|
1632 |
+
width: 100%;
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
table.add-coupon {
|
1636 |
+
width: 100%;
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
table.add-coupon tr th {
|
1640 |
+
text-align: left;
|
1641 |
+
padding: 2px 5px 0px 5px;
|
1642 |
+
border: none;
|
1643 |
+
}
|
1644 |
+
|
1645 |
+
table.add-coupon tr td {
|
1646 |
+
text-align: left;
|
1647 |
+
padding: 2px 5px 2px 5px;
|
1648 |
+
border: none;
|
1649 |
+
}
|
1650 |
+
|
1651 |
+
table.add-coupon tr td p {
|
1652 |
+
padding: 0;
|
1653 |
+
margin: 5px;
|
1654 |
+
}
|
1655 |
+
#table_header {
|
1656 |
+
font-size: 16px;
|
1657 |
+
margin-top: 20px;
|
1658 |
+
font-weight: bold;
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
table.coupon-list {
|
1662 |
+
width: 100%;
|
1663 |
+
}
|
1664 |
+
|
1665 |
+
table.coupon-list th {
|
1666 |
+
text-align: left;
|
1667 |
+
}
|
1668 |
+
|
1669 |
+
table.coupon-list tr.toprow td {
|
1670 |
+
text-align: left;
|
1671 |
+
font-weight: bold;
|
1672 |
+
}
|
1673 |
+
|
1674 |
+
table.coupon-list tr td {
|
1675 |
+
padding: 5px 5px 10px 10px;
|
1676 |
+
vertical-align: middle;
|
1677 |
+
}
|
1678 |
+
|
1679 |
+
table.coupon-list tr.alt {
|
1680 |
+
background-color: #eeeeee;
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
table.coupon-list tr.alt td {
|
1684 |
+
background-color: #eeeeee;
|
1685 |
+
}
|
1686 |
+
|
1687 |
+
table.coupon-list tr.coupon_edit td {
|
1688 |
+
padding: 0;
|
1689 |
+
}
|
1690 |
+
|
1691 |
+
td#order_summary_container {
|
1692 |
+
width: 80px;
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
table.category_forms a.delete_button,
|
1696 |
+
span.delete_button {
|
1697 |
+
color: #FF0000;
|
1698 |
+
display: block;
|
1699 |
+
float: left;
|
1700 |
+
font-size: 11px;
|
1701 |
+
margin: 3px 0 0 8px;
|
1702 |
+
text-decoration: underline;
|
1703 |
+
}
|
1704 |
+
|
1705 |
+
p span.input_label {
|
1706 |
+
font-size: 1.2em;
|
1707 |
+
width: 180px;
|
1708 |
+
float: left;
|
1709 |
+
}
|
1710 |
+
|
1711 |
+
a.wpsc_featured_product_toggle {
|
1712 |
+
display: block;
|
1713 |
+
height: 18px;
|
1714 |
+
width: 18px;
|
1715 |
+
margin: 4px 0px 0px 0px;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
.column-featured a {
|
1719 |
+
background: url(../../wpsc-core/images/core-sprite.png) no-repeat 0 -32px transparent;
|
1720 |
+
}
|
1721 |
+
|
1722 |
+
.column-featured a.gold-star {
|
1723 |
+
background-position: 0 -16px;
|
1724 |
+
}
|
1725 |
+
|
1726 |
+
.column-featured a:active,
|
1727 |
+
.column-featured a.gold-star:active {
|
1728 |
+
background-position: 0 0;
|
1729 |
+
}
|
1730 |
+
|
1731 |
+
div.wpsc_clear {
|
1732 |
+
clear: both;
|
1733 |
+
}
|
1734 |
+
|
1735 |
+
.wpsc_featured div.product_grid_display div.product_grid_item {
|
1736 |
+
width: 100%;
|
1737 |
+
height: auto !important;
|
1738 |
+
margin: 4px 90px 8px 0;
|
1739 |
+
position: relative;
|
1740 |
+
}
|
1741 |
+
|
1742 |
+
.wpsc_featured .item_text {
|
1743 |
+
float: left;
|
1744 |
+
height: 240px;
|
1745 |
+
width: auto;
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
.wpsc_featured .item_image {
|
1749 |
+
float: left;
|
1750 |
+
height: 240px;
|
1751 |
+
width: 340px;
|
1752 |
+
margin-left: 20px;
|
1753 |
+
}
|
1754 |
+
|
1755 |
+
.wpsc_featured .item_image a {
|
1756 |
+
display: block;
|
1757 |
+
height: 240px;
|
1758 |
+
width: 340px;
|
1759 |
+
border: 1px solid #FEFAF1;
|
1760 |
+
-webkit-border-radius: 18px;
|
1761 |
+
-moz-border-radius: 18px;
|
1762 |
+
border-radius: 18px;
|
1763 |
+
background-repeat: no-repeat;
|
1764 |
+
}
|
1765 |
+
|
1766 |
+
.wpsc_featured .item_text h3 {
|
1767 |
+
font-size: 1.4em;
|
1768 |
+
margin: 0px 0px 8px 0px;
|
1769 |
+
}
|
1770 |
+
|
1771 |
+
.wpsc_featured .item_text div.pricedisplay {
|
1772 |
+
color: #9B9A96;
|
1773 |
+
line-height: normal;
|
1774 |
+
display: block;
|
1775 |
+
margin: 0px 0px 4px 0px;
|
1776 |
+
}
|
1777 |
+
|
1778 |
+
.wpsc_featured .item_text .wpsc_description {
|
1779 |
+
font-size: 1em;
|
1780 |
+
line-height: 24px;
|
1781 |
+
display: block;
|
1782 |
+
float: left;
|
1783 |
+
width: auto;
|
1784 |
+
color: #9B9A96;
|
1785 |
+
font-family: Georgia, "Bitstream Charter", serif;
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
.wpsc_featured .item_text .wpsc_description p {
|
1789 |
+
margin-bottom: 0px;
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
.wpsc_featured .item_text .wpsc_description a {
|
1793 |
+
color: #9B9A96;
|
1794 |
+
}
|
1795 |
+
|
1796 |
+
ul.wpsc_categories {
|
1797 |
+
clear: both;
|
1798 |
+
}
|
1799 |
+
|
1800 |
+
a.update_variations_action {
|
1801 |
+
vertical-align: middle;
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
#poststuff .inside p.update-variations {
|
1805 |
+
display: none;
|
1806 |
+
margin-top: 1em;
|
1807 |
+
}
|
1808 |
+
|
1809 |
+
#search-products {
|
1810 |
+
width: auto;
|
1811 |
+
float: right;
|
1812 |
+
}
|
1813 |
+
|
1814 |
+
.productnav {
|
1815 |
+
height: 30px;
|
1816 |
+
margin: 6px 0px 4px;
|
1817 |
+
vertical-align: middle;
|
1818 |
+
}
|
1819 |
+
|
1820 |
+
#wpsc_stock_control_forms .edit_stock {
|
1821 |
+
margin-top: 15px;
|
1822 |
+
line-height: 16px;
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
#wpsc_stock_control_forms .unpublish_when_none_left,
|
1826 |
+
#wpsc_stock_control_forms .notify_when_none_left {
|
1827 |
+
margin: 0.5em 0;
|
1828 |
+
}
|
1829 |
+
|
1830 |
+
#media-upload form p.help {
|
1831 |
+
text-align: left;
|
1832 |
+
clear: both;
|
1833 |
+
}
|
1834 |
+
|
1835 |
+
ul#category_list_li li:hover span.handle {
|
1836 |
+
cursor: move;
|
1837 |
+
}
|
1838 |
+
|
1839 |
+
ul#category_list_li li span.handle {
|
1840 |
+
float: left;
|
1841 |
+
padding: 5px;
|
1842 |
+
}
|
1843 |
+
|
1844 |
+
.category_admin_list_img a.row-title {
|
1845 |
+
text-decoration: none;
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
.category_admin_list_img:hover div.row-actions {
|
1849 |
+
visibility: visible;
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
ul#category_list_li ul {
|
1853 |
+
margin-left: 15px;
|
1854 |
+
}
|
1855 |
+
|
1856 |
+
.row-title img {
|
1857 |
+
width: 30px;
|
1858 |
+
float: left;
|
1859 |
+
padding-right: 10px;
|
1860 |
+
}
|
1861 |
+
|
1862 |
+
.row-title {
|
1863 |
+
margin-right: 5px;
|
1864 |
+
}
|
1865 |
+
|
1866 |
+
body.edit-php form#posts-filter {
|
1867 |
+
min-width: 830px;
|
1868 |
+
}
|
1869 |
+
|
1870 |
+
input.wpsc_cat_image_size {
|
1871 |
+
width: 40px
|
1872 |
+
}
|
1873 |
+
|
1874 |
+
input.wpsc_cat_box {
|
1875 |
+
width: auto;
|
1876 |
+
margin: 6px;
|
1877 |
+
vertical-align: middle;
|
1878 |
+
}
|
1879 |
+
|
1880 |
+
.wpsc_ie_field {
|
1881 |
+
width: 100%;
|
1882 |
+
}
|
1883 |
+
|
1884 |
+
.wpsc_inline_actions .loading_indicator {
|
1885 |
+
position: relative;
|
1886 |
+
top: 3px;
|
1887 |
+
left: 2px;
|
1888 |
+
visibility: hidden;
|
1889 |
+
}
|
1890 |
+
|
1891 |
+
table.tags th#image {
|
1892 |
+
width: 60px;
|
1893 |
+
}
|
1894 |
+
|
1895 |
+
|
1896 |
+
/**
|
1897 |
+
* Quick and bulk edit product
|
1898 |
+
*/
|
1899 |
+
|
1900 |
+
#wpbody-content .bulk-edit-row-post fieldset.wpsc-cols {
|
1901 |
+
width: 49%;
|
1902 |
+
margin-top: 0;
|
1903 |
+
}
|
1904 |
+
|
1905 |
+
#wpbody-content .quick-edit-row-post .inline-edit-col-left {
|
1906 |
+
width: 35%;
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
.bulk-edit-row-post fieldset.inline-edit-col-right label span.title {
|
1910 |
+
padding-right: 0.5em;
|
1911 |
+
width: auto;
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
.wpsc-quick-edit {
|
1915 |
+
width: 30%;
|
1916 |
+
float: left;
|
1917 |
+
}
|
1918 |
+
|
1919 |
+
textarea.tax_input_product_tag {
|
1920 |
+
width: 50% !important;
|
1921 |
+
height: 95px !important;
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
ul.wpsc_product_category-checklist {
|
1925 |
+
height: 280px;
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
span.wpsc-quick-edit {
|
1929 |
+
width: 77px;
|
1930 |
+
display: block;
|
1931 |
+
float: left;
|
1932 |
+
}
|
1933 |
+
|
1934 |
+
.wpsc_var_description {
|
1935 |
+
margin: 20px 0 0 20px !important;
|
1936 |
+
color: red;
|
1937 |
+
}
|
1938 |
+
|
1939 |
+
.ajax-loading {
|
1940 |
+
visibility: hidden;
|
1941 |
+
}
|
1942 |
+
|
1943 |
+
#cart_options .delete {
|
1944 |
+
color: #c00;
|
1945 |
+
float: right;
|
1946 |
+
}
|
1947 |
+
|
1948 |
+
#cart_options .delete:hover {
|
1949 |
+
color: #D54E21;
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
.dashboard_page_wpsc-update .wpsc-progress-bar {
|
1953 |
+
position: relative;
|
1954 |
+
height: 20px;
|
1955 |
+
width: 300px;
|
1956 |
+
border: 1px solid #3a58cf;
|
1957 |
+
margin: -0.75em 0 27px;
|
1958 |
+
}
|
1959 |
+
|
1960 |
+
.dashboard_page_wpsc-update .wpsc-progress-bar * {
|
1961 |
+
position: absolute;
|
1962 |
+
left: 0;
|
1963 |
+
top: 0;
|
1964 |
+
background: #f9f9f9;
|
1965 |
+
font-size: 12px;
|
1966 |
+
}
|
1967 |
+
|
1968 |
+
.dashboard_page_wpsc-update .wpsc-progress-bar .block {
|
1969 |
+
background-color: #527dff;
|
1970 |
+
z-index: -1;
|
1971 |
+
height: 20px;
|
1972 |
+
}
|
1973 |
+
|
1974 |
+
.dashboard_page_wpsc-update .wpsc-progress-bar span {
|
1975 |
+
display: block;
|
1976 |
+
left: 310px;
|
1977 |
+
line-height: 20px;
|
1978 |
+
width: 200px;
|
1979 |
+
}
|
1980 |
+
|
1981 |
+
.dashboard_page_wpsc-update .wpsc-progress-bar .eta {
|
1982 |
+
top: 22px;
|
1983 |
+
line-height: 15px;
|
1984 |
+
width: 100%;
|
1985 |
+
}
|
1986 |
+
|
1987 |
+
.downloadables_float {
|
1988 |
+
float: right;
|
1989 |
+
width: 80px;
|
1990 |
+
vertical-align: middle;
|
1991 |
+
}
|
1992 |
+
|
1993 |
+
.downloadables_headding1 {
|
1994 |
+
display: inline;
|
1995 |
+
float: left;
|
1996 |
+
text-align: left;
|
1997 |
+
vertical-align: middle;
|
1998 |
+
width: auto;
|
1999 |
+
}
|
2000 |
+
|
2001 |
+
img.ajax-feedback-active {
|
2002 |
+
vertical-align: middle;
|
2003 |
+
visibility: visible;
|
2004 |
+
}
|
2005 |
+
|
2006 |
+
.dashboard_page_wpsc-purchase-logs .column-id {
|
2007 |
+
width: 75px;
|
2008 |
+
}
|
2009 |
+
|
2010 |
+
.dashboard_page_wpsc-purchase-logs .column-amount {
|
2011 |
+
width: 100px;
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
.js table.purchase-logs td.column-status span,
|
2015 |
+
table.purchase-logs .column-status select {
|
2016 |
+
display: none;
|
2017 |
+
}
|
2018 |
+
|
2019 |
+
.js table.purchase-logs .column-status select {
|
2020 |
+
display: inline-block;
|
2021 |
+
margin-right: 5px;
|
2022 |
+
}
|
2023 |
+
|
2024 |
+
table.purchase-logs .column-tracking .empty {
|
2025 |
+
position: relative;
|
2026 |
+
}
|
2027 |
+
|
2028 |
+
table.purchase-logs .column-tracking .empty .send-email {
|
2029 |
+
display: none;
|
2030 |
+
}
|
2031 |
+
|
2032 |
+
table.purchase-logs .column-tracking .add {
|
2033 |
+
position: absolute;
|
2034 |
+
left: 6px;
|
2035 |
+
top: 4px;
|
2036 |
+
}
|
2037 |
+
|
2038 |
+
table.purchase-logs .column-tracking {
|
2039 |
+
width: 200px;
|
2040 |
+
}
|
2041 |
+
|
2042 |
+
table.purchase-logs .column-tracking input[type="text"] {
|
2043 |
+
width: 180px;
|
2044 |
+
}
|
2045 |
+
|
2046 |
+
table.purchase-logs .column-tracking a.save {
|
2047 |
+
display: none;
|
2048 |
+
float: right;
|
2049 |
+
}
|
2050 |
+
|
2051 |
+
table.purchase-logs .column-tracking a.add {
|
2052 |
+
display: none;
|
2053 |
+
color: #ccc;
|
2054 |
+
cursor: text;
|
2055 |
+
}
|
2056 |
+
|
2057 |
+
table.purchase-logs .column-tracking .empty a.add {
|
2058 |
+
display: inline;
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
table.purchase-logs .column-tracking .ajax-feedback {
|
2062 |
+
display: none;
|
2063 |
+
float: right;
|
2064 |
+
margin-top: 5px;
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
table.purchase-logs .column-tracking .ajax-feedback-active {
|
2068 |
+
display: inline-block;
|
2069 |
+
}
|
2070 |
+
|
2071 |
+
table.purchase-logs .column-tracking em.sent {
|
2072 |
+
color: green;
|
2073 |
+
}
|
2074 |
+
|
2075 |
+
table.purchase-logs .column-id .delete {
|
2076 |
+
color: red;
|
2077 |
+
visibility: hidden;
|
2078 |
+
}
|
2079 |
+
|
2080 |
+
table.purchase-logs tr:hover .column-id .delete {
|
2081 |
+
visibility: visible;
|
2082 |
+
}
|
2083 |
+
|
2084 |
+
|
2085 |
+
/**
|
2086 |
+
* Product Variations
|
2087 |
+
*/
|
2088 |
+
|
2089 |
+
.no-js #wpsc_product_variation_forms iframe {
|
2090 |
+
height: 300px;
|
2091 |
+
}
|
2092 |
+
|
2093 |
+
.js #wpsc_product_variation_forms iframe {
|
2094 |
+
border: 0;
|
2095 |
+
margin: 0;
|
2096 |
+
overflow: hidden;
|
2097 |
+
padding: 0;
|
2098 |
+
}
|
2099 |
+
|
2100 |
+
#wpsc_product_variation_forms .inside {
|
2101 |
+
margin: 0;
|
2102 |
+
padding: 0 12px 0 12px;
|
2103 |
+
}
|
2104 |
+
|
2105 |
+
#wpsc_product_variation_forms iframe {
|
2106 |
+
background: transparent;
|
2107 |
+
width: 100%;
|
2108 |
+
}
|
2109 |
+
|
2110 |
+
.wpsc-product-variation-iframe {
|
2111 |
+
min-width: 400px;
|
2112 |
+
padding: 6px 0 12px 0;
|
2113 |
+
overflow:hidden;
|
2114 |
+
}
|
2115 |
+
|
2116 |
+
#wpsc-product-variations-wrapper .tablenav.top {
|
2117 |
+
margin-top: 0;
|
2118 |
+
}
|
2119 |
+
|
2120 |
+
.wpsc-save-variations-top {
|
2121 |
+
float: right;
|
2122 |
+
margin: 8px 0 5px;
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
#wpsc-product-variations-wrapper .column-stock input[type="text"],
|
2126 |
+
#wpsc-product-variations-wrapper .column-tax input[type="text"],
|
2127 |
+
#wpsc-product-variations-wrapper .column-price input[type="text"],
|
2128 |
+
#wpsc-product-variations-wrapper .column-sale_price input[type="text"],
|
2129 |
+
#wpsc-product-variations-wrapper .column-sku input[type="text"] {
|
2130 |
+
width: 100%;
|
2131 |
+
-webkit-box-sizing: border-box;
|
2132 |
+
-moz-box-sizing: border-box;
|
2133 |
+
-o-box-sizing: border-box;
|
2134 |
+
box-sizing: border-box;
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
#wpsc-product-variations-wrapper .inline-edit-row.column-stock input[type="text"],
|
2138 |
+
#wpsc-product-variations-wrapper .inline-edit-row.column-tax input[type="text"],
|
2139 |
+
#wpsc-product-variations-wrapper .inline-edit-row.column-price input[type="text"],
|
2140 |
+
#wpsc-product-variations-wrapper .inline-edit-row.column-sale_price input[type="text"],
|
2141 |
+
#wpsc-product-variations-wrapper .inline-edit-row.column-sku input[type="text"] {
|
2142 |
+
width: 60%;
|
2143 |
+
}
|
2144 |
+
|
2145 |
+
#wpsc-product-variations-wrapper .column-stock,
|
2146 |
+
#wpsc-product-variations-wrapper .column-tax,
|
2147 |
+
#wpsc-product-variations-wrapper .column-price,
|
2148 |
+
#wpsc-product-variations-wrapper .column-sale_price,
|
2149 |
+
#wpsc-product-variations-wrapper .column-sku {
|
2150 |
+
text-align: center;
|
2151 |
+
width: 11%;
|
2152 |
+
}
|
2153 |
+
|
2154 |
+
#wpsc-product-variations-wrapper .column-stock input,
|
2155 |
+
#wpsc-product-variations-wrapper .column-tax input,
|
2156 |
+
#wpsc-product-variations-wrapper .column-price input,
|
2157 |
+
#wpsc-product-variations-wrapper .column-sale_price input,
|
2158 |
+
#wpsc-product-variations-wrapper .column-sku input {
|
2159 |
+
text-align: right;
|
2160 |
+
}
|
2161 |
+
|
2162 |
+
.js #wpsc-product-variations-wrapper tbody .active td,
|
2163 |
+
.js #wpsc-product-variations-wrapper tbody .active th {
|
2164 |
+
border-bottom-style: dashed;
|
2165 |
+
}
|
2166 |
+
|
2167 |
+
#wpsc-product-variations-wrapper div.updated,
|
2168 |
+
#wpsc-product-variations-wrapper div.error {
|
2169 |
+
margin: 15px 0 2px;
|
2170 |
+
}
|
2171 |
+
|
2172 |
+
.js #wpsc-product-variations-wrapper .wpsc-stock-editor-row {
|
2173 |
+
display: none;
|
2174 |
+
}
|
2175 |
+
|
2176 |
+
#wpsc-product-variations-wrapper .wpsc-stock-editor-row td {
|
2177 |
+
border-bottom-style: solid;
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
#wpsc-product-variations-wrapper {
|
2181 |
+
padding-bottom: 5px;
|
2182 |
+
}
|
2183 |
+
|
2184 |
+
#wpsc-product-variations-wrapper .submit {
|
2185 |
+
margin: 0;
|
2186 |
+
padding: 0;
|
2187 |
+
}
|
2188 |
+
|
2189 |
+
.wpsc-stock-editor .inside {
|
2190 |
+
overflow: hidden;
|
2191 |
+
}
|
2192 |
+
|
2193 |
+
.wpsc-stock-editor .wpsc-product-shipping-section {
|
2194 |
+
vertical-align: top;
|
2195 |
+
}
|
2196 |
+
|
2197 |
+
.wpsc-stock-editor .wpsc-form-field {
|
2198 |
+
clear: both;
|
2199 |
+
}
|
2200 |
+
|
2201 |
+
.wpsc-stock-editor .wpsc-form-field label {
|
2202 |
+
width: 150px;
|
2203 |
+
}
|
2204 |
+
|
2205 |
+
.wpsc-stock-editor .wpsc-form-field input[type="number"] {
|
2206 |
+
width: 70px;
|
2207 |
+
}
|
2208 |
+
|
2209 |
+
.wpsc-stock-editor .wpsc-product-shipping-section input[type="text"] {
|
2210 |
+
text-align: right;
|
2211 |
+
width: 50px;
|
2212 |
+
}
|
2213 |
+
|
2214 |
+
.wpsc-product-shipping-weight-dimensions label {
|
2215 |
+
display: inline-block;
|
2216 |
+
min-width: 60px;
|
2217 |
+
}
|
2218 |
+
|
2219 |
+
.wpsc-product-shipping-flat-rate label {
|
2220 |
+
display: inline-block;
|
2221 |
+
min-width: 160px;
|
2222 |
+
}
|
2223 |
+
|
2224 |
+
.wpsc-stock-editor {
|
2225 |
+
overflow: hidden;
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
.wpsc-stock-editor select {
|
2229 |
+
min-width: 100px;
|
2230 |
+
}
|
2231 |
+
|
2232 |
+
.wpsc-product-variations-tabs {
|
2233 |
+
margin: 0 0 1px 0;
|
2234 |
+
width: 100%;
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
.wpsc-product-variations-tabs:before,
|
2238 |
+
.wpsc-product-variations-tabs:after {
|
2239 |
+
display: table;
|
2240 |
+
content: "";
|
2241 |
+
}
|
2242 |
+
|
2243 |
+
.wpsc-product-variations-tabs:after {
|
2244 |
+
clear: both;
|
2245 |
+
}
|
2246 |
+
|
2247 |
+
.wpsc-product-variations-tabs li {
|
2248 |
+
float: left;
|
2249 |
+
margin: 5px 4px 0 0px;
|
2250 |
+
}
|
2251 |
+
|
2252 |
+
.wpsc-product-variations-tabs a {
|
2253 |
+
display: block;
|
2254 |
+
background-color: #f1f1f1;
|
2255 |
+
border-color: #dfdfdf #dfdfdf #fff;
|
2256 |
+
border-style: solid;
|
2257 |
+
border-width: 1px 1px 0;
|
2258 |
+
line-height: 1em;
|
2259 |
+
color: #aaa;
|
2260 |
+
padding: 5px 7px 3px;
|
2261 |
+
text-decoration: none;
|
2262 |
+
vertical-align: middle;
|
2263 |
+
-webkit-border-top-right-radius: 3px;
|
2264 |
+
-moz-border-top-right-radius: 3px;
|
2265 |
+
border-top-right-radius: 3px;
|
2266 |
+
-webkit-border-top-left-radius: 3px;
|
2267 |
+
-moz-border-top-left-radius: 3px;
|
2268 |
+
border-top-left-radius: 3px;
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
.wpsc-product-variations-tabs a:hover {
|
2272 |
+
color: #D54E21;
|
2273 |
+
}
|
2274 |
+
|
2275 |
+
.wpsc-product-variations-tabs .active a {
|
2276 |
+
background: #fff;
|
2277 |
+
border-bottom-width: 1px;
|
2278 |
+
color: #333;
|
2279 |
+
margin-bottom: -1px;
|
2280 |
+
}
|
2281 |
+
|
2282 |
+
.wpsc-product-variations-tab-content {
|
2283 |
+
clear: both;
|
2284 |
+
padding: 0 10px;
|
2285 |
+
}
|
2286 |
+
|
2287 |
+
.wpsc-save-product-variations.top {
|
2288 |
+
margin: 8px 0 5px;
|
2289 |
+
}
|
2290 |
+
|
2291 |
+
.wpsc-save-product-variations.bottom {
|
2292 |
+
float: none;
|
2293 |
+
overflow: hidden;
|
2294 |
+
padding-bottom: 5px;
|
2295 |
+
}
|
2296 |
+
.wpsc-save-product-variations.bottom input {
|
2297 |
+
float: right;
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
.wpsc-product-variation-thumbnail {
|
2301 |
+
float: left;
|
2302 |
+
height: 50px;
|
2303 |
+
width: 50px;
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
.wpsc-product-variation-thumbnail img {
|
2307 |
+
max-height: 50px;
|
2308 |
+
max-width: 50px;
|
2309 |
+
}
|
2310 |
+
|
2311 |
+
.wpsc-product-variation-title {
|
2312 |
+
margin-left: 60px;
|
2313 |
+
}
|
2314 |
+
|
2315 |
+
.compat-field-wpsc_image_size input[type="radio"] {
|
2316 |
+
width: auto;
|
2317 |
+
margin-right:5px;
|
2318 |
+
}
|
2319 |
+
|
2320 |
+
.wpsc-button-round {
|
2321 |
+
padding: 0 0 1px !important;
|
2322 |
+
height: 28px !important;
|
2323 |
+
text-align: center;
|
2324 |
+
width: 28px !important;
|
2325 |
+
-webkit-border-radius: 14px !important;
|
2326 |
+
border-radius: 14px !important;
|
2327 |
+
outline: 0 !important;
|
2328 |
+
}
|
2329 |
+
|
2330 |
+
/* Make the minus sign look balanced with the plus sign */
|
2331 |
+
|
2332 |
+
.wpsc-button-minus {
|
2333 |
+
font-weight: bold;
|
2334 |
+
font-size: 10px !important;
|
2335 |
+
}
|
2336 |
+
|
2337 |
+
span.wpsc-button-round {
|
2338 |
+
cursor: default !important;
|
2339 |
+
opacity: 0.3;
|
2340 |
+
}
|
2341 |
+
|
2342 |
+
.wpsc-coupon-status-active {
|
2343 |
+
color: #1be032;
|
2344 |
+
}
|
2345 |
+
|
2346 |
+
.wpsc-coupon-status-inactive {
|
2347 |
+
color: #e01b1b;
|
2348 |
+
}
|
2349 |
+
|
2350 |
+
th.right-col {
|
2351 |
+
text-align: right;
|
2352 |
+
padding: 0;
|
2353 |
+
}
|
2354 |
+
|
2355 |
+
div.new_layer {
|
2356 |
+
display: block;
|
2357 |
+
margin-bottom: 10px;
|
2358 |
+
}
|
2359 |
+
|
2360 |
+
div.new_layer > * {
|
2361 |
+
display: inline-block;
|
2362 |
+
vertical-align: middle;
|
2363 |
+
}
|
2364 |
+
|
2365 |
+
div.new_layer select {
|
2366 |
+
height: auto !important;
|
2367 |
+
white-space: nowrap;
|
2368 |
+
}
|
2369 |
+
|
2370 |
+
body.edit-tags-php img.wpsc_category_image {
|
2371 |
+
max-width: 256px;
|
2372 |
+
max-height: 256px;
|
2373 |
+
min-width: 128px;
|
2374 |
+
}
|
2375 |
+
|
2376 |
+
.wpsc-width-height-fields label {
|
2377 |
+
display: inline;
|
2378 |
+
}
|
2379 |
+
|
2380 |
+
|
2381 |
+
/**
|
2382 |
+
* Live Title Meta Box
|
2383 |
+
*/
|
2384 |
+
|
2385 |
+
.wpsc_metabox_live_title {
|
2386 |
+
position: absolute;
|
2387 |
+
right: 30px;
|
2388 |
+
}
|
2389 |
+
|
2390 |
+
.wpsc_metabox_live_title > * {
|
2391 |
+
float: right;
|
2392 |
+
margin: 0px;
|
2393 |
+
padding: 0px;
|
2394 |
+
font-style: normal;
|
2395 |
+
font-size: 13px;
|
2396 |
+
color: #858585;
|
2397 |
+
text-shadow: 1px 1px #fff;
|
2398 |
+
}
|
2399 |
+
|
2400 |
+
#wpsc_product_delivery_metabox_live_title,
|
2401 |
+
#wpsc_product_details_metabox_live_title {
|
2402 |
+
left: 170px;
|
2403 |
+
}
|
2404 |
+
|
2405 |
+
/**
|
2406 |
+
* Product Price Meta Box
|
2407 |
+
*/
|
2408 |
+
|
2409 |
+
.wpsc-categorydiv .tabs-panel {
|
2410 |
+
max-height: none !important;
|
2411 |
+
overflow: visible !important;
|
2412 |
+
padding-top: 5px !important;
|
2413 |
+
padding-bottom: 5px !important;
|
2414 |
+
}
|
2415 |
+
|
2416 |
+
|
2417 |
+
/**
|
2418 |
+
* Product Delivery
|
2419 |
+
*/
|
2420 |
+
|
2421 |
+
#wpsc_product_delivery-external_link th {
|
2422 |
+
width: 50px;
|
2423 |
+
}
|
2424 |
+
|
2425 |
+
#external_link_target {
|
2426 |
+
padding-top: 21px;
|
2427 |
+
}
|
2428 |
+
|
2429 |
+
#external_link_target input {
|
2430 |
+
width: auto;
|
2431 |
+
}
|
2432 |
+
|
2433 |
+
#external_link_target span {
|
2434 |
+
margin-left: 10px;
|
2435 |
+
margin-right: 30px;
|
2436 |
+
}
|
2437 |
+
|
2438 |
+
#wpsc_product_gallery li {
|
2439 |
+
float: left;
|
2440 |
+
margin-right: 10px;
|
2441 |
+
cursor: move;
|
2442 |
+
}
|
2443 |
+
|
2444 |
+
/**
|
2445 |
+
* Digital download table style
|
2446 |
+
*/
|
2447 |
+
|
2448 |
+
#wpsc_digital_download_table {
|
2449 |
+
margin-top: 10px;
|
2450 |
+
margin-bottom: 15px;
|
2451 |
+
}
|
2452 |
+
|
2453 |
+
#wpsc_digital_download_table tfoot {
|
2454 |
+
display: none;
|
2455 |
+
}
|
2456 |
+
|
2457 |
+
#wpsc_digital_download_table a,
|
2458 |
+
#wpsc_digital_download_table img {
|
2459 |
+
display: inline-block;
|
2460 |
+
margin-right: 10px;
|
2461 |
+
}
|
2462 |
+
|
2463 |
+
#wpsc_digital_download_table span {
|
2464 |
+
display: inline-block;
|
2465 |
+
vertical-align: middle;
|
2466 |
+
}
|
2467 |
+
|
2468 |
+
#wpsc_digital_download_table img {
|
2469 |
+
max-height: 20px;
|
2470 |
+
vertical-align: middle;
|
2471 |
+
}
|
2472 |
+
|
2473 |
+
#wpsc_digital_download_action_th {
|
2474 |
+
width: 120px;
|
2475 |
+
}
|
2476 |
+
|
2477 |
+
|
2478 |
+
/**
|
2479 |
+
* Custom meta style
|
2480 |
+
*/
|
2481 |
+
|
2482 |
+
#wpsc_product_meta_table {
|
2483 |
+
margin-bottom: 10px;
|
2484 |
+
margin-top: 10px;
|
2485 |
+
}
|
2486 |
+
|
2487 |
+
#wpsc_product_meta_table tfoot {
|
2488 |
+
display: none;
|
2489 |
+
}
|
2490 |
+
|
2491 |
+
#wpsc_product_meta_table input {
|
2492 |
+
width: 100%;
|
2493 |
+
}
|
2494 |
+
|
2495 |
+
a.wpsc_remove_meta {
|
2496 |
+
color: red;
|
2497 |
+
}
|
2498 |
+
|
2499 |
+
#wpsc_custom_meta_name_th {
|
2500 |
+
width: 250px;
|
2501 |
+
}
|
2502 |
+
|
2503 |
+
#wpsc_custom_meta_action_th {
|
2504 |
+
width: 70px;
|
2505 |
+
}
|
2506 |
+
|
2507 |
+
.wpsc_fileUpload {
|
2508 |
+
display: inline-block;
|
2509 |
+
position: relative;
|
2510 |
+
margin: 10px;
|
2511 |
+
cursor: pointer;
|
2512 |
+
}
|
2513 |
+
|
2514 |
+
.wpsc_fileUpload input {
|
2515 |
+
position: absolute;
|
2516 |
+
top: 0;
|
2517 |
+
bottom: 0;
|
2518 |
+
right: 0;
|
2519 |
+
left: 0;
|
2520 |
+
margin: 0;
|
2521 |
+
padding: 0;
|
2522 |
+
font-size: 20px;
|
2523 |
+
cursor: pointer;
|
2524 |
+
opacity: 0;
|
2525 |
+
filter: alpha(opacity=0);
|
2526 |
+
}
|
2527 |
+
|
2528 |
+
#wpsc_sku {
|
2529 |
+
width: 100%;
|
2530 |
+
}
|
2531 |
+
|
2532 |
+
|
2533 |
+
/**
|
2534 |
+
* WordPress 3.8 Responsiveness
|
2535 |
+
*/
|
2536 |
+
|
2537 |
+
@media screen and ( max-width: 782px ) {
|
2538 |
+
|
2539 |
+
/**
|
2540 |
+
* Override responsiveness in variations iframe
|
2541 |
+
*/
|
2542 |
+
|
2543 |
+
/* Buttons */
|
2544 |
+
.wpsc-product-variation-iframe.wp-core-ui .button,
|
2545 |
+
.wpsc-product-variation-iframe.wp-core-ui .button.button-large,
|
2546 |
+
.wpsc-product-variation-iframe.wp-core-ui .button.button-small {
|
2547 |
+
padding: 0px 10px 1px;
|
2548 |
+
line-height: 2;
|
2549 |
+
font-size: 13px;
|
2550 |
+
vertical-align: top;
|
2551 |
+
height: 28px;
|
2552 |
+
margin-bottom: 0px;
|
2553 |
+
}
|
2554 |
+
|
2555 |
+
.wpsc-product-variation-iframe.wp-core-ui .button:active,
|
2556 |
+
.wpsc-product-variation-iframe.wp-core-ui .button-large:active,
|
2557 |
+
.wpsc-product-variation-iframe.wp-core-ui .button-small:active {
|
2558 |
+
padding-top: 1px;
|
2559 |
+
padding-bottom: 0;
|
2560 |
+
}
|
2561 |
+
|
2562 |
+
/* Categories Metabox */
|
2563 |
+
.wpsc-product-variation-iframe ul.category-tabs {
|
2564 |
+
margin: 12px 0 5px;
|
2565 |
+
}
|
2566 |
+
|
2567 |
+
.wpsc-product-variation-iframe ul.category-tabs li.tabs {
|
2568 |
+
padding: 3px 5px 5px;
|
2569 |
+
}
|
2570 |
+
|
2571 |
+
/* Subsubsub Nav */
|
2572 |
+
.wpsc-product-variation-iframe .subsubsub {
|
2573 |
+
font-size: 13px;
|
2574 |
+
margin: 8px 0px 0px;
|
2575 |
+
}
|
2576 |
+
|
2577 |
+
/* Form Tables */
|
2578 |
+
.wpsc-product-variation-iframe input[type="checkbox"],
|
2579 |
+
.wpsc-product-variation-iframe .widefat th input[type="checkbox"] {
|
2580 |
+
padding: 0px;
|
2581 |
+
}
|
2582 |
+
|
2583 |
+
.wpsc-product-variation-iframe input[type="radio"],
|
2584 |
+
.wpsc-product-variation-iframe input[type="checkbox"] {
|
2585 |
+
width: 16px;
|
2586 |
+
height: 16px;
|
2587 |
+
}
|
2588 |
+
|
2589 |
+
.wpsc-product-variation-iframe textarea,
|
2590 |
+
.wpsc-product-variation-iframe input,
|
2591 |
+
.wpsc-product-variation-iframe select {
|
2592 |
+
font-size: 14px;
|
2593 |
+
}
|
2594 |
+
|
2595 |
+
.wpsc-product-variation-iframe input[type=checkbox]:checked:before,
|
2596 |
+
.wpsc-product-variation-iframe .widefat th input[type=checkbox]:before {
|
2597 |
+
font-size: 21px;
|
2598 |
+
margin: -3px 0 0 -4px;
|
2599 |
+
}
|
2600 |
+
|
2601 |
+
.wpsc-product-variation-iframe input[type="text"],
|
2602 |
+
.wpsc-product-variation-iframe input[type="search"],
|
2603 |
+
.wpsc-product-variation-iframe input[type="password"],
|
2604 |
+
.wpsc-product-variation-iframe input[type="number"] {
|
2605 |
+
padding: 3px 5px;
|
2606 |
+
}
|
2607 |
+
|
2608 |
+
.wpsc-product-variation-iframe .tablenav.bottom .displaying-num {
|
2609 |
+
font-size: 12px;
|
2610 |
+
}
|
2611 |
+
|
2612 |
+
}
|
2613 |
+
|
2614 |
+
|
2615 |
+
/**
|
2616 |
+
* Pre WordPress 3.8 Compatibility
|
2617 |
+
*/
|
2618 |
+
|
2619 |
+
|
2620 |
+
.branch-3-7.wpsc-product-variation-iframe #post-body,
|
2621 |
+
.branch-3-6.wpsc-product-variation-iframe #post-body {
|
2622 |
+
background: #f5f5f5;
|
2623 |
+
background-image: -webkit-gradient(linear,left bottom,left top,from(#f5f5f5),to(#f9f9f9));
|
2624 |
+
background-image: -webkit-linear-gradient(bottom, #f5f5f5, #f9f9f9);
|
2625 |
+
background-image: -moz-linear-gradient(bottom, #f5f5f5, #f9f9f9);
|
2626 |
+
background-image: -o-linear-gradient(bottom, #f5f5f5, #f9f9f9);
|
2627 |
+
background-image: linear-gradient(to top, #f5f5f5, #f9f9f9);
|
2628 |
+
}
|
2629 |
+
|
2630 |
+
.branch-3-7.wpsc-product-variation-iframe .widefat td.column-title,
|
2631 |
+
.branch-3-6.wpsc-product-variation-iframe .widefat td.column-title {
|
2632 |
+
padding-bottom: 5px;
|
2633 |
+
}
|
2634 |
+
|
2635 |
+
.branch-3-7 .wpsc-currency-layers td.remove a,
|
2636 |
+
.branch-3-7 .wpsc-quantity-discounts td.remove a,
|
2637 |
+
.branch-3-6 .wpsc-currency-layers td.remove a,
|
2638 |
+
.branch-3-6 .wpsc-quantity-discounts td.remove a {
|
2639 |
+
background: url(xit.gif) no-repeat 0 0;
|
2640 |
+
display: inline-block;
|
2641 |
+
margin-top: 7px;
|
2642 |
+
overflow: hidden;
|
2643 |
+
text-indent: -999px;
|
2644 |
+
width: 10px;
|
2645 |
+
height: 10px;
|
2646 |
+
}
|
2647 |
+
|
2648 |
+
.branch-3-7 .wpsc-currency-layers td.remove a:hover,
|
2649 |
+
.branch-3-7 .wpsc-quantity-discounts td.remove a:hover,
|
2650 |
+
.branch-3-6 .wpsc-currency-layers td.remove a:hover,
|
2651 |
+
.branch-3-6 .wpsc-quantity-discounts td.remove a:hover {
|
2652 |
+
background-position: -10px 0;
|
2653 |
+
}
|
2654 |
+
|
2655 |
+
.product_gallery_image_delete_button {
|
2656 |
+
display: none;
|
2657 |
+
}
|
2658 |
+
|
2659 |
+
.list_gallery_image {
|
2660 |
+
position: relative;
|
2661 |
+
}
|
2662 |
+
|
2663 |
+
.product_gallery_image_delete_button {
|
2664 |
+
position: absolute;
|
2665 |
+
right: 0;
|
2666 |
+
top: 0;
|
2667 |
+
font-size: 16px;
|
2668 |
+
}
|
2669 |
+
|
2670 |
+
.product_gallery_image_delete_button:hover,
|
2671 |
+
.wpsc-remove-row button {
|
2672 |
+
cursor: pointer
|
2673 |
+
}
|
2674 |
+
|
2675 |
+
.wpsc-refund-ui {
|
2676 |
+
display: none;
|
2677 |
+
}
|
trunk/wpsc-admin/css/arrows.png
ADDED
Binary file
|
trunk/wpsc-admin/css/jquery.ui.datepicker-classic.css
ADDED
@@ -0,0 +1,579 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery UI CSS Framework 1.8.16
|
3 |
+
*
|
4 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
+
* http://jquery.org/license
|
7 |
+
*
|
8 |
+
* http://docs.jquery.com/UI/Theming/API
|
9 |
+
*
|
10 |
+
* Credit goes to Helen Hou-Sandi:
|
11 |
+
* https://github.com/helenhousandi/wp-admin-jquery-ui
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
/* Layout helpers
|
16 |
+
----------------------------------*/
|
17 |
+
.ui-helper-hidden { display: none; }
|
18 |
+
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
19 |
+
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
20 |
+
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
|
21 |
+
.ui-helper-clearfix { display: inline-block; }
|
22 |
+
/* required comment for clearfix to work in Opera \*/
|
23 |
+
* html .ui-helper-clearfix { height:1%; }
|
24 |
+
.ui-helper-clearfix { display:block; }
|
25 |
+
/* end clearfix */
|
26 |
+
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
27 |
+
|
28 |
+
|
29 |
+
/* Interaction Cues
|
30 |
+
----------------------------------*/
|
31 |
+
.ui-state-disabled { cursor: default !important; }
|
32 |
+
|
33 |
+
|
34 |
+
/* Icons
|
35 |
+
----------------------------------*/
|
36 |
+
|
37 |
+
/* states and images */
|
38 |
+
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
39 |
+
|
40 |
+
|
41 |
+
/* Misc visuals
|
42 |
+
----------------------------------*/
|
43 |
+
|
44 |
+
/* Overlays */
|
45 |
+
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
46 |
+
|
47 |
+
|
48 |
+
/*
|
49 |
+
* jQuery UI CSS Framework 1.8.16
|
50 |
+
*
|
51 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
52 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
53 |
+
* http://jquery.org/license
|
54 |
+
*
|
55 |
+
* http://docs.jquery.com/UI/Theming/API
|
56 |
+
*
|
57 |
+
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=sans-serif&fwDefault=normal&fsDefault=12px&cornerRadius=3px&bgColorHeader=eff8ff&bgTextureHeader=04_highlight_hard.png&bgImgOpacityHeader=75&borderColorHeader=d1e5ee&fcHeader=333333&iconColorHeader=21759b&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=d1e5ee&fcContent=333333&iconColorContent=333333&bgColorDefault=eff8ff&bgTextureDefault=04_highlight_hard.png&bgImgOpacityDefault=75&borderColorDefault=d1e5ee&fcDefault=333333&iconColorDefault=333333&bgColorHover=f7fcfe&bgTextureHover=06_inset_hard.png&bgImgOpacityHover=75&borderColorHover=b8d7e5&fcHover=000000&iconColorHover=333333&bgColorActive=ffffff&bgTextureActive=01_flat.png&bgImgOpacityActive=65&borderColorActive=d1e5ee&fcActive=333333&iconColorActive=333333&bgColorHighlight=ffffe0&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=e6db55&fcHighlight=333333&iconColorHighlight=21759b&bgColorError=ffebe8&bgTextureError=01_flat.png&bgImgOpacityError=95&borderColorError=cc0000&fcError=cc0000&iconColorError=cc0000&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=3px
|
58 |
+
*/
|
59 |
+
|
60 |
+
|
61 |
+
/* Component containers
|
62 |
+
----------------------------------*/
|
63 |
+
.ui-widget { font-family: sans-serif; font-size: 12px; }
|
64 |
+
.ui-widget .ui-widget { font-size: 1em; }
|
65 |
+
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: sans-serif; font-size: 1em; }
|
66 |
+
.ui-widget-content { border: 1px solid #d1e5ee; background: #ffffff; color: #333333; }
|
67 |
+
.ui-widget-header { border: 1px solid #d1e5ee; background-color: #f5fafd; background-image: -ms-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -moz-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -o-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -webkit-gradient(linear, left top, left bottom, from(#f7fcfe), to(#eff8ff)); background-image: -webkit-linear-gradient(top, #f7fcfe, #eff8ff); background-image: linear-gradient(top, #f7fcfe, #eff8ff); color: #333333; font-weight: bold; }
|
68 |
+
.ui-widget-header a { color: #333333; }
|
69 |
+
|
70 |
+
/* Interaction states
|
71 |
+
----------------------------------*/
|
72 |
+
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d1e5ee; background-color: #f5fafd; background-image: -ms-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -moz-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -o-linear-gradient(top, #f7fcfe, #eff8ff); background-image: -webkit-gradient(linear, left top, left bottom, from(#f7fcfe), to(#eff8ff)); background-image: -webkit-linear-gradient(top, #f7fcfe, #eff8ff); background-image: linear-gradient(top, #f7fcfe, #eff8ff); font-weight: normal; color: #333333; }
|
73 |
+
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #333333; text-decoration: none; }
|
74 |
+
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #b8d7e5; background-color: #f7fcfe; background-image: -ms-linear-gradient(top, #eff8ff, #f7fcfe); background-image: -moz-linear-gradient(top, #eff8ff, #f7fcfe); background-image: -o-linear-gradient(top, #eff8ff, #f7fcfe); background-image: -webkit-gradient(linear, left top, left bottom, from(#eff8ff), to(#f7fcfe)); background-image: -webkit-linear-gradient(top, #eff8ff, #f7fcfe); background-image: linear-gradient(top, #eff8ff, #f7fcfe);; font-weight: normal; color: #000000; }
|
75 |
+
.ui-state-hover a, .ui-state-hover a:hover { color: #000000; text-decoration: none; }
|
76 |
+
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #d1e5ee; background: #ffffff; font-weight: normal; color: #333333; }
|
77 |
+
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #333333; text-decoration: none; }
|
78 |
+
.ui-widget :active { outline: none; }
|
79 |
+
|
80 |
+
/* Interaction Cues
|
81 |
+
----------------------------------*/
|
82 |
+
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #e6db55; background: #ffffe0; color: #333333; }
|
83 |
+
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #333333; }
|
84 |
+
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cc0000; background: #ffebe8; color: #cc0000; }
|
85 |
+
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cc0000; }
|
86 |
+
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cc0000; }
|
87 |
+
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
88 |
+
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
89 |
+
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
90 |
+
|
91 |
+
/* Icons
|
92 |
+
----------------------------------*/
|
93 |
+
|
94 |
+
/* states and images */
|
95 |
+
.ui-icon { width: 16px; height: 16px; background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
96 |
+
.ui-widget-content .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
97 |
+
.ui-widget-header .ui-icon {background-image: url(ui-images/ui-icons_999999_256x240.png); }
|
98 |
+
.ui-state-default .ui-icon { background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
99 |
+
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
100 |
+
.ui-state-active .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
101 |
+
.ui-state-highlight .ui-icon {background-image: url(ui-images/ui-icons_21759b_256x240.png); }
|
102 |
+
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(ui-images/ui-icons_cc0000_256x240.png); }
|
103 |
+
|
104 |
+
/* positioning */
|
105 |
+
.ui-icon-carat-1-n { background-position: 0 0; }
|
106 |
+
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
107 |
+
.ui-icon-carat-1-e { background-position: -32px 0; }
|
108 |
+
.ui-icon-carat-1-se { background-position: -48px 0; }
|
109 |
+
.ui-icon-carat-1-s { background-position: -64px 0; }
|
110 |
+
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
111 |
+
.ui-icon-carat-1-w { background-position: -96px 0; }
|
112 |
+
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
113 |
+
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
114 |
+
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
115 |
+
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
116 |
+
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
117 |
+
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
118 |
+
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
119 |
+
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
120 |
+
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
121 |
+
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
122 |
+
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
123 |
+
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
124 |
+
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
125 |
+
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
126 |
+
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
127 |
+
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
128 |
+
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
129 |
+
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
130 |
+
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
131 |
+
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
132 |
+
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
133 |
+
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
134 |
+
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
135 |
+
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
136 |
+
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
137 |
+
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
138 |
+
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
139 |
+
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
140 |
+
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
141 |
+
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
142 |
+
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
143 |
+
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
144 |
+
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
145 |
+
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
146 |
+
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
147 |
+
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
148 |
+
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
149 |
+
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
150 |
+
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
151 |
+
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
152 |
+
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
153 |
+
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
154 |
+
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
155 |
+
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
156 |
+
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
157 |
+
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
158 |
+
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
159 |
+
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
160 |
+
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
161 |
+
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
162 |
+
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
163 |
+
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
164 |
+
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
165 |
+
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
166 |
+
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
167 |
+
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
168 |
+
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
169 |
+
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
170 |
+
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
171 |
+
.ui-icon-extlink { background-position: -32px -80px; }
|
172 |
+
.ui-icon-newwin { background-position: -48px -80px; }
|
173 |
+
.ui-icon-refresh { background-position: -64px -80px; }
|
174 |
+
.ui-icon-shuffle { background-position: -80px -80px; }
|
175 |
+
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
176 |
+
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
177 |
+
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
178 |
+
.ui-icon-folder-open { background-position: -16px -96px; }
|
179 |
+
.ui-icon-document { background-position: -32px -96px; }
|
180 |
+
.ui-icon-document-b { background-position: -48px -96px; }
|
181 |
+
.ui-icon-note { background-position: -64px -96px; }
|
182 |
+
.ui-icon-mail-closed { background-position: -80px -96px; }
|
183 |
+
.ui-icon-mail-open { background-position: -96px -96px; }
|
184 |
+
.ui-icon-suitcase { background-position: -112px -96px; }
|
185 |
+
.ui-icon-comment { background-position: -128px -96px; }
|
186 |
+
.ui-icon-person { background-position: -144px -96px; }
|
187 |
+
.ui-icon-print { background-position: -160px -96px; }
|
188 |
+
.ui-icon-trash { background-position: -176px -96px; }
|
189 |
+
.ui-icon-locked { background-position: -192px -96px; }
|
190 |
+
.ui-icon-unlocked { background-position: -208px -96px; }
|
191 |
+
.ui-icon-bookmark { background-position: -224px -96px; }
|
192 |
+
.ui-icon-tag { background-position: -240px -96px; }
|
193 |
+
.ui-icon-home { background-position: 0 -112px; }
|
194 |
+
.ui-icon-flag { background-position: -16px -112px; }
|
195 |
+
.ui-icon-calendar { background-position: -32px -112px; }
|
196 |
+
.ui-icon-cart { background-position: -48px -112px; }
|
197 |
+
.ui-icon-pencil { background-position: -64px -112px; }
|
198 |
+
.ui-icon-clock { background-position: -80px -112px; }
|
199 |
+
.ui-icon-disk { background-position: -96px -112px; }
|
200 |
+
.ui-icon-calculator { background-position: -112px -112px; }
|
201 |
+
.ui-icon-zoomin { background-position: -128px -112px; }
|
202 |
+
.ui-icon-zoomout { background-position: -144px -112px; }
|
203 |
+
.ui-icon-search { background-position: -160px -112px; }
|
204 |
+
.ui-icon-wrench { background-position: -176px -112px; }
|
205 |
+
.ui-icon-gear { background-position: -192px -112px; }
|
206 |
+
.ui-icon-heart { background-position: -208px -112px; }
|
207 |
+
.ui-icon-star { background-position: -224px -112px; }
|
208 |
+
.ui-icon-link { background-position: -240px -112px; }
|
209 |
+
.ui-icon-cancel { background-position: 0 -128px; }
|
210 |
+
.ui-icon-plus { background-position: -16px -128px; }
|
211 |
+
.ui-icon-plusthick { background-position: -32px -128px; }
|
212 |
+
.ui-icon-minus { background-position: -48px -128px; }
|
213 |
+
.ui-icon-minusthick { background-position: -64px -128px; }
|
214 |
+
.ui-icon-close { background-position: -80px -128px; }
|
215 |
+
.ui-icon-closethick { background-position: -96px -128px; }
|
216 |
+
.ui-icon-key { background-position: -112px -128px; }
|
217 |
+
.ui-icon-lightbulb { background-position: -128px -128px; }
|
218 |
+
.ui-icon-scissors { background-position: -144px -128px; }
|
219 |
+
.ui-icon-clipboard { background-position: -160px -128px; }
|
220 |
+
.ui-icon-copy { background-position: -176px -128px; }
|
221 |
+
.ui-icon-contact { background-position: -192px -128px; }
|
222 |
+
.ui-icon-image { background-position: -208px -128px; }
|
223 |
+
.ui-icon-video { background-position: -224px -128px; }
|
224 |
+
.ui-icon-script { background-position: -240px -128px; }
|
225 |
+
.ui-icon-alert { background-position: 0 -144px; }
|
226 |
+
.ui-icon-info { background-position: -16px -144px; }
|
227 |
+
.ui-icon-notice { background-position: -32px -144px; }
|
228 |
+
.ui-icon-help { background-position: -48px -144px; }
|
229 |
+
.ui-icon-check { background-position: -64px -144px; }
|
230 |
+
.ui-icon-bullet { background-position: -80px -144px; }
|
231 |
+
.ui-icon-radio-off { background-position: -96px -144px; }
|
232 |
+
.ui-icon-radio-on { background-position: -112px -144px; }
|
233 |
+
.ui-icon-pin-w { background-position: -128px -144px; }
|
234 |
+
.ui-icon-pin-s { background-position: -144px -144px; }
|
235 |
+
.ui-icon-play { background-position: 0 -160px; }
|
236 |
+
.ui-icon-pause { background-position: -16px -160px; }
|
237 |
+
.ui-icon-seek-next { background-position: -32px -160px; }
|
238 |
+
.ui-icon-seek-prev { background-position: -48px -160px; }
|
239 |
+
.ui-icon-seek-end { background-position: -64px -160px; }
|
240 |
+
.ui-icon-seek-start { background-position: -80px -160px; }
|
241 |
+
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
242 |
+
.ui-icon-seek-first { background-position: -80px -160px; }
|
243 |
+
.ui-icon-stop { background-position: -96px -160px; }
|
244 |
+
.ui-icon-eject { background-position: -112px -160px; }
|
245 |
+
.ui-icon-volume-off { background-position: -128px -160px; }
|
246 |
+
.ui-icon-volume-on { background-position: -144px -160px; }
|
247 |
+
.ui-icon-power { background-position: 0 -176px; }
|
248 |
+
.ui-icon-signal-diag { background-position: -16px -176px; }
|
249 |
+
.ui-icon-signal { background-position: -32px -176px; }
|
250 |
+
.ui-icon-battery-0 { background-position: -48px -176px; }
|
251 |
+
.ui-icon-battery-1 { background-position: -64px -176px; }
|
252 |
+
.ui-icon-battery-2 { background-position: -80px -176px; }
|
253 |
+
.ui-icon-battery-3 { background-position: -96px -176px; }
|
254 |
+
.ui-icon-circle-plus { background-position: 0 -192px; }
|
255 |
+
.ui-icon-circle-minus { background-position: -16px -192px; }
|
256 |
+
.ui-icon-circle-close { background-position: -32px -192px; }
|
257 |
+
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
258 |
+
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
259 |
+
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
260 |
+
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
261 |
+
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
262 |
+
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
263 |
+
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
264 |
+
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
265 |
+
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
266 |
+
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
267 |
+
.ui-icon-circle-check { background-position: -208px -192px; }
|
268 |
+
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
269 |
+
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
270 |
+
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
271 |
+
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
272 |
+
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
273 |
+
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
274 |
+
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
275 |
+
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
276 |
+
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
277 |
+
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
278 |
+
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
279 |
+
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
280 |
+
|
281 |
+
|
282 |
+
/* Misc visuals
|
283 |
+
----------------------------------*/
|
284 |
+
|
285 |
+
/* Corner radius */
|
286 |
+
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 3px; -webkit-border-top-left-radius: 3px; -khtml-border-top-left-radius: 3px; border-top-left-radius: 3px; }
|
287 |
+
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 3px; -khtml-border-top-right-radius: 3px; border-top-right-radius: 3px; }
|
288 |
+
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 3px; -webkit-border-bottom-left-radius: 3px; -khtml-border-bottom-left-radius: 3px; border-bottom-left-radius: 3px; }
|
289 |
+
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 3px; -webkit-border-bottom-right-radius: 3px; -khtml-border-bottom-right-radius: 3px; border-bottom-right-radius: 3px; }
|
290 |
+
|
291 |
+
/* Overlays */
|
292 |
+
.ui-widget-overlay { background: #000000; opacity: .6;filter:Alpha(Opacity=60); }
|
293 |
+
.ui-widget-shadow { box-shadow: 0 0 16px rgba(0, 0, 0, 0.3); }/*
|
294 |
+
* jQuery UI Resizable 1.8.16
|
295 |
+
*
|
296 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
297 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
298 |
+
* http://jquery.org/license
|
299 |
+
*
|
300 |
+
* http://docs.jquery.com/UI/Resizable#theming
|
301 |
+
*/
|
302 |
+
.ui-resizable { position: relative;}
|
303 |
+
.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block; }
|
304 |
+
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
|
305 |
+
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
|
306 |
+
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
|
307 |
+
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
|
308 |
+
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
|
309 |
+
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
|
310 |
+
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
|
311 |
+
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
|
312 |
+
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
|
313 |
+
* jQuery UI Selectable 1.8.16
|
314 |
+
*
|
315 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
316 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
317 |
+
* http://jquery.org/license
|
318 |
+
*
|
319 |
+
* http://docs.jquery.com/UI/Selectable#theming
|
320 |
+
*/
|
321 |
+
.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
|
322 |
+
/*
|
323 |
+
* jQuery UI Accordion 1.8.16
|
324 |
+
*
|
325 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
326 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
327 |
+
* http://jquery.org/license
|
328 |
+
*
|
329 |
+
* http://docs.jquery.com/UI/Accordion#theming
|
330 |
+
*/
|
331 |
+
/* IE/Win - Fix animation bug - #4615 */
|
332 |
+
.ui-accordion { width: 100%; }
|
333 |
+
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
|
334 |
+
.ui-accordion .ui-accordion-li-fix { display: inline; }
|
335 |
+
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
|
336 |
+
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
|
337 |
+
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
|
338 |
+
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
|
339 |
+
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
|
340 |
+
.ui-accordion .ui-accordion-content-active { display: block; }
|
341 |
+
/*
|
342 |
+
* jQuery UI Autocomplete 1.8.16
|
343 |
+
*
|
344 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
345 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
346 |
+
* http://jquery.org/license
|
347 |
+
*
|
348 |
+
* http://docs.jquery.com/UI/Autocomplete#theming
|
349 |
+
*/
|
350 |
+
.ui-autocomplete { position: absolute; cursor: default; }
|
351 |
+
|
352 |
+
/* workarounds */
|
353 |
+
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
|
354 |
+
|
355 |
+
/*
|
356 |
+
* jQuery UI Menu 1.8.16
|
357 |
+
*
|
358 |
+
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
|
359 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
360 |
+
* http://jquery.org/license
|
361 |
+
*
|
362 |
+
* http://docs.jquery.com/UI/Menu#theming
|
363 |
+
*/
|
364 |
+
.ui-menu {
|
365 |
+
list-style:none;
|
366 |
+
padding: 2px;
|
367 |
+
margin: 0;
|
368 |
+
display:block;
|
369 |
+
float: left;
|
370 |
+
}
|
371 |
+
.ui-menu .ui-menu {
|
372 |
+
margin-top: -3px;
|
373 |
+
}
|
374 |
+
.ui-menu .ui-menu-item {
|
375 |
+
margin:0;
|
376 |
+
padding: 0;
|
377 |
+
zoom: 1;
|
378 |
+
float: left;
|
379 |
+
clear: left;
|
380 |
+
width: 100%;
|
381 |
+
}
|
382 |
+
.ui-menu .ui-menu-item a {
|
383 |
+
text-decoration:none;
|
384 |
+
display:block;
|
385 |
+
padding:.2em .4em;
|
386 |
+
line-height:1.5;
|
387 |
+
zoom:1;
|
388 |
+
}
|
389 |
+
.ui-menu .ui-menu-item a.ui-state-hover,
|
390 |
+
.ui-menu .ui-menu-item a.ui-state-active {
|
391 |
+
font-weight: normal;
|
392 |
+
margin: -1px;
|
393 |
+
}
|
394 |
+
/*
|
395 |
+
* jQuery UI Button 1.8.16
|
396 |
+
*
|
397 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
398 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
399 |
+
* http://jquery.org/license
|
400 |
+
*
|
401 |
+
* http://docs.jquery.com/UI/Button#theming
|
402 |
+
*/
|
403 |
+
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
|
404 |
+
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
|
405 |
+
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
|
406 |
+
.ui-button-icons-only { width: 3.4em; }
|
407 |
+
button.ui-button-icons-only { width: 3.7em; }
|
408 |
+
|
409 |
+
/*button text element */
|
410 |
+
.ui-button .ui-button-text { display: block; line-height: 1.4; }
|
411 |
+
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
|
412 |
+
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
|
413 |
+
.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
|
414 |
+
.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
|
415 |
+
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
|
416 |
+
/* no icon support for input elements, provide padding by default */
|
417 |
+
input.ui-button { padding: .4em 1em; }
|
418 |
+
|
419 |
+
/*button icon element(s) */
|
420 |
+
.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
|
421 |
+
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
|
422 |
+
.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
|
423 |
+
.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
424 |
+
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
425 |
+
|
426 |
+
/*button sets*/
|
427 |
+
.ui-buttonset { margin-right: 7px; }
|
428 |
+
.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
|
429 |
+
|
430 |
+
/* workarounds */
|
431 |
+
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
|
432 |
+
/*
|
433 |
+
* jQuery UI Dialog 1.8.16
|
434 |
+
*
|
435 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
436 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
437 |
+
* http://jquery.org/license
|
438 |
+
*
|
439 |
+
* http://docs.jquery.com/UI/Dialog#theming
|
440 |
+
*/
|
441 |
+
.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
|
442 |
+
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
|
443 |
+
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
|
444 |
+
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
|
445 |
+
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
|
446 |
+
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
|
447 |
+
.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
|
448 |
+
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
|
449 |
+
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
|
450 |
+
.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
|
451 |
+
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
|
452 |
+
.ui-draggable .ui-dialog-titlebar { cursor: move; }
|
453 |
+
/*
|
454 |
+
* jQuery UI Slider 1.8.16
|
455 |
+
*
|
456 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
457 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
458 |
+
* http://jquery.org/license
|
459 |
+
*
|
460 |
+
* http://docs.jquery.com/UI/Slider#theming
|
461 |
+
*/
|
462 |
+
.ui-slider { position: relative; text-align: left; }
|
463 |
+
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
|
464 |
+
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
|
465 |
+
|
466 |
+
.ui-slider-horizontal { height: .8em; }
|
467 |
+
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
|
468 |
+
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
|
469 |
+
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
|
470 |
+
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
|
471 |
+
|
472 |
+
.ui-slider-vertical { width: .8em; height: 100px; }
|
473 |
+
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
|
474 |
+
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
|
475 |
+
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
|
476 |
+
.ui-slider-vertical .ui-slider-range-max { top: 0; }/*
|
477 |
+
* jQuery UI Tabs 1.8.16
|
478 |
+
*
|
479 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
480 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
481 |
+
* http://jquery.org/license
|
482 |
+
*
|
483 |
+
* http://docs.jquery.com/UI/Tabs#theming
|
484 |
+
*/
|
485 |
+
.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
486 |
+
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
|
487 |
+
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
|
488 |
+
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
|
489 |
+
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
|
490 |
+
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
|
491 |
+
.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
|
492 |
+
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
|
493 |
+
.ui-tabs .ui-tabs-hide { display: none !important; }
|
494 |
+
/*
|
495 |
+
* jQuery UI Datepicker 1.8.16
|
496 |
+
*
|
497 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
498 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
499 |
+
* http://jquery.org/license
|
500 |
+
*
|
501 |
+
* http://docs.jquery.com/UI/Datepicker#theming
|
502 |
+
*/
|
503 |
+
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
|
504 |
+
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
|
505 |
+
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
|
506 |
+
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
507 |
+
.ui-datepicker .ui-datepicker-prev { left:2px; }
|
508 |
+
.ui-datepicker .ui-datepicker-next { right:2px; }
|
509 |
+
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
510 |
+
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
511 |
+
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
512 |
+
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
513 |
+
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
514 |
+
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
515 |
+
.ui-datepicker select.ui-datepicker-month,
|
516 |
+
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
517 |
+
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
518 |
+
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
|
519 |
+
.ui-datepicker td { border: 0; padding: 1px; }
|
520 |
+
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
521 |
+
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
522 |
+
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
523 |
+
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
524 |
+
|
525 |
+
/* with multiple calendars */
|
526 |
+
.ui-datepicker.ui-datepicker-multi { width:auto; }
|
527 |
+
.ui-datepicker-multi .ui-datepicker-group { float:left; }
|
528 |
+
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
529 |
+
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
530 |
+
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
531 |
+
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
532 |
+
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
533 |
+
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
534 |
+
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
535 |
+
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
536 |
+
|
537 |
+
/* RTL support */
|
538 |
+
.ui-datepicker-rtl { direction: rtl; }
|
539 |
+
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
540 |
+
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
541 |
+
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
542 |
+
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
543 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
544 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
545 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
546 |
+
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
547 |
+
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
548 |
+
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
549 |
+
|
550 |
+
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
551 |
+
.ui-datepicker-cover {
|
552 |
+
display: none; /*sorry for IE5*/
|
553 |
+
display/**/: block; /*sorry for IE5*/
|
554 |
+
position: absolute; /*must have*/
|
555 |
+
z-index: -1; /*must have*/
|
556 |
+
filter: mask(); /*must have*/
|
557 |
+
top: -4px; /*must have*/
|
558 |
+
left: -4px; /*must have*/
|
559 |
+
width: 200px; /*must have*/
|
560 |
+
height: 200px; /*must have*/
|
561 |
+
}/*
|
562 |
+
* jQuery UI Progressbar 1.8.16
|
563 |
+
*
|
564 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
565 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
566 |
+
* http://jquery.org/license
|
567 |
+
*
|
568 |
+
* http://docs.jquery.com/UI/Progressbar#theming
|
569 |
+
*/
|
570 |
+
.ui-progressbar { height:2em; text-align: left; }
|
571 |
+
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
|
572 |
+
.ui-progressbar .ui-widget-header {
|
573 |
+
background-color: #83B4D8;
|
574 |
+
background-image: linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
575 |
+
background-image: -o-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
576 |
+
background-image: -moz-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
577 |
+
background-image: -webkit-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
578 |
+
background-image: -ms-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
579 |
+
}
|
trunk/wpsc-admin/css/jquery.ui.datepicker-fresh.css
ADDED
@@ -0,0 +1,579 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery UI CSS Framework 1.8.16
|
3 |
+
*
|
4 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
+
* http://jquery.org/license
|
7 |
+
*
|
8 |
+
* http://docs.jquery.com/UI/Theming/API
|
9 |
+
*
|
10 |
+
* Credit goes to Helen Hou-Sandi:
|
11 |
+
* https://github.com/helenhousandi/wp-admin-jquery-ui
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
|
15 |
+
/* Layout helpers
|
16 |
+
----------------------------------*/
|
17 |
+
.ui-helper-hidden { display: none; }
|
18 |
+
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
19 |
+
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
20 |
+
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
|
21 |
+
.ui-helper-clearfix { display: inline-block; }
|
22 |
+
/* required comment for clearfix to work in Opera \*/
|
23 |
+
* html .ui-helper-clearfix { height:1%; }
|
24 |
+
.ui-helper-clearfix { display:block; }
|
25 |
+
/* end clearfix */
|
26 |
+
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
27 |
+
|
28 |
+
|
29 |
+
/* Interaction Cues
|
30 |
+
----------------------------------*/
|
31 |
+
.ui-state-disabled { cursor: default !important; }
|
32 |
+
|
33 |
+
|
34 |
+
/* Icons
|
35 |
+
----------------------------------*/
|
36 |
+
|
37 |
+
/* states and images */
|
38 |
+
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
39 |
+
|
40 |
+
|
41 |
+
/* Misc visuals
|
42 |
+
----------------------------------*/
|
43 |
+
|
44 |
+
/* Overlays */
|
45 |
+
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
46 |
+
|
47 |
+
|
48 |
+
/*
|
49 |
+
* jQuery UI CSS Framework 1.8.16
|
50 |
+
*
|
51 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
52 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
53 |
+
* http://jquery.org/license
|
54 |
+
*
|
55 |
+
* http://docs.jquery.com/UI/Theming/API
|
56 |
+
*
|
57 |
+
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=sans-serif&fwDefault=normal&fsDefault=12px&cornerRadius=4px&bgColorHeader=ececec&bgTextureHeader=04_highlight_hard.png&bgImgOpacityHeader=75&borderColorHeader=dfdfdf&fcHeader=333333&iconColorHeader=999999&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=dfdfdf&fcContent=333333&iconColorContent=333333&bgColorDefault=ececec&bgTextureDefault=04_highlight_hard.png&bgImgOpacityDefault=75&borderColorDefault=dfdfdf&fcDefault=333333&iconColorDefault=333333&bgColorHover=ececec&bgTextureHover=06_inset_hard.png&bgImgOpacityHover=75&borderColorHover=ccc&fcHover=000000&iconColorHover=333333&bgColorActive=ffffff&bgTextureActive=01_flat.png&bgImgOpacityActive=65&borderColorActive=dfdfdf&fcActive=333333&iconColorActive=333333&bgColorHighlight=ffffe0&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=e6db55&fcHighlight=333333&iconColorHighlight=21759b&bgColorError=ffebe8&bgTextureError=01_flat.png&bgImgOpacityError=95&borderColorError=cc0000&fcError=cc0000&iconColorError=cc0000&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=3px
|
58 |
+
*/
|
59 |
+
|
60 |
+
|
61 |
+
/* Component containers
|
62 |
+
----------------------------------*/
|
63 |
+
.ui-widget { font-family: sans-serif; font-size: 12px; }
|
64 |
+
.ui-widget .ui-widget { font-size: 1em; }
|
65 |
+
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: sans-serif; font-size: 1em; }
|
66 |
+
.ui-widget-content { border: 1px solid #dfdfdf; background: #ffffff; color: #333333; }
|
67 |
+
.ui-widget-header { border: 1px solid #dfdfdf; color: #333333; font-weight: bold; background-color: #f1f1f1; background-image: -ms-linear-gradient(top, #f9f9f9, #ececec); background-image: -moz-linear-gradient(top, #f9f9f9, #ececec); background-image: -o-linear-gradient(top, #f9f9f9, #ececec); background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec)); background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec); background-image: linear-gradient(top, #f9f9f9, #ececec); }
|
68 |
+
.ui-widget-header a { color: #333333; }
|
69 |
+
|
70 |
+
/* Interaction states
|
71 |
+
----------------------------------*/
|
72 |
+
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #dfdfdf; background-color: #f1f1f1; background-image: -ms-linear-gradient(top, #f9f9f9, #ececec); background-image: -moz-linear-gradient(top, #f9f9f9, #ececec); background-image: -o-linear-gradient(top, #f9f9f9, #ececec); background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec)); background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec); background-image: linear-gradient(top, #f9f9f9, #ececec); font-weight: normal; color: #333333; }
|
73 |
+
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #333333; text-decoration: none; }
|
74 |
+
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #ccc; background-color: #ececec; background-image: -ms-linear-gradient(top, #ececec, #f9f9f9); background-image: -moz-linear-gradient(top, #ececec, #f9f9f9); background-image: -o-linear-gradient(top, #ececec, #f9f9f9); background-image: -webkit-gradient(linear, left top, left bottom, from(#ececec), to(#f9f9f9)); background-image: -webkit-linear-gradient(top, #ececec, #f9f9f9); background-image: linear-gradient(top, #ececec, #f9f9f9); font-weight: normal; color: #000000; }
|
75 |
+
.ui-state-hover a, .ui-state-hover a:hover { color: #000000; text-decoration: none; }
|
76 |
+
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #dfdfdf; background: #ffffff; font-weight: normal; color: #333333; }
|
77 |
+
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #333333; text-decoration: none; }
|
78 |
+
.ui-widget :active { outline: none; }
|
79 |
+
|
80 |
+
/* Interaction Cues
|
81 |
+
----------------------------------*/
|
82 |
+
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #e6db55; background: #ffffe0; color: #333333; }
|
83 |
+
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #333333; }
|
84 |
+
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cc0000; background: #ffebe8; color: #cc0000; }
|
85 |
+
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cc0000; }
|
86 |
+
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cc0000; }
|
87 |
+
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
88 |
+
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
89 |
+
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
90 |
+
|
91 |
+
/* Icons
|
92 |
+
----------------------------------*/
|
93 |
+
|
94 |
+
/* states and images */
|
95 |
+
.ui-icon { width: 16px; height: 16px; background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
96 |
+
.ui-widget-content .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
97 |
+
.ui-widget-header .ui-icon {background-image: url(ui-images/ui-icons_999999_256x240.png); }
|
98 |
+
.ui-state-default .ui-icon { background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
99 |
+
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
100 |
+
.ui-state-active .ui-icon {background-image: url(ui-images/ui-icons_333333_256x240.png); }
|
101 |
+
.ui-state-highlight .ui-icon {background-image: url(ui-images/ui-icons_21759b_256x240.png); }
|
102 |
+
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(ui-images/ui-icons_cc0000_256x240.png); }
|
103 |
+
|
104 |
+
/* positioning */
|
105 |
+
.ui-icon-carat-1-n { background-position: 0 0; }
|
106 |
+
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
107 |
+
.ui-icon-carat-1-e { background-position: -32px 0; }
|
108 |
+
.ui-icon-carat-1-se { background-position: -48px 0; }
|
109 |
+
.ui-icon-carat-1-s { background-position: -64px 0; }
|
110 |
+
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
111 |
+
.ui-icon-carat-1-w { background-position: -96px 0; }
|
112 |
+
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
113 |
+
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
114 |
+
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
115 |
+
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
116 |
+
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
117 |
+
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
118 |
+
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
119 |
+
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
120 |
+
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
121 |
+
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
122 |
+
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
123 |
+
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
124 |
+
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
125 |
+
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
126 |
+
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
127 |
+
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
128 |
+
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
129 |
+
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
130 |
+
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
131 |
+
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
132 |
+
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
133 |
+
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
134 |
+
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
135 |
+
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
136 |
+
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
137 |
+
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
138 |
+
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
139 |
+
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
140 |
+
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
141 |
+
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
142 |
+
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
143 |
+
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
144 |
+
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
145 |
+
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
146 |
+
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
147 |
+
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
148 |
+
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
149 |
+
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
150 |
+
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
151 |
+
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
152 |
+
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
153 |
+
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
154 |
+
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
155 |
+
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
156 |
+
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
157 |
+
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
158 |
+
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
159 |
+
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
160 |
+
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
161 |
+
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
162 |
+
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
163 |
+
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
164 |
+
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
165 |
+
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
166 |
+
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
167 |
+
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
168 |
+
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
169 |
+
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
170 |
+
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
171 |
+
.ui-icon-extlink { background-position: -32px -80px; }
|
172 |
+
.ui-icon-newwin { background-position: -48px -80px; }
|
173 |
+
.ui-icon-refresh { background-position: -64px -80px; }
|
174 |
+
.ui-icon-shuffle { background-position: -80px -80px; }
|
175 |
+
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
176 |
+
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
177 |
+
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
178 |
+
.ui-icon-folder-open { background-position: -16px -96px; }
|
179 |
+
.ui-icon-document { background-position: -32px -96px; }
|
180 |
+
.ui-icon-document-b { background-position: -48px -96px; }
|
181 |
+
.ui-icon-note { background-position: -64px -96px; }
|
182 |
+
.ui-icon-mail-closed { background-position: -80px -96px; }
|
183 |
+
.ui-icon-mail-open { background-position: -96px -96px; }
|
184 |
+
.ui-icon-suitcase { background-position: -112px -96px; }
|
185 |
+
.ui-icon-comment { background-position: -128px -96px; }
|
186 |
+
.ui-icon-person { background-position: -144px -96px; }
|
187 |
+
.ui-icon-print { background-position: -160px -96px; }
|
188 |
+
.ui-icon-trash { background-position: -176px -96px; }
|
189 |
+
.ui-icon-locked { background-position: -192px -96px; }
|
190 |
+
.ui-icon-unlocked { background-position: -208px -96px; }
|
191 |
+
.ui-icon-bookmark { background-position: -224px -96px; }
|
192 |
+
.ui-icon-tag { background-position: -240px -96px; }
|
193 |
+
.ui-icon-home { background-position: 0 -112px; }
|
194 |
+
.ui-icon-flag { background-position: -16px -112px; }
|
195 |
+
.ui-icon-calendar { background-position: -32px -112px; }
|
196 |
+
.ui-icon-cart { background-position: -48px -112px; }
|
197 |
+
.ui-icon-pencil { background-position: -64px -112px; }
|
198 |
+
.ui-icon-clock { background-position: -80px -112px; }
|
199 |
+
.ui-icon-disk { background-position: -96px -112px; }
|
200 |
+
.ui-icon-calculator { background-position: -112px -112px; }
|
201 |
+
.ui-icon-zoomin { background-position: -128px -112px; }
|
202 |
+
.ui-icon-zoomout { background-position: -144px -112px; }
|
203 |
+
.ui-icon-search { background-position: -160px -112px; }
|
204 |
+
.ui-icon-wrench { background-position: -176px -112px; }
|
205 |
+
.ui-icon-gear { background-position: -192px -112px; }
|
206 |
+
.ui-icon-heart { background-position: -208px -112px; }
|
207 |
+
.ui-icon-star { background-position: -224px -112px; }
|
208 |
+
.ui-icon-link { background-position: -240px -112px; }
|
209 |
+
.ui-icon-cancel { background-position: 0 -128px; }
|
210 |
+
.ui-icon-plus { background-position: -16px -128px; }
|
211 |
+
.ui-icon-plusthick { background-position: -32px -128px; }
|
212 |
+
.ui-icon-minus { background-position: -48px -128px; }
|
213 |
+
.ui-icon-minusthick { background-position: -64px -128px; }
|
214 |
+
.ui-icon-close { background-position: -80px -128px; }
|
215 |
+
.ui-icon-closethick { background-position: -96px -128px; }
|
216 |
+
.ui-icon-key { background-position: -112px -128px; }
|
217 |
+
.ui-icon-lightbulb { background-position: -128px -128px; }
|
218 |
+
.ui-icon-scissors { background-position: -144px -128px; }
|
219 |
+
.ui-icon-clipboard { background-position: -160px -128px; }
|
220 |
+
.ui-icon-copy { background-position: -176px -128px; }
|
221 |
+
.ui-icon-contact { background-position: -192px -128px; }
|
222 |
+
.ui-icon-image { background-position: -208px -128px; }
|
223 |
+
.ui-icon-video { background-position: -224px -128px; }
|
224 |
+
.ui-icon-script { background-position: -240px -128px; }
|
225 |
+
.ui-icon-alert { background-position: 0 -144px; }
|
226 |
+
.ui-icon-info { background-position: -16px -144px; }
|
227 |
+
.ui-icon-notice { background-position: -32px -144px; }
|
228 |
+
.ui-icon-help { background-position: -48px -144px; }
|
229 |
+
.ui-icon-check { background-position: -64px -144px; }
|
230 |
+
.ui-icon-bullet { background-position: -80px -144px; }
|
231 |
+
.ui-icon-radio-off { background-position: -96px -144px; }
|
232 |
+
.ui-icon-radio-on { background-position: -112px -144px; }
|
233 |
+
.ui-icon-pin-w { background-position: -128px -144px; }
|
234 |
+
.ui-icon-pin-s { background-position: -144px -144px; }
|
235 |
+
.ui-icon-play { background-position: 0 -160px; }
|
236 |
+
.ui-icon-pause { background-position: -16px -160px; }
|
237 |
+
.ui-icon-seek-next { background-position: -32px -160px; }
|
238 |
+
.ui-icon-seek-prev { background-position: -48px -160px; }
|
239 |
+
.ui-icon-seek-end { background-position: -64px -160px; }
|
240 |
+
.ui-icon-seek-start { background-position: -80px -160px; }
|
241 |
+
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
242 |
+
.ui-icon-seek-first { background-position: -80px -160px; }
|
243 |
+
.ui-icon-stop { background-position: -96px -160px; }
|
244 |
+
.ui-icon-eject { background-position: -112px -160px; }
|
245 |
+
.ui-icon-volume-off { background-position: -128px -160px; }
|
246 |
+
.ui-icon-volume-on { background-position: -144px -160px; }
|
247 |
+
.ui-icon-power { background-position: 0 -176px; }
|
248 |
+
.ui-icon-signal-diag { background-position: -16px -176px; }
|
249 |
+
.ui-icon-signal { background-position: -32px -176px; }
|
250 |
+
.ui-icon-battery-0 { background-position: -48px -176px; }
|
251 |
+
.ui-icon-battery-1 { background-position: -64px -176px; }
|
252 |
+
.ui-icon-battery-2 { background-position: -80px -176px; }
|
253 |
+
.ui-icon-battery-3 { background-position: -96px -176px; }
|
254 |
+
.ui-icon-circle-plus { background-position: 0 -192px; }
|
255 |
+
.ui-icon-circle-minus { background-position: -16px -192px; }
|
256 |
+
.ui-icon-circle-close { background-position: -32px -192px; }
|
257 |
+
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
258 |
+
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
259 |
+
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
260 |
+
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
261 |
+
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
262 |
+
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
263 |
+
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
264 |
+
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
265 |
+
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
266 |
+
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
267 |
+
.ui-icon-circle-check { background-position: -208px -192px; }
|
268 |
+
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
269 |
+
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
270 |
+
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
271 |
+
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
272 |
+
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
273 |
+
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
274 |
+
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
275 |
+
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
276 |
+
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
277 |
+
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
278 |
+
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
279 |
+
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
280 |
+
|
281 |
+
|
282 |
+
/* Misc visuals
|
283 |
+
----------------------------------*/
|
284 |
+
|
285 |
+
/* Corner radius */
|
286 |
+
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 3px; -webkit-border-top-left-radius: 3px; border-top-left-radius: 3px; }
|
287 |
+
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 3px; border-top-right-radius: 3px; }
|
288 |
+
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 3px; -webkit-border-bottom-left-radius: 3px; border-bottom-left-radius: 3px; }
|
289 |
+
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 3px; -webkit-border-bottom-right-radius: 3px; border-bottom-right-radius: 3px; }
|
290 |
+
|
291 |
+
/* Overlays */
|
292 |
+
.ui-widget-overlay { background: #000000; opacity: .6;filter:Alpha(Opacity=60); }
|
293 |
+
.ui-widget-shadow { box-shadow: 0 0 16px rgba(0, 0, 0, 0.3); }/*
|
294 |
+
* jQuery UI Resizable 1.8.16
|
295 |
+
*
|
296 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
297 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
298 |
+
* http://jquery.org/license
|
299 |
+
*
|
300 |
+
* http://docs.jquery.com/UI/Resizable#theming
|
301 |
+
*/
|
302 |
+
.ui-resizable { position: relative;}
|
303 |
+
.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block; }
|
304 |
+
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
|
305 |
+
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
|
306 |
+
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
|
307 |
+
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
|
308 |
+
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
|
309 |
+
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
|
310 |
+
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
|
311 |
+
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
|
312 |
+
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
|
313 |
+
* jQuery UI Selectable 1.8.16
|
314 |
+
*
|
315 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
316 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
317 |
+
* http://jquery.org/license
|
318 |
+
*
|
319 |
+
* http://docs.jquery.com/UI/Selectable#theming
|
320 |
+
*/
|
321 |
+
.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
|
322 |
+
/*
|
323 |
+
* jQuery UI Accordion 1.8.16
|
324 |
+
*
|
325 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
326 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
327 |
+
* http://jquery.org/license
|
328 |
+
*
|
329 |
+
* http://docs.jquery.com/UI/Accordion#theming
|
330 |
+
*/
|
331 |
+
/* IE/Win - Fix animation bug - #4615 */
|
332 |
+
.ui-accordion { width: 100%; }
|
333 |
+
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
|
334 |
+
.ui-accordion .ui-accordion-li-fix { display: inline; }
|
335 |
+
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
|
336 |
+
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
|
337 |
+
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
|
338 |
+
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
|
339 |
+
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
|
340 |
+
.ui-accordion .ui-accordion-content-active { display: block; }
|
341 |
+
/*
|
342 |
+
* jQuery UI Autocomplete 1.8.16
|
343 |
+
*
|
344 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
345 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
346 |
+
* http://jquery.org/license
|
347 |
+
*
|
348 |
+
* http://docs.jquery.com/UI/Autocomplete#theming
|
349 |
+
*/
|
350 |
+
.ui-autocomplete { position: absolute; cursor: default; }
|
351 |
+
|
352 |
+
/* workarounds */
|
353 |
+
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
|
354 |
+
|
355 |
+
/*
|
356 |
+
* jQuery UI Menu 1.8.16
|
357 |
+
*
|
358 |
+
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
|
359 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
360 |
+
* http://jquery.org/license
|
361 |
+
*
|
362 |
+
* http://docs.jquery.com/UI/Menu#theming
|
363 |
+
*/
|
364 |
+
.ui-menu {
|
365 |
+
list-style:none;
|
366 |
+
padding: 2px;
|
367 |
+
margin: 0;
|
368 |
+
display:block;
|
369 |
+
float: left;
|
370 |
+
}
|
371 |
+
.ui-menu .ui-menu {
|
372 |
+
margin-top: -3px;
|
373 |
+
}
|
374 |
+
.ui-menu .ui-menu-item {
|
375 |
+
margin:0;
|
376 |
+
padding: 0;
|
377 |
+
zoom: 1;
|
378 |
+
float: left;
|
379 |
+
clear: left;
|
380 |
+
width: 100%;
|
381 |
+
}
|
382 |
+
.ui-menu .ui-menu-item a {
|
383 |
+
text-decoration:none;
|
384 |
+
display:block;
|
385 |
+
padding:.2em .4em;
|
386 |
+
line-height:1.5;
|
387 |
+
zoom:1;
|
388 |
+
}
|
389 |
+
.ui-menu .ui-menu-item a.ui-state-hover,
|
390 |
+
.ui-menu .ui-menu-item a.ui-state-active {
|
391 |
+
font-weight: normal;
|
392 |
+
margin: -1px;
|
393 |
+
}
|
394 |
+
/*
|
395 |
+
* jQuery UI Button 1.8.16
|
396 |
+
*
|
397 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
398 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
399 |
+
* http://jquery.org/license
|
400 |
+
*
|
401 |
+
* http://docs.jquery.com/UI/Button#theming
|
402 |
+
*/
|
403 |
+
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
|
404 |
+
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
|
405 |
+
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
|
406 |
+
.ui-button-icons-only { width: 3.4em; }
|
407 |
+
button.ui-button-icons-only { width: 3.7em; }
|
408 |
+
|
409 |
+
/*button text element */
|
410 |
+
.ui-button .ui-button-text { display: block; line-height: 1.4; }
|
411 |
+
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
|
412 |
+
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
|
413 |
+
.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
|
414 |
+
.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
|
415 |
+
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
|
416 |
+
/* no icon support for input elements, provide padding by default */
|
417 |
+
input.ui-button { padding: .4em 1em; }
|
418 |
+
|
419 |
+
/*button icon element(s) */
|
420 |
+
.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
|
421 |
+
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
|
422 |
+
.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
|
423 |
+
.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
424 |
+
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
425 |
+
|
426 |
+
/*button sets*/
|
427 |
+
.ui-buttonset { margin-right: 7px; }
|
428 |
+
.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
|
429 |
+
|
430 |
+
/* workarounds */
|
431 |
+
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
|
432 |
+
/*
|
433 |
+
* jQuery UI Dialog 1.8.16
|
434 |
+
*
|
435 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
436 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
437 |
+
* http://jquery.org/license
|
438 |
+
*
|
439 |
+
* http://docs.jquery.com/UI/Dialog#theming
|
440 |
+
*/
|
441 |
+
.ui-dialog { position: fixed; padding: .2em; width: 300px; overflow: hidden; }
|
442 |
+
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
|
443 |
+
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
|
444 |
+
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
|
445 |
+
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
|
446 |
+
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
|
447 |
+
.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
|
448 |
+
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
|
449 |
+
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
|
450 |
+
.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
|
451 |
+
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
|
452 |
+
.ui-draggable .ui-dialog-titlebar { cursor: move; }
|
453 |
+
/*
|
454 |
+
* jQuery UI Slider 1.8.16
|
455 |
+
*
|
456 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
457 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
458 |
+
* http://jquery.org/license
|
459 |
+
*
|
460 |
+
* http://docs.jquery.com/UI/Slider#theming
|
461 |
+
*/
|
462 |
+
.ui-slider { position: relative; text-align: left; }
|
463 |
+
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
|
464 |
+
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
|
465 |
+
|
466 |
+
.ui-slider-horizontal { height: .8em; }
|
467 |
+
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
|
468 |
+
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
|
469 |
+
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
|
470 |
+
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
|
471 |
+
|
472 |
+
.ui-slider-vertical { width: .8em; height: 100px; }
|
473 |
+
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
|
474 |
+
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
|
475 |
+
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
|
476 |
+
.ui-slider-vertical .ui-slider-range-max { top: 0; }/*
|
477 |
+
* jQuery UI Tabs 1.8.16
|
478 |
+
*
|
479 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
480 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
481 |
+
* http://jquery.org/license
|
482 |
+
*
|
483 |
+
* http://docs.jquery.com/UI/Tabs#theming
|
484 |
+
*/
|
485 |
+
.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
486 |
+
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
|
487 |
+
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
|
488 |
+
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
|
489 |
+
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
|
490 |
+
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
|
491 |
+
.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
|
492 |
+
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
|
493 |
+
.ui-tabs .ui-tabs-hide { display: none !important; }
|
494 |
+
/*
|
495 |
+
* jQuery UI Datepicker 1.8.16
|
496 |
+
*
|
497 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
498 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
499 |
+
* http://jquery.org/license
|
500 |
+
*
|
501 |
+
* http://docs.jquery.com/UI/Datepicker#theming
|
502 |
+
*/
|
503 |
+
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
|
504 |
+
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
|
505 |
+
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
|
506 |
+
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
507 |
+
.ui-datepicker .ui-datepicker-prev { left:2px; }
|
508 |
+
.ui-datepicker .ui-datepicker-next { right:2px; }
|
509 |
+
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
510 |
+
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
511 |
+
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
512 |
+
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
513 |
+
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
514 |
+
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
515 |
+
.ui-datepicker select.ui-datepicker-month,
|
516 |
+
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
517 |
+
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
518 |
+
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
|
519 |
+
.ui-datepicker td { border: 0; padding: 1px; }
|
520 |
+
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
521 |
+
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
522 |
+
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
523 |
+
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
524 |
+
|
525 |
+
/* with multiple calendars */
|
526 |
+
.ui-datepicker.ui-datepicker-multi { width:auto; }
|
527 |
+
.ui-datepicker-multi .ui-datepicker-group { float:left; }
|
528 |
+
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
529 |
+
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
530 |
+
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
531 |
+
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
532 |
+
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
533 |
+
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
534 |
+
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
535 |
+
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
536 |
+
|
537 |
+
/* RTL support */
|
538 |
+
.ui-datepicker-rtl { direction: rtl; }
|
539 |
+
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
540 |
+
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
541 |
+
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
542 |
+
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
543 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
544 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
545 |
+
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
546 |
+
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
547 |
+
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
548 |
+
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
549 |
+
|
550 |
+
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
551 |
+
.ui-datepicker-cover {
|
552 |
+
display: none; /*sorry for IE5*/
|
553 |
+
display/**/: block; /*sorry for IE5*/
|
554 |
+
position: absolute; /*must have*/
|
555 |
+
z-index: -1; /*must have*/
|
556 |
+
filter: mask(); /*must have*/
|
557 |
+
top: -4px; /*must have*/
|
558 |
+
left: -4px; /*must have*/
|
559 |
+
width: 200px; /*must have*/
|
560 |
+
height: 200px; /*must have*/
|
561 |
+
}/*
|
562 |
+
* jQuery UI Progressbar 1.8.16
|
563 |
+
*
|
564 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
565 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
566 |
+
* http://jquery.org/license
|
567 |
+
*
|
568 |
+
* http://docs.jquery.com/UI/Progressbar#theming
|
569 |
+
*/
|
570 |
+
.ui-progressbar { height:2em; text-align: left; }
|
571 |
+
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
|
572 |
+
.ui-progressbar .ui-widget-header {
|
573 |
+
background-color: #83B4D8;
|
574 |
+
background-image: linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
575 |
+
background-image: -o-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
576 |
+
background-image: -moz-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
577 |
+
background-image: -webkit-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
578 |
+
background-image: -ms-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
|
579 |
+
}
|
trunk/wpsc-admin/css/jquery.ui.tabs.css
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Caution! Ensure accessibility in print and other media types... */
|
2 |
+
@media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
|
3 |
+
.ui-tabs-hide {
|
4 |
+
display: none;
|
5 |
+
}
|
6 |
+
}
|
7 |
+
|
8 |
+
/* Hide useless elements in print layouts... */
|
9 |
+
@media print {
|
10 |
+
.ui-tabs-nav {
|
11 |
+
display: none;
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
/* Skin */
|
16 |
+
#slider {
|
17 |
+
border-color:#EBEBEB rgb(204, 204, 204) rgb(204, 204, 204) rgb(235, 235, 235);
|
18 |
+
border-style:solid;
|
19 |
+
border-width:1px;
|
20 |
+
margin:0pt 15% 0pt 15px;
|
21 |
+
padding:2px;
|
22 |
+
}
|
23 |
+
#tabs{
|
24 |
+
display: block;
|
25 |
+
background:#EAF3FA none repeat scroll 0%;
|
26 |
+
font-size:14px;
|
27 |
+
margin:0pt 0pt 10px;
|
28 |
+
overflow:hidden;
|
29 |
+
}
|
30 |
+
|
31 |
+
.ui-tabs-nav {
|
32 |
+
list-style: none;
|
33 |
+
margin: 0;
|
34 |
+
padding: 0 0 0 4px;
|
35 |
+
}
|
36 |
+
.ui-tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */
|
37 |
+
display: block;
|
38 |
+
clear: both;
|
39 |
+
content: " ";
|
40 |
+
}
|
41 |
+
.ui-tabs-nav li {
|
42 |
+
float: left;
|
43 |
+
padding:8px 5px;
|
44 |
+
min-width: 84px; /* be nice to Opera */
|
45 |
+
margin: 2px 2px 0px 1px !important;
|
46 |
+
text-decoration: none;
|
47 |
+
list-style: none;
|
48 |
+
}
|
49 |
+
.ui-tabs-nav a, .ui-tabs-nav a span {
|
50 |
+
display: block;
|
51 |
+
padding: 0 10px;
|
52 |
+
}
|
53 |
+
|
54 |
+
.ui-tabs-nav a {
|
55 |
+
margin: 1px 0 0; /* position: relative makes opacity fail for disabled tab in IE */
|
56 |
+
padding-left: 0;
|
57 |
+
color: #27537a;
|
58 |
+
line-height: 1.2;
|
59 |
+
text-align: center;
|
60 |
+
text-decoration: none;
|
61 |
+
white-space: nowrap; /* required in IE 6 */
|
62 |
+
outline: 0; /* prevent dotted border in Firefox */
|
63 |
+
}
|
64 |
+
.ui-tabs-nav .ui-tabs-selected{
|
65 |
+
background:#CEE1EF none repeat scroll 0% 50%;
|
66 |
+
font-weight:bold;
|
67 |
+
-moz-border-radius-topright: 4px;
|
68 |
+
-khtml-border-top-right-radius: 4px;
|
69 |
+
-webkit-border-top-right-radius: 4px;
|
70 |
+
border-top-right-radius: 4px;
|
71 |
+
-moz-border-radius-topleft: 4px;
|
72 |
+
-khtml-border-top-left-radius: 4px;
|
73 |
+
-webkit-border-top-left-radius: 4px;
|
74 |
+
border-top-left-radius: 4px;
|
75 |
+
}
|
76 |
+
.ui-tabs-nav .ui-tabs-selected a {
|
77 |
+
position: relative;
|
78 |
+
top: 1px;
|
79 |
+
z-index: 2;
|
80 |
+
margin-top: 0;
|
81 |
+
color:#333333;
|
82 |
+
}
|
83 |
+
.ui-tabs-nav li a:hover {
|
84 |
+
color:#D54E21;
|
85 |
+
}
|
86 |
+
.ui-tabs-nav a span {
|
87 |
+
width: 64px; /* IE 6 treats width as min-width */
|
88 |
+
min-width: 64px;
|
89 |
+
height: 18px; /* IE 6 treats height as min-height */
|
90 |
+
min-height: 18px;
|
91 |
+
padding-top: 6px;
|
92 |
+
padding-right: 0;
|
93 |
+
}
|
94 |
+
*>.ui-tabs-nav a span { /* hide from IE 6 */
|
95 |
+
width: auto;
|
96 |
+
height: auto;
|
97 |
+
}
|
98 |
+
.ui-tabs-nav .ui-tabs-selected a span {
|
99 |
+
padding-bottom: 1px;
|
100 |
+
}
|
101 |
+
.ui-tabs-nav .ui-tabs-selected a, .ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active {
|
102 |
+
background-position: 100% -150px;
|
103 |
+
}
|
104 |
+
.ui-tabs-nav a, .ui-tabs-nav .ui-tabs-disabled a:hover, .ui-tabs-nav .ui-tabs-disabled a:focus, .ui-tabs-nav .ui-tabs-disabled a:active {
|
105 |
+
background-position: 100% -100px;
|
106 |
+
}
|
107 |
+
.ui-tabs-nav .ui-tabs-selected a span, .ui-tabs-nav a:hover span, .ui-tabs-nav a:focus span, .ui-tabs-nav a:active span {
|
108 |
+
background-position: 0 -50px;
|
109 |
+
}
|
110 |
+
.ui-tabs-nav a span, .ui-tabs-nav .ui-tabs-disabled a:hover span, .ui-tabs-nav .ui-tabs-disabled a:focus span, .ui-tabs-nav .ui-tabs-disabled a:active span {
|
111 |
+
background-position: 0 0;
|
112 |
+
}
|
113 |
+
.ui-tabs-nav .ui-tabs-selected a:link, .ui-tabs-nav .ui-tabs-selected a:visited, .ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */
|
114 |
+
cursor: text;
|
115 |
+
}
|
116 |
+
.ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active,
|
117 |
+
.ui-tabs-nav .ui-tabs-unselect a:hover, .ui-tabs-nav .ui-tabs-unselect a:focus, .ui-tabs-nav .ui-tabs-unselect a:active { /* @ Opera, we need to be explicit again here now... */
|
118 |
+
cursor: pointer;
|
119 |
+
}
|
120 |
+
.ui-tabs-disabled {
|
121 |
+
opacity: .4;
|
122 |
+
filter: alpha(opacity=40);
|
123 |
+
}
|
124 |
+
.ui-tabs-panel {
|
125 |
+
border-top: 1px solid #97a5b0 !important;
|
126 |
+
padding: 1em 8px;
|
127 |
+
background: #fff; /* declare background color for container to avoid distorted fonts in IE while fading */
|
128 |
+
|
129 |
+
/* overwrite wp-admin */
|
130 |
+
border:none !important;
|
131 |
+
height:100% !important;
|
132 |
+
margin:0pt 0pt 0pt 0px !important;
|
133 |
+
overflow:visible !important;
|
134 |
+
}
|
135 |
+
|
136 |
+
.ui-tabs-panel a {
|
137 |
+
display:inline;
|
138 |
+
}
|
139 |
+
|
140 |
+
.ui-tabs-loading em {
|
141 |
+
padding: 0 0 0 20px;
|
142 |
+
background: url(loading.gif) no-repeat 0 50%;
|
143 |
+
}
|
144 |
+
|
145 |
+
/* Additional IE specific bug fixes... */
|
146 |
+
* html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
|
147 |
+
display: inline-block;
|
148 |
+
}
|
149 |
+
*:first-child+html .ui-tabs-nav { /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
|
150 |
+
display: inline-block;
|
151 |
+
}
|
152 |
+
|
trunk/wpsc-admin/css/loading-small.gif
ADDED
Binary file
|
trunk/wpsc-admin/css/media.css
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wpsc-featured-label {
|
2 |
+
position: absolute;
|
3 |
+
bottom: 0;
|
4 |
+
left: 0;
|
5 |
+
right: 0;
|
6 |
+
background: #f1f1f1;
|
7 |
+
background-image: -webkit-gradient(linear, left top, left bottom, from(#f1f1f1), to(#e1e1e1));
|
8 |
+
background-image: -webkit-linear-gradient(top, #f1f1f1, #e1e1e1);
|
9 |
+
background-image: -moz-linear-gradient(top, #f1f1f1, #e1e1e1);
|
10 |
+
background-image: -o-linear-gradient(top, #f1f1f1, #e1e1e1);
|
11 |
+
background-image: linear-gradient(to bottom, #f1f1f1, #e1e1e1);
|
12 |
+
box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.15 );
|
13 |
+
font-weight: bold;
|
14 |
+
text-align: center;
|
15 |
+
color: rgb(70, 70, 70);
|
16 |
+
max-height: 100%;
|
17 |
+
padding: 5px 10px;
|
18 |
+
outline: 0 none;
|
19 |
+
opacity: 0.95;
|
20 |
+
line-height: 1em;
|
21 |
+
}
|
22 |
+
|
23 |
+
.selection-view .wpsc-featured-label {
|
24 |
+
font-size:7px;
|
25 |
+
padding: 2px 0;
|
26 |
+
}
|
trunk/wpsc-admin/css/settingspage.css
ADDED
@@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
tr.wpsc_grey{
|
16 |
+
background-color: #ededed;
|
17 |
+
}
|
18 |
+
td.drag a:hover{
|
19 |
+
cursor: move;
|
20 |
+
}
|
21 |
+
|
22 |
+
th.column-type {
|
23 |
+
width: 9em;
|
24 |
+
}
|
25 |
+
#wpsc_checkout_list th.column-type {
|
26 |
+
width: 9em;
|
27 |
+
}
|
28 |
+
|
29 |
+
th.column-unique_name {
|
30 |
+
width: 9em;
|
31 |
+
}
|
32 |
+
|
33 |
+
th.column-mandatory, th.column-display {
|
34 |
+
width: 6em;
|
35 |
+
}
|
36 |
+
|
37 |
+
.widefat th.column-mandatory, td.mandatorycol, .widefat th.column-display, td.displaycol, .widefat th.column-trash, td.trashcol {
|
38 |
+
text-align:center;
|
39 |
+
vertical-align: top
|
40 |
+
}
|
41 |
+
|
42 |
+
#wpsc_checkout_list td.typecol select {
|
43 |
+
width: 100%;
|
44 |
+
}
|
45 |
+
|
46 |
+
#wpsc_imported_columns ol {
|
47 |
+
margin-top: 0;
|
48 |
+
}
|
49 |
+
#wpsc_imported_columns .empty {
|
50 |
+
color: #999;
|
51 |
+
}
|
52 |
+
|
53 |
+
#checkout_message{
|
54 |
+
display: none;
|
55 |
+
}
|
56 |
+
|
57 |
+
#wpsc_checkout_list td {
|
58 |
+
vertical-align:middle;
|
59 |
+
}
|
60 |
+
|
61 |
+
#wpsc_checkout_list .uniquenamecol small {
|
62 |
+
color:#999;
|
63 |
+
}
|
64 |
+
|
65 |
+
td.drag a img {
|
66 |
+
vertical-align:middle;
|
67 |
+
}
|
68 |
+
|
69 |
+
#wpsc_checkout_list_body .ajax-feedback {
|
70 |
+
display:none;
|
71 |
+
}
|
72 |
+
|
73 |
+
#wpsc_checkout_list_body .ajax-feedback-active {
|
74 |
+
display:inline-block;
|
75 |
+
margin-left:4px;
|
76 |
+
}
|
77 |
+
|
78 |
+
#wpsc_checkout_list .ui-sortable-helper {
|
79 |
+
margin-left:0;
|
80 |
+
}
|
81 |
+
|
82 |
+
#wpsc_checkout_list .namecol input {
|
83 |
+
width: 98%;
|
84 |
+
}
|
85 |
+
|
86 |
+
#wpsc_checkout_list .actionscol .cell-wrapper {
|
87 |
+
float:right !important;
|
88 |
+
}
|
89 |
+
|
90 |
+
tr.checkout-placeholder td {
|
91 |
+
border-width: 1px;
|
92 |
+
border-style: dashed;
|
93 |
+
z-index: 900;
|
94 |
+
border-color: #bbb;
|
95 |
+
background-color: #f5f5f5;
|
96 |
+
margin: -2px 0 0 -2px;
|
97 |
+
}
|
98 |
+
|
99 |
+
/* Removed to prevent overlapping the Contextual Help tab
|
100 |
+
#wpsc_options {
|
101 |
+
position: relative;
|
102 |
+
}
|
103 |
+
*/
|
104 |
+
|
105 |
+
#wpsc_options a.about_this_page {
|
106 |
+
position: absolute;
|
107 |
+
top: 10px;
|
108 |
+
right: 12px;
|
109 |
+
}
|
110 |
+
|
111 |
+
#wpsc_options_page {
|
112 |
+
padding: 0;
|
113 |
+
}
|
114 |
+
|
115 |
+
#options_presentation{
|
116 |
+
margin-right: 370px;
|
117 |
+
}
|
118 |
+
|
119 |
+
table.wpsc-edit-module-options tr td {
|
120 |
+
padding: 0;
|
121 |
+
vertical-align: top;
|
122 |
+
}
|
123 |
+
.wpsc-module-settings {
|
124 |
+
padding: 0 0 8px 8px;
|
125 |
+
width:394px;
|
126 |
+
}
|
127 |
+
.gateway_settings_form,
|
128 |
+
.shipping-module-settings-form {
|
129 |
+
padding: .5em;
|
130 |
+
}
|
131 |
+
.widefat .gateway_settings_form td,
|
132 |
+
.widefat .shipping-module-settings-form td {
|
133 |
+
border: none;
|
134 |
+
overflow: initial;
|
135 |
+
}
|
136 |
+
.widefat .shipping-module-settings-form td input {
|
137 |
+
margin-top: -5px;
|
138 |
+
}
|
139 |
+
.widefat .shipping-module-settings-form th {
|
140 |
+
font-family: inherit;
|
141 |
+
font-size: 12px;
|
142 |
+
}
|
143 |
+
.widefat p.description {
|
144 |
+
color: #666;
|
145 |
+
}
|
146 |
+
.widefat .inactive p.description {
|
147 |
+
margin-left: 0;
|
148 |
+
}
|
149 |
+
.gateway_settings_form p.submit,
|
150 |
+
.shipping-module-settings-form p.submit {
|
151 |
+
margin-top: 2em;
|
152 |
+
}
|
153 |
+
|
154 |
+
.gateway_settings input[type=text]{
|
155 |
+
width: 200px;
|
156 |
+
}
|
157 |
+
.edit-payment-module-update,
|
158 |
+
.edit-shipping-module-update {
|
159 |
+
float: right;
|
160 |
+
}
|
161 |
+
|
162 |
+
tr.rate_row td input[type=text]{
|
163 |
+
width:50px;
|
164 |
+
}
|
165 |
+
div.wpsc_newlayer input[type=text]{
|
166 |
+
width:50px;
|
167 |
+
}
|
168 |
+
.gateway_settings textarea{
|
169 |
+
width:100%;
|
170 |
+
}
|
171 |
+
.gateway_settings h4{
|
172 |
+
margin-bottom:5px;
|
173 |
+
}
|
174 |
+
|
175 |
+
div#wpsc_shipwire_setting, div#shipping_discount_value {
|
176 |
+
display: none;
|
177 |
+
}
|
178 |
+
|
179 |
+
table.wpsc-edit-module-options {
|
180 |
+
margin:0;
|
181 |
+
width:100%;
|
182 |
+
}
|
183 |
+
/* admin checkout page css */
|
184 |
+
div#form_field_form_container{ padding: 0px; margin: 0px; }
|
185 |
+
|
186 |
+
div#form_field_form_container div, div#form_field_form_container div table{ padding: 0px; margin: 0px; width: 100%; border-collapse: collapse; }
|
187 |
+
table#form_field_table tr td.namecol{ }
|
188 |
+
|
189 |
+
table#form_field_table tr *.namecol{ width: 170px; padding-right: 8px; }
|
190 |
+
table#form_field_table tr *.namecol input{ width: 160px; }
|
191 |
+
|
192 |
+
tr td.namecol{ padding-left: 2em; }
|
193 |
+
tr.field_type_heading td.namecol { padding-left: 0; }
|
194 |
+
|
195 |
+
table#form_field_table tr *.typecol{ width: 120px; }
|
196 |
+
table#form_field_table tr *.typecol select{ width: 115px; }
|
197 |
+
|
198 |
+
table#form_field_table tr *.mandatorycol{ width: 90px; text-align: center; }
|
199 |
+
table#form_field_table tr *.mandatorycol input{ }
|
200 |
+
|
201 |
+
table#form_field_table tr *.logdisplaycol{ width: 70px; text-align: center; }
|
202 |
+
table#form_field_table tr *.logdisplaycol input{ }
|
203 |
+
|
204 |
+
table#form_field_table tr *.ordercol{ width: 70px; text-align: center; }
|
205 |
+
table#form_field_table tr *.ordercol input{ }
|
206 |
+
|
207 |
+
table#form_field_table tr th{ padding-left: 0px; padding-right: 0px; }
|
208 |
+
|
209 |
+
.flag_email{
|
210 |
+
width:16px;
|
211 |
+
float:right;
|
212 |
+
}
|
213 |
+
|
214 |
+
#wpsc_settingpage_nav_spacer{
|
215 |
+
width:35%;
|
216 |
+
float:right;
|
217 |
+
height:30px;
|
218 |
+
border-bottom:1px solid #dfdfdf;
|
219 |
+
}
|
220 |
+
|
221 |
+
#wpsc_settings_nav_bar {
|
222 |
+
width:100%;
|
223 |
+
}
|
224 |
+
|
225 |
+
#wpsc_settings_nav_bar ul {
|
226 |
+
width: 98%;
|
227 |
+
border-bottom: 1px solid #DFDFDF;
|
228 |
+
float: left;
|
229 |
+
margin: 10px auto 0;
|
230 |
+
padding-left: 15px;
|
231 |
+
}
|
232 |
+
#wpsc_settings_nav_bar ul li a{
|
233 |
+
margin-bottom:-1px;
|
234 |
+
}
|
235 |
+
|
236 |
+
#wpsc_settings_nav_bar ul li a.current {
|
237 |
+
background-color: #f9f9f9 !important;
|
238 |
+
border-bottom-color: transparent !important;
|
239 |
+
}
|
240 |
+
|
241 |
+
h3.form_group {
|
242 |
+
clear: left;
|
243 |
+
}
|
244 |
+
h3.form_group a{
|
245 |
+
color: #000;
|
246 |
+
}
|
247 |
+
div.product_and_button_settings {
|
248 |
+
position: relative;
|
249 |
+
}
|
250 |
+
|
251 |
+
div#themes_and_appearance {
|
252 |
+
border: 1px solid #DFDFDF;
|
253 |
+
width: 360px;
|
254 |
+
position: absolute;
|
255 |
+
left: 45em;
|
256 |
+
}
|
257 |
+
|
258 |
+
div#themes_and_appearance p {
|
259 |
+
font-size: 11px;
|
260 |
+
}
|
261 |
+
|
262 |
+
span.display-path {
|
263 |
+
color:#666666;
|
264 |
+
}
|
265 |
+
|
266 |
+
div#themes_and_appearance ol {
|
267 |
+
font-size: 11px;
|
268 |
+
list-style-type:decimal;
|
269 |
+
list-style-position:inside;
|
270 |
+
}
|
271 |
+
|
272 |
+
div#themes_and_appearance ol li {
|
273 |
+
font-size: 11px;
|
274 |
+
}
|
275 |
+
|
276 |
+
a.nav-tab-loading {
|
277 |
+
color:#D54E21;
|
278 |
+
}
|
279 |
+
|
280 |
+
#wpsc_options h2 .nav-tab {
|
281 |
+
font-size:16px;
|
282 |
+
line-height:20px;
|
283 |
+
padding:3px 6px 3px;
|
284 |
+
margin-right:0;
|
285 |
+
}
|
286 |
+
|
287 |
+
#wpsc_options h2.nav-tab-wrapper {
|
288 |
+
padding-left:7px;
|
289 |
+
}
|
290 |
+
|
291 |
+
#wpsc_options .postbox .inside p.submit {
|
292 |
+
margin-top:5px;
|
293 |
+
padding:0;
|
294 |
+
}
|
295 |
+
|
296 |
+
#wpsc-shipping-module-settings td small {
|
297 |
+
color:#666;
|
298 |
+
font-style:italic;
|
299 |
+
}
|
300 |
+
|
301 |
+
.wpsc-shipping-module-settings-tablerate .postbox .inside, .wpsc-shipping-module-settings-weightrate .postbox .inside {
|
302 |
+
padding: 0;
|
303 |
+
}
|
304 |
+
|
305 |
+
.wpsc-shipping-module-settings-tablerate .form-table th, .wpsc-shipping-module-settings-weightrate .form-table th {
|
306 |
+
border-bottom:1px solid #dfdfdf;
|
307 |
+
font-size:12px;
|
308 |
+
font-weight:bold;
|
309 |
+
padding:7px 10px 7px 20px;
|
310 |
+
}
|
311 |
+
|
312 |
+
.wpsc-shipping-module-settings-tablerate .form-table, .wpsc-shipping-module-settings-weightrate .form-table {
|
313 |
+
margin-top:0;
|
314 |
+
}
|
315 |
+
|
316 |
+
.wpsc-shipping-module-settings-tablerate .total {
|
317 |
+
width:120px;
|
318 |
+
}
|
319 |
+
|
320 |
+
.wpsc-shipping-module-settings-weightrate .form-table th.total-weight {
|
321 |
+
padding-left:10px;
|
322 |
+
width:140px;
|
323 |
+
}
|
324 |
+
|
325 |
+
.wpsc-shipping-module-settings-tablerate .form-table td, .wpsc-shipping-module-settings-weightrate .form-table td {
|
326 |
+
border-bottom:1px solid #dfdfdf;
|
327 |
+
padding:0 10px;
|
328 |
+
}
|
329 |
+
|
330 |
+
.wpsc-shipping-module-settings-tablerate .form-table td .cell-wrapper, .wpsc-shipping-module-settings-weightrate .form-table td .cell-wrapper {
|
331 |
+
padding:7px 0;
|
332 |
+
width:100%;
|
333 |
+
}
|
334 |
+
|
335 |
+
#wpsc_options .wpsc-shipping-module-settings-tablerate .postbox .inside .submit, #wpsc_options .wpsc-shipping-module-settings-weightrate .postbox .inside .submit {
|
336 |
+
padding:0 10px 0 20px;
|
337 |
+
}
|
338 |
+
|
339 |
+
.wpsc-shipping-module-settings-tablerate td .actions, .wpsc-shipping-module-settings-weightrate td .actions {
|
340 |
+
float:right;
|
341 |
+
margin-right:10px;
|
342 |
+
}
|
343 |
+
|
344 |
+
#wpsc_options .action {
|
345 |
+
display:none;
|
346 |
+
}
|
347 |
+
|
348 |
+
.js #wpsc_options .js-warning {
|
349 |
+
display:none;
|
350 |
+
}
|
351 |
+
|
352 |
+
.js #wpsc_options .wpsc-shipping-module-settings-tablerate td .action,
|
353 |
+
.js #wpsc_options .wpsc-shipping-module-settings-weightrate td .action,
|
354 |
+
.js #wpsc_checkout_list .action {
|
355 |
+
background-image:url(plus-minus.png);
|
356 |
+
background-repeat:no-repeat;
|
357 |
+
display:inline-block;
|
358 |
+
height:20px;
|
359 |
+
margin-left:3px;
|
360 |
+
text-indent:-9999em;
|
361 |
+
width:20px;
|
362 |
+
}
|
363 |
+
|
364 |
+
.js #wpsc_options .wpsc-shipping-module-settings-tablerate td span.action,
|
365 |
+
.js #wpsc_options .wpsc-shipping-module-settings-weightrate td span.action,
|
366 |
+
.js #wpsc_checkout_list span.action {
|
367 |
+
opacity:0.3;
|
368 |
+
}
|
369 |
+
|
370 |
+
#wpsc_checkout_list .wpsc-field-options-table {
|
371 |
+
border-collapse:collapse;
|
372 |
+
margin-bottom:1em;
|
373 |
+
width:100%;
|
374 |
+
}
|
375 |
+
|
376 |
+
#wpsc_checkout_list .wpsc-field-options-table th {
|
377 |
+
background:none;
|
378 |
+
border-top:none;
|
379 |
+
color:#000;
|
380 |
+
font-family:sans-serif;
|
381 |
+
font-size:12px;
|
382 |
+
font-weight:bold;
|
383 |
+
padding:0 5px;
|
384 |
+
}
|
385 |
+
|
386 |
+
#wpsc_checkout_list .wpsc-field-options-table input {
|
387 |
+
width:100%;
|
388 |
+
}
|
389 |
+
|
390 |
+
#wpsc_checkout_list .wpsc-field-options-table td {
|
391 |
+
border:none;
|
392 |
+
padding:0 5px;
|
393 |
+
}
|
394 |
+
|
395 |
+
.js #wpsc_checkout_list .edit-options {
|
396 |
+
display: none;
|
397 |
+
}
|
398 |
+
|
399 |
+
.js .form-field-options {
|
400 |
+
display:none;
|
401 |
+
}
|
402 |
+
|
403 |
+
#wpsc_checkout_list .form-field-options td {
|
404 |
+
border-top:none;
|
405 |
+
}
|
406 |
+
|
407 |
+
#wpsc_checkout_list tr.editing-options td {
|
408 |
+
border-bottom:none;
|
409 |
+
}
|
410 |
+
|
411 |
+
#wpsc_checkout_list .wpsc-field-options-table td .field-option-cell-wrapper {
|
412 |
+
padding: 2px 0;
|
413 |
+
}
|
414 |
+
|
415 |
+
#wpsc_checkout_list .wpsc-field-options-table .column-actions {
|
416 |
+
width:65px;
|
417 |
+
}
|
418 |
+
|
419 |
+
#wpsc_checkout_list .wpsc-field-options-table .column-actions .field-option-cell-wrapper {
|
420 |
+
float:right;
|
421 |
+
}
|
422 |
+
|
423 |
+
.js #wpsc_checkout_list .new-field {
|
424 |
+
display:none;
|
425 |
+
}
|
426 |
+
|
427 |
+
/* shipping options start here */
|
428 |
+
div.wpsc_shipping_options, div.wpsc-select-gateway {
|
429 |
+
border-top: 1px solid #e9e9e9;
|
430 |
+
width:100%;
|
431 |
+
padding:3px 0;
|
432 |
+
}
|
433 |
+
.wpsc-shipping-actions, .wpsc-gateway-actions {
|
434 |
+
visibility:hidden;
|
435 |
+
line-height: 16px;
|
436 |
+
margin:0px 9em 0 0;
|
437 |
+
float:right;
|
438 |
+
}
|
439 |
+
div.wpsc_shipping_options:hover .wpsc-shipping-actions,
|
440 |
+
div.wpsc-select-gateway:hover .wpsc-gateway-actions {
|
441 |
+
visibility:visible;
|
442 |
+
}
|
443 |
+
div.wpsc-select-gateway p, div.wpsc_shipping_options p {
|
444 |
+
margin: 0px 15px 4px 5px;
|
445 |
+
}
|
446 |
+
#wpsc-payment-gateway-settings-panel input[type=text], #wpsc-payment-gateway-settings-panel textarea {
|
447 |
+
width:265px;
|
448 |
+
}
|
449 |
+
table.form-table td .updated.shipwire-update {
|
450 |
+
display : none;
|
451 |
+
font-size : 12px;
|
452 |
+
line-height : 1.6em;
|
453 |
+
}
|
454 |
+
|
455 |
+
/* tax */
|
456 |
+
.wpsc-tax-bands-row, .wpsc-tax-rates-row {
|
457 |
+
line-height: 3.2;
|
458 |
+
}
|
459 |
+
|
460 |
+
.wpsc-tax-bands-row.prototype,
|
461 |
+
.wpsc-tax-rates-row.prototype {
|
462 |
+
display: none;
|
463 |
+
}
|
464 |
+
|
465 |
+
#wpsc-amazon-payments-secret-key {
|
466 |
+
width: 400px;
|
467 |
+
}
|
468 |
+
|
469 |
+
#wpsc-amazon-payments-client_id,
|
470 |
+
#wpsc-amazon-payments-ipn {
|
471 |
+
width: 500px;
|
472 |
+
}
|
trunk/wpsc-admin/css/ui-images/ui-icons_21759b_256x240.png
ADDED
Binary file
|
trunk/wpsc-admin/css/ui-images/ui-icons_333333_256x240.png
ADDED
Binary file
|
trunk/wpsc-admin/css/ui-images/ui-icons_999999_256x240.png
ADDED
Binary file
|
trunk/wpsc-admin/css/ui-images/ui-icons_cc0000_256x240.png
ADDED
Binary file
|
trunk/wpsc-admin/css/xit.gif
ADDED
Binary file
|
trunk/wpsc-admin/db-upgrades/routines/1.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_1() {
|
4 |
+
_wpsc_fix_checkout_field_limitation();
|
5 |
+
_wpsc_fix_mexico_currency_sign();
|
6 |
+
_wpsc_fix_canadian_province_codes();
|
7 |
+
_wpsc_fix_colombia_currency();
|
8 |
+
_wpsc_fix_ukraine_currency();
|
9 |
+
_wpsc_fix_russia_currency();
|
10 |
+
_wpsc_fix_belarus_currency();
|
11 |
+
_wpsc_fix_estonia_currency();
|
12 |
+
_wpsc_fix_slovenia_currency();
|
13 |
+
_wpsc_fix_sudan_currency();
|
14 |
+
_wpsc_create_south_sudan();
|
15 |
+
wpsc_update_permalink_slugs();
|
16 |
+
}
|
17 |
+
|
18 |
+
function _wpsc_fix_checkout_field_limitation() {
|
19 |
+
global $wpdb;
|
20 |
+
$wpdb->query( "ALTER TABLE " . WPSC_TABLE_CHECKOUT_FORMS . " MODIFY options longtext" );
|
21 |
+
}
|
22 |
+
|
23 |
+
function _wpsc_fix_mexico_currency_sign() {
|
24 |
+
$country = new WPSC_Country( array(
|
25 |
+
'isocode' => 'MX',
|
26 |
+
'currency' => __( 'Mexican Peso', 'wp-e-commerce' ),
|
27 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
28 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
29 |
+
'has_regions' => '1'
|
30 |
+
) );
|
31 |
+
}
|
32 |
+
|
33 |
+
function _wpsc_fix_canadian_province_codes() {
|
34 |
+
global $wpdb;
|
35 |
+
|
36 |
+
$correct_provinces = array(
|
37 |
+
'AB' => 'Alberta',
|
38 |
+
'BC' => 'British Columbia',
|
39 |
+
'MB' => 'Manitoba',
|
40 |
+
'NB' => 'New Brunswick',
|
41 |
+
'NT' => 'Northwest Territories',
|
42 |
+
'NS' => 'Nova Scotia',
|
43 |
+
'NU' => 'Nunavut',
|
44 |
+
'ON' => 'Ontario',
|
45 |
+
'PE' => 'Prince Edward Island',
|
46 |
+
'QC' => 'Quebec',
|
47 |
+
'SK' => 'Saskatchewan',
|
48 |
+
'YT' => 'Yukon',
|
49 |
+
);
|
50 |
+
|
51 |
+
foreach( $correct_provinces as $code => $name ) {
|
52 |
+
$wpdb->update( WPSC_TABLE_REGION_TAX,
|
53 |
+
array(
|
54 |
+
'code' => $code
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'name' => $name
|
58 |
+
)
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
$wpdb->update( WPSC_TABLE_REGION_TAX,
|
63 |
+
array(
|
64 |
+
'code' => 'NL',
|
65 |
+
'name' => 'Newfoundland and Labrador',
|
66 |
+
),
|
67 |
+
array(
|
68 |
+
'name' => 'Newfoundland',
|
69 |
+
)
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
function _wpsc_fix_colombia_currency() {
|
74 |
+
$country = new WPSC_Country( array(
|
75 |
+
'isocode' => 'CO',
|
76 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
77 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
78 |
+
) );
|
79 |
+
}
|
80 |
+
|
81 |
+
function _wpsc_fix_ukraine_currency() {
|
82 |
+
$country = new WPSC_Country( array(
|
83 |
+
'isocode' => 'UA',
|
84 |
+
'code' => __( 'UAH', 'wp-e-commerce' ),
|
85 |
+
'symbol' => __( '₴', 'wp-e-commerce' ),
|
86 |
+
'symbol_html' => __( '₴', 'wp-e-commerce' ),
|
87 |
+
) );
|
88 |
+
}
|
89 |
+
|
90 |
+
function _wpsc_fix_russia_currency() {
|
91 |
+
$country = new WPSC_Country( array(
|
92 |
+
'isocode' => 'RU',
|
93 |
+
'code' => __( 'RUB', 'wp-e-commerce' )
|
94 |
+
) );
|
95 |
+
}
|
96 |
+
|
97 |
+
function _wpsc_fix_belarus_currency() {
|
98 |
+
$country = new WPSC_Country( array(
|
99 |
+
'isocode' => 'BY',
|
100 |
+
'code' => __( 'BYR', 'wp-e-commerce' )
|
101 |
+
) );
|
102 |
+
}
|
103 |
+
|
104 |
+
function _wpsc_fix_estonia_currency() {
|
105 |
+
$country = new WPSC_Country( array(
|
106 |
+
'isocode' => 'EE',
|
107 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
108 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
109 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
110 |
+
'code' => __( 'EUR', 'wp-e-commerce' )
|
111 |
+
) );
|
112 |
+
}
|
113 |
+
|
114 |
+
function _wpsc_fix_slovenia_currency() {
|
115 |
+
$country = new WPSC_Country( array(
|
116 |
+
'isocode' => 'SI',
|
117 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
118 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
119 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
120 |
+
'code' => __( 'EUR', 'wp-e-commerce' )
|
121 |
+
) );
|
122 |
+
}
|
123 |
+
|
124 |
+
function _wpsc_fix_sudan_currency() {
|
125 |
+
$country = new WPSC_Country( array(
|
126 |
+
'isocode' => 'SD',
|
127 |
+
'currency' => __( 'Sudanese Pound', 'wp-e-commerce' ),
|
128 |
+
'code' => __( 'SDG', 'wp-e-commerce' )
|
129 |
+
) );
|
130 |
+
}
|
131 |
+
|
132 |
+
function _wpsc_create_south_sudan() {
|
133 |
+
$country = new WPSC_Country( array(
|
134 |
+
'id' => '242',
|
135 |
+
'country' => __( 'South Sudan', 'wp-e-commerce' ),
|
136 |
+
'isocode' => __( 'SS', 'wp-e-commerce' ),
|
137 |
+
'currency' => __( 'South Sudanese Pound', 'wp-e-commerce' ),
|
138 |
+
'code' => __( 'SSP', 'wp-e-commerce' ),
|
139 |
+
'continent' => 'africa',
|
140 |
+
'visible' => 0,
|
141 |
+
) );
|
142 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/10.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Control database upgrade to version 10
|
5 |
+
*
|
6 |
+
* @access private
|
7 |
+
* @since 3.8.14
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
function _wpsc_db_upgrade_10() {
|
11 |
+
_wpsc_add_region_name_meta();
|
12 |
+
_wpsc_maybe_create_visitor_tables();
|
13 |
+
_wpsc_cleanup_visitor_meta_checkout_details();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* 3.8.14 supports country meta and a feature that let's a countries regions be called by the
|
18 |
+
* proper name. Here we initialize the values.
|
19 |
+
*
|
20 |
+
* @access private
|
21 |
+
* @since 3.8.14
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
function _wpsc_add_region_name_meta() {
|
25 |
+
$wpsc_country = new WPSC_Country( 'US' );
|
26 |
+
$wpsc_country->set( 'region_label', __( 'State', 'wp-e-commerce' ) );
|
27 |
+
|
28 |
+
$wpsc_country = new WPSC_Country( 'CA' );
|
29 |
+
$wpsc_country->set( 'region_label', __( 'Province', 'wp-e-commerce' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* 3.8.14 maintains visitor information in a visitors table, create it
|
34 |
+
*
|
35 |
+
* @access private
|
36 |
+
* @since 3.8.14
|
37 |
+
*
|
38 |
+
*/
|
39 |
+
function _wpsc_maybe_create_visitor_tables() {
|
40 |
+
_wpsc_create_visitor_table();
|
41 |
+
_wpsc_create_visitor_meta_table();
|
42 |
+
_wpsc_meta_migrate_anonymous_users();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* starting in 3.8.14 visitors information belongs in the vistor table, not the users table, start
|
47 |
+
* the migration. This migration could take a very long time so it's done as a cron
|
48 |
+
*
|
49 |
+
* @access private
|
50 |
+
* @since 3.8.14
|
51 |
+
*
|
52 |
+
*/
|
53 |
+
function _wpsc_meta_migrate_anonymous_users() {
|
54 |
+
global $wpdb;
|
55 |
+
|
56 |
+
// get the users table auto increment value, and set the visitor meta auto increment to match.
|
57 |
+
// we do this so that new customer cookies don't collide with existing customer cookies after
|
58 |
+
// the migration. Note we can't use max of user id because users may have been deleted.
|
59 |
+
$sql = 'SHOW TABLE STATUS WHERE NAME = "' . $wpdb->users . '"';
|
60 |
+
$status = $wpdb->get_results( $sql );
|
61 |
+
|
62 |
+
$wpdb->query( 'ALTER TABLE ' . $wpdb->wpsc_visitors . ' AUTO_INCREMENT = ' . $status[0]->Auto_increment );
|
63 |
+
|
64 |
+
wp_suspend_cache_addition( true );
|
65 |
+
|
66 |
+
$role = get_role( 'wpsc_anonymous' );
|
67 |
+
|
68 |
+
if ( $role ) {
|
69 |
+
remove_role( 'wpsc_anonymous', __( 'Anonymous', 'wp-e-commerce' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
wp_schedule_single_event( time() + 5 , 'wpsc_migrate_anonymous_user_cron' );
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Create the table for visitors
|
79 |
+
*
|
80 |
+
* @since 3.8.14
|
81 |
+
* @access private
|
82 |
+
*
|
83 |
+
*/
|
84 |
+
function _wpsc_create_visitor_table() {
|
85 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
86 |
+
global $wpdb;
|
87 |
+
global $charset_collate;
|
88 |
+
|
89 |
+
$sql = 'CREATE TABLE IF NOT EXISTS '. $wpdb->wpsc_visitors .' ('
|
90 |
+
.'id bigint(20) unsigned NOT NULL AUTO_INCREMENT, '
|
91 |
+
.'user_id bigint(20) unsigned DEFAULT NULL , '
|
92 |
+
.'last_active timestamp NULL DEFAULT NULL, '
|
93 |
+
.'expires timestamp NULL DEFAULT NULL, '
|
94 |
+
.'created timestamp NULL DEFAULT NULL, '
|
95 |
+
.'PRIMARY KEY ( `id` ), '
|
96 |
+
.'KEY user_id ( `user_id` ), '
|
97 |
+
.'KEY expires ( `expires` ), '
|
98 |
+
.'KEY last_active ( `last_active` ), '
|
99 |
+
.'KEY created ( `created` ) '
|
100 |
+
.') '. $charset_collate;
|
101 |
+
|
102 |
+
dbDelta( $sql );
|
103 |
+
|
104 |
+
_wpsc_create_well_known_visitors();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Create the meta table for visitor meta
|
109 |
+
*
|
110 |
+
* @since 3.8.14
|
111 |
+
* @access private
|
112 |
+
*
|
113 |
+
*/
|
114 |
+
function _wpsc_create_visitor_meta_table() {
|
115 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
116 |
+
global $wpdb;
|
117 |
+
global $charset_collate;
|
118 |
+
|
119 |
+
$sql = 'CREATE TABLE IF NOT EXISTS '. $wpdb->wpsc_visitormeta .' ('
|
120 |
+
.'meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, '
|
121 |
+
.'wpsc_visitor_id bigint(20) unsigned NOT NULL DEFAULT 0 , '
|
122 |
+
.'meta_key varchar(255) DEFAULT NULL, '
|
123 |
+
.'meta_value longtext, '
|
124 |
+
.'meta_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, '
|
125 |
+
.'PRIMARY KEY (meta_id), '
|
126 |
+
.'KEY wpsc_visitor_id (wpsc_visitor_id), '
|
127 |
+
.'KEY meta_key (meta_key(191)), '
|
128 |
+
.'KEY meta_value (meta_value(20)), '
|
129 |
+
.'KEY meta_key_and_value (meta_key(191),meta_value(32)), '
|
130 |
+
.'KEY meta_timestamp_index ( `meta_timestamp` ) '
|
131 |
+
.') '. $charset_collate;
|
132 |
+
|
133 |
+
dbDelta( $sql );
|
134 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/11.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Control database upgrade to version 11
|
4 |
+
*
|
5 |
+
* @access private
|
6 |
+
* @since 3.8.14
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
function _wpsc_db_upgrade_11() {
|
10 |
+
_wpsc_fix_united_kingdom();
|
11 |
+
_wpsc_set_legacy_country_meta();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Reset United Kingdom country data to default, hide ISO code 'UK'
|
16 |
+
*
|
17 |
+
* @access private
|
18 |
+
* @since 3.8.14
|
19 |
+
*/
|
20 |
+
function _wpsc_fix_united_kingdom() {
|
21 |
+
|
22 |
+
$legacy_ok_country_was_visible = true;
|
23 |
+
|
24 |
+
if ( $wpsc_country = WPSC_Countries::get_country( 'UK' ) ) {
|
25 |
+
|
26 |
+
$legacy_ok_country_was_visible = $wpsc_country->is_visible();
|
27 |
+
|
28 |
+
$wpsc_country = new WPSC_Country(
|
29 |
+
array(
|
30 |
+
'visible' => '0',
|
31 |
+
'isocode' => 'UK',
|
32 |
+
)
|
33 |
+
);
|
34 |
+
|
35 |
+
$wpsc_country->set( '_is_country_legacy', true );
|
36 |
+
}
|
37 |
+
|
38 |
+
$wpsc_country = new WPSC_Country(
|
39 |
+
array(
|
40 |
+
'country' => __( 'United Kingdom', 'wp-e-commerce' ),
|
41 |
+
'isocode' => 'GB',
|
42 |
+
'currency' => __( 'Pound Sterling', 'wp-e-commerce' ),
|
43 |
+
'symbol' => __( '£', 'wp-e-commerce' ),
|
44 |
+
'symbol_html' => __( '£', 'wp-e-commerce' ),
|
45 |
+
'code' => __( 'GBP', 'wp-e-commerce' ),
|
46 |
+
'continent' => 'europe',
|
47 |
+
'visible' => $legacy_ok_country_was_visible ? '0' : '1',
|
48 |
+
'has_regions' => '0',
|
49 |
+
'tax' => '0',
|
50 |
+
)
|
51 |
+
);
|
52 |
+
|
53 |
+
//make sure base country is ok after the UK/GB fix
|
54 |
+
$base_country = get_option( 'base_country', '' );
|
55 |
+
if ( ! empty( $base_country ) && is_numeric( $base_country ) ) {
|
56 |
+
$wpsc_country = new WPSC_Country( $base_country );
|
57 |
+
if ( 'UK' == $wpsc_country->get_isocode() ) {
|
58 |
+
$wpsc_country = new WPSC_Country( 'GB' );
|
59 |
+
update_option( 'base_country' , $wpsc_country->get_id() );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Sets meta for countries that no longer exist in their former notation to be considered legacy.
|
67 |
+
*
|
68 |
+
* @access private
|
69 |
+
* @since 3.8.14
|
70 |
+
*/
|
71 |
+
function _wpsc_set_legacy_country_meta() {
|
72 |
+
if ( $wpsc_country = WPSC_Countries::get_country( 'YU' ) ) {
|
73 |
+
$wpsc_country->set( '_is_country_legacy', true );
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( $wpsc_country = WPSC_Countries::get_country( 'AN' ) ) {
|
77 |
+
$wpsc_country->set( '_is_country_legacy', true );
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( $wpsc_country = WPSC_Countries::get_country( 'TP' ) ) {
|
81 |
+
$wpsc_country->set( '_is_country_legacy', true );
|
82 |
+
}
|
83 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/12.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Control database upgrade to version 12
|
4 |
+
*
|
5 |
+
* @access private
|
6 |
+
* @since 3.8.14
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
function _wpsc_db_upgrade_12() {
|
10 |
+
_wpsc_fix_billing_country_meta();
|
11 |
+
_wpsc_fix_shipping_country_meta();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* make sure the billing country meta is stored as individual values not as an array
|
16 |
+
*
|
17 |
+
* @access private
|
18 |
+
* @since 3.8.14
|
19 |
+
*/
|
20 |
+
function _wpsc_fix_billing_country_meta() {
|
21 |
+
global $wpdb;
|
22 |
+
|
23 |
+
$sql = 'SELECT * from ' . $wpdb->wpsc_visitormeta . ' WHERE meta_key = "billingcountry"';
|
24 |
+
$metas = $wpdb->get_results( $sql, OBJECT );
|
25 |
+
|
26 |
+
foreach ( $metas as $meta ) {
|
27 |
+
$meta_value = maybe_unserialize( $meta->meta_value );
|
28 |
+
if ( is_array( $meta_value ) ) {
|
29 |
+
wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'billingregion', $meta_value[1] );
|
30 |
+
wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'billingcountry', $meta_value[0] );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* make sure the shipping country meta is stored as individual values not as an array
|
37 |
+
*
|
38 |
+
* @access private
|
39 |
+
* @since 3.8.14
|
40 |
+
*/
|
41 |
+
function _wpsc_fix_shipping_country_meta() {
|
42 |
+
global $wpdb;
|
43 |
+
|
44 |
+
$sql = 'SELECT * from ' . $wpdb->wpsc_visitormeta . ' WHERE meta_key = "shippingcountry"';
|
45 |
+
$metas = $wpdb->get_results( $sql, OBJECT );
|
46 |
+
|
47 |
+
foreach ( $metas as $meta ) {
|
48 |
+
$meta_value = maybe_unserialize( $meta->meta_value );
|
49 |
+
if ( is_array( $meta_value ) ) {
|
50 |
+
wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'shippingregion', $meta_value[1] );
|
51 |
+
wpsc_update_visitor_meta( $meta->wpsc_visitor_id, 'shippingcountry', $meta_value[0] );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
trunk/wpsc-admin/db-upgrades/routines/13.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Control database upgrade to version 13
|
4 |
+
*
|
5 |
+
* @access private
|
6 |
+
* @since 3.8.14
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
function _wpsc_db_upgrade_13() {
|
10 |
+
_wpsc_add_region_label_to_uk();
|
11 |
+
_wpsc_fix_bad_checkout_form_rows();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Add the county region label to the uk
|
16 |
+
*
|
17 |
+
* @access private
|
18 |
+
* @since 3.8.14.1
|
19 |
+
*/
|
20 |
+
function _wpsc_add_region_label_to_uk() {
|
21 |
+
$wpsc_country = new WPSC_Country( 'GB' );
|
22 |
+
$wpsc_country->set( 'region_label', __( 'County', 'wp-e-commerce' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
function _wpsc_fix_bad_checkout_form_rows() {
|
26 |
+
global $wpdb;
|
27 |
+
|
28 |
+
$rows = $wpdb->get_results( 'SELECT * from '. WPSC_TABLE_CHECKOUT_FORMS . ' WHERE `unique_name` = ""' );
|
29 |
+
|
30 |
+
foreach ( $rows as $index => $row ) {
|
31 |
+
// look for the unique name to be sure it doesn't already-exist, if it does, make it unique
|
32 |
+
$new_unique_name = sanitize_title( $row->name );
|
33 |
+
|
34 |
+
$count = $wpdb->get_var( 'SELECT count(*) FROM ' . WPSC_TABLE_CHECKOUT_FORMS . ' WHERE `unique_name` = "' . $new_unique_name .'"' );
|
35 |
+
$count = intval( $count );
|
36 |
+
if ( $count ) {
|
37 |
+
$new_unique_name = sanitize_title( $row->name ) . '-' . ( $count + 1 );
|
38 |
+
}
|
39 |
+
|
40 |
+
$result = $wpdb->query(
|
41 |
+
'UPDATE ' . WPSC_TABLE_CHECKOUT_FORMS
|
42 |
+
. ' SET `unique_name` = "' . $new_unique_name
|
43 |
+
. '" WHERE id=' . $row->id
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
$index = $wpdb->get_results( 'SHOW INDEX FROM `' . WPSC_TABLE_CHECKOUT_FORMS . '` WHERE KEY_NAME = "unique_name"' );
|
49 |
+
|
50 |
+
if ( ! count( $index ) ) {
|
51 |
+
// Add the new index
|
52 |
+
$wpdb->query( 'ALTER TABLE `' . WPSC_TABLE_CHECKOUT_FORMS . '` ADD INDEX ( `unique_name` )' );
|
53 |
+
}
|
54 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/14.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Control database upgrade to version 14
|
4 |
+
*
|
5 |
+
* @access private
|
6 |
+
* @since 3.9.0
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
function _wpsc_db_upgrade_14() {
|
10 |
+
_wpsc_fix_latvia_currency();
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Change Latvian currency to Euro.
|
15 |
+
*
|
16 |
+
* @access private
|
17 |
+
* @since 3.9.0
|
18 |
+
*/
|
19 |
+
function _wpsc_fix_latvia_currency() {
|
20 |
+
$country = new WPSC_Country( array(
|
21 |
+
'isocode' => 'LV',
|
22 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
23 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
24 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
25 |
+
'code' => __( 'EUR', 'wp-e-commerce' )
|
26 |
+
) );
|
27 |
+
|
28 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/2.php
ADDED
@@ -0,0 +1,430 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_2() {
|
4 |
+
_wpsc_fix_UK_country_code();
|
5 |
+
_wpsc_fix_guernsey_country_code();
|
6 |
+
_wpsc_new_country_serbia();
|
7 |
+
_wpsc_new_country_montenegro();
|
8 |
+
_wpsc_fix_timor_leste_name();
|
9 |
+
_wpsc_new_country_aland_islands();
|
10 |
+
_wpsc_new_country_saint_barthelemy();
|
11 |
+
_wpsc_new_country_bonaire_et_al();
|
12 |
+
_wpsc_new_country_curacao();
|
13 |
+
_wpsc_new_country_saint_martin_french();
|
14 |
+
_wpsc_new_country_palestinian_territories();
|
15 |
+
_wpsc_update_israeli_new_shekel_symbol();
|
16 |
+
_wpsc_new_country_sint_maarten_dutch();
|
17 |
+
_wpsc_new_country_french_guiana();
|
18 |
+
_wpsc_fix_netherlands_antille();
|
19 |
+
_wpsc_fix_angola_kwanza();
|
20 |
+
_wpsc_fix_aruban_florin();
|
21 |
+
_wpsc_fix_azerbaijani_manat();
|
22 |
+
_wpsc_fix_cyprus_currency();
|
23 |
+
_wpsc_fix_republic_of_the_congo();
|
24 |
+
_wpsc_fix_currency_el_salvador();
|
25 |
+
_wpsc_fix_ghanaian_currency_code();
|
26 |
+
_wpsc_fix_guatemala_currency();
|
27 |
+
_wpsc_fix_guinea_bissau_currency();
|
28 |
+
_wpsc_fix_madagascar_currency();
|
29 |
+
_wpsc_fix_malta_currency();
|
30 |
+
_wpsc_fix_mozambique_currency();
|
31 |
+
_wpsc_fix_nicaragua_currency();
|
32 |
+
_wpsc_fix_romania_currency();
|
33 |
+
_wpsc_fix_san_marino_currency();
|
34 |
+
_wpsc_fix_somalia_currency();
|
35 |
+
_wpsc_fix_suriname_currency();
|
36 |
+
_wpsc_fix_taiwan_currency();
|
37 |
+
_wpsc_fix_tajikistan_currency();
|
38 |
+
_wpsc_fix_tunisia_currency();
|
39 |
+
_wpsc_fix_uganda_currency();
|
40 |
+
_wpsc_fix_turkey_currency();
|
41 |
+
_wpsc_fix_uruguay_currency();
|
42 |
+
_wpsc_fix_venezuela_currency();
|
43 |
+
_wpsc_fix_zimbabwe_currency();
|
44 |
+
}
|
45 |
+
|
46 |
+
function _wpsc_fix_UK_country_code() {
|
47 |
+
$country = new WPSC_Country( array(
|
48 |
+
'isocode' => 'GB',
|
49 |
+
'country', __( 'United Kingdom', 'wp-e-commerce' )
|
50 |
+
) );
|
51 |
+
}
|
52 |
+
|
53 |
+
function _wpsc_fix_guernsey_country_code() {
|
54 |
+
$existing_wpsc_country = new WPSC_Country( 'GF' );
|
55 |
+
// replace the ISO country code in the existing country
|
56 |
+
$updated_wpsc_country = new WPSC_Country( array( 'id' => $existing_wpsc_country->get_id(), 'isocode' => 'GG', ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
function _wpsc_new_country_serbia() {
|
60 |
+
$country = new WPSC_Country( array(
|
61 |
+
'id' => 243,
|
62 |
+
'country' => __( 'Serbia', 'wp-e-commerce' ),
|
63 |
+
'isocode' => 'RS',
|
64 |
+
'currency' => __('Serbian Dinar', 'wp-e-commerce'),
|
65 |
+
'code' => __('RSD', 'wp-e-commerce'),
|
66 |
+
'continent' => 'europe',
|
67 |
+
'visible' => '0',
|
68 |
+
) );
|
69 |
+
}
|
70 |
+
|
71 |
+
function _wpsc_new_country_montenegro() {
|
72 |
+
$country = new WPSC_Country( array(
|
73 |
+
'id' => 244,
|
74 |
+
'country' => __( 'Montenegro', 'wp-e-commerce' ),
|
75 |
+
'isocode' => 'ME',
|
76 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
77 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
78 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
79 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
80 |
+
'continent' => 'europe',
|
81 |
+
'visible' => '0',
|
82 |
+
) );
|
83 |
+
}
|
84 |
+
|
85 |
+
function _wpsc_fix_timor_leste_name() {
|
86 |
+
$country = new WPSC_Country( array(
|
87 |
+
'id' => 245,
|
88 |
+
'country' => __( 'Timor-Leste', 'wp-e-commerce' ),
|
89 |
+
'isocode' => 'TL',
|
90 |
+
'currency' => __( 'US Dollar', 'wp-e-commerce' ),
|
91 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
92 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
93 |
+
'code' => 'USD',
|
94 |
+
'continent' => 'asiapacific',
|
95 |
+
'visible' => '0',
|
96 |
+
) );
|
97 |
+
}
|
98 |
+
|
99 |
+
function _wpsc_new_country_aland_islands() {
|
100 |
+
$country = new WPSC_Country( array(
|
101 |
+
'id' => 246,
|
102 |
+
'country' => __( 'Aland Islands', 'wp-e-commerce' ),
|
103 |
+
'isocode' => 'AX',
|
104 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
105 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
106 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
107 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
108 |
+
'continent' => 'europe',
|
109 |
+
'visible' => '0',
|
110 |
+
) );
|
111 |
+
}
|
112 |
+
|
113 |
+
function _wpsc_new_country_saint_barthelemy() {
|
114 |
+
$country = new WPSC_Country( array(
|
115 |
+
'id' => 247,
|
116 |
+
'country' => __( 'Saint Barthelemy', 'wp-e-commerce' ),
|
117 |
+
'isocode' => 'BL',
|
118 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
119 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
120 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
121 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
122 |
+
'continent' => 'europe',
|
123 |
+
'visible' => '0',
|
124 |
+
) );
|
125 |
+
}
|
126 |
+
|
127 |
+
function _wpsc_new_country_bonaire_et_al() {
|
128 |
+
$country = new WPSC_Country( array(
|
129 |
+
'id' => 248,
|
130 |
+
'country' => __( 'Bonaire, Sint Eustatius and Saba', 'wp-e-commerce' ),
|
131 |
+
'isocode' => 'BQ',
|
132 |
+
'currency' => __( 'US Dollar', 'wp-e-commerce' ),
|
133 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
134 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
135 |
+
'code' => __( 'USD', 'wp-e-commerce' ),
|
136 |
+
'continent' => 'southamerica',
|
137 |
+
'visible' => '0',
|
138 |
+
) );
|
139 |
+
}
|
140 |
+
|
141 |
+
function _wpsc_new_country_curacao() {
|
142 |
+
$country = new WPSC_Country( array(
|
143 |
+
'id' => 249,
|
144 |
+
'country' => __( 'Curacao', 'wp-e-commerce' ),
|
145 |
+
'isocode' => 'CW',
|
146 |
+
'currency' => __( 'Netherlands Antillean Guilder', 'wp-e-commerce' ),
|
147 |
+
'symbol' => __( 'ƒ', 'wp-e-commerce' ),
|
148 |
+
'symbol_html' => __( 'ƒ', 'wp-e-commerce' ),
|
149 |
+
'code' => __( 'ANG', 'wp-e-commerce' ),
|
150 |
+
'continent' => 'southamerica',
|
151 |
+
'visible' => '0',
|
152 |
+
) );
|
153 |
+
}
|
154 |
+
|
155 |
+
function _wpsc_new_country_saint_martin_french() {
|
156 |
+
$country = new WPSC_Country( array(
|
157 |
+
'id' => 250,
|
158 |
+
'country' => __( 'Saint Martin (French Part)', 'wp-e-commerce' ),
|
159 |
+
'isocode' => 'MF',
|
160 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
161 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
162 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
163 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
164 |
+
'continent' => 'southamerica',
|
165 |
+
'visible' => '0',
|
166 |
+
) );
|
167 |
+
}
|
168 |
+
|
169 |
+
function _wpsc_new_country_palestinian_territories() {
|
170 |
+
$country = new WPSC_Country( array(
|
171 |
+
'id' => 251,
|
172 |
+
'country' => __( 'Palestinian Territories', 'wp-e-commerce' ),
|
173 |
+
'isocode' => 'PS',
|
174 |
+
'currency' => __( 'Israeli New Shekel', 'wp-e-commerce' ),
|
175 |
+
'symbol' => __( '₪', 'wp-e-commerce' ),
|
176 |
+
'symbol_html' => __( '₪', 'wp-e-commerce' ),
|
177 |
+
'code' => __( 'ILS', 'wp-e-commerce' ),
|
178 |
+
'continent' => 'asiapacific',
|
179 |
+
'visible' => '0',
|
180 |
+
) );
|
181 |
+
}
|
182 |
+
|
183 |
+
function _wpsc_update_israeli_new_shekel_symbol() {
|
184 |
+
$country = new WPSC_Country( array(
|
185 |
+
'isocode' => 'IL',
|
186 |
+
'symbol' => __( '₪', 'wp-e-commerce' ),
|
187 |
+
'symbol_html' => __( '₪', 'wp-e-commerce' ),
|
188 |
+
) );
|
189 |
+
}
|
190 |
+
|
191 |
+
function _wpsc_new_country_sint_maarten_dutch() {
|
192 |
+
$country = new WPSC_Country( array(
|
193 |
+
'id' => 252,
|
194 |
+
'country' => __( 'Sint Maarten (Dutch Part)', 'wp-e-commerce' ),
|
195 |
+
'isocode' => 'SX',
|
196 |
+
'currency' => __( 'Netherlands Antillean Guilder', 'wp-e-commerce' ),
|
197 |
+
'symbol' => __( 'ƒ', 'wp-e-commerce' ),
|
198 |
+
'symbol_html' => __( 'ƒ', 'wp-e-commerce' ),
|
199 |
+
'code' => __( 'ANG', 'wp-e-commerce' ),
|
200 |
+
'continent' => 'southamerica',
|
201 |
+
'visible' => '0',
|
202 |
+
) );
|
203 |
+
}
|
204 |
+
|
205 |
+
function _wpsc_new_country_french_guiana() {
|
206 |
+
$country = new WPSC_Country( array(
|
207 |
+
'id' => 253,
|
208 |
+
'country' => __( 'French Guiana', 'wp-e-commerce' ),
|
209 |
+
'isocode' => 'GF',
|
210 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
211 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
212 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
213 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
214 |
+
'continent' => 'southamerica',
|
215 |
+
'visible' => '0',
|
216 |
+
) );
|
217 |
+
}
|
218 |
+
|
219 |
+
function _wpsc_fix_netherlands_antille() {
|
220 |
+
$country = new WPSC_Country( array(
|
221 |
+
'isocode' => 'AN',
|
222 |
+
'symbol' => __( 'ƒ', 'wp-e-commerce' ),
|
223 |
+
'symbol_html' => __( 'ƒ', 'wp-e-commerce' ),
|
224 |
+
'continent' => 'southamerica',
|
225 |
+
) );
|
226 |
+
}
|
227 |
+
|
228 |
+
function _wpsc_fix_angola_kwanza() {
|
229 |
+
$country = new WPSC_Country( array(
|
230 |
+
'isocode' => 'AO',
|
231 |
+
'code' => 'AOA',
|
232 |
+
'currency' => __( 'Angolan Kwanza', 'wp-e-commerce' ),
|
233 |
+
'symbol' => __( 'Kz', 'wp-e-commerce' ),
|
234 |
+
'symbol_html' => __( 'Kz', 'wp-e-commerce' ),
|
235 |
+
) );
|
236 |
+
}
|
237 |
+
|
238 |
+
function _wpsc_fix_aruban_florin() {
|
239 |
+
$country = new WPSC_Country( array(
|
240 |
+
'isocode' => 'AW',
|
241 |
+
'currency' => __( 'Aruban Florin', 'wp-e-commerce' ),
|
242 |
+
'symbol' => __( 'Afl.', 'wp-e-commerce' ),
|
243 |
+
'symbol_html' => __( 'Afl.', 'wp-e-commerce' ),
|
244 |
+
) );
|
245 |
+
}
|
246 |
+
|
247 |
+
function _wpsc_fix_azerbaijani_manat() {
|
248 |
+
$country = new WPSC_Country( array(
|
249 |
+
'isocode' => 'AZ',
|
250 |
+
'currency' => __('Azerbaijani Manat', 'wp-e-commerce'),
|
251 |
+
'code' => 'AZN',
|
252 |
+
'symbol' => _x( 'm', 'azerbaijani manat symbol', 'wp-e-commerce' ),
|
253 |
+
'symbol_html' => _x( 'm', 'azerbaijani manat symbol html', 'wp-e-commerce' ),
|
254 |
+
) );
|
255 |
+
}
|
256 |
+
|
257 |
+
function _wpsc_fix_cyprus_currency() {
|
258 |
+
$country = new WPSC_Country( array(
|
259 |
+
'isocode' => 'CY',
|
260 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
261 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
262 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
263 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
264 |
+
) );
|
265 |
+
}
|
266 |
+
|
267 |
+
function _wpsc_fix_republic_of_the_congo() {
|
268 |
+
$country = new WPSC_Country( array(
|
269 |
+
'isocode' => 'CG',
|
270 |
+
'country' => __( 'Republic of the Congo', 'wp-e-commerce' ),
|
271 |
+
) );
|
272 |
+
}
|
273 |
+
|
274 |
+
function _wpsc_fix_currency_el_salvador() {
|
275 |
+
$country = new WPSC_Country( array(
|
276 |
+
'isocode' => 'SV',
|
277 |
+
'currency' => __( 'US Dollar', 'wp-e-commerce' ),
|
278 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
279 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
280 |
+
'code' => 'USD',
|
281 |
+
) );
|
282 |
+
}
|
283 |
+
|
284 |
+
function _wpsc_fix_ghanaian_currency_code() {
|
285 |
+
$country = new WPSC_Country( array(
|
286 |
+
'isocode' => 'GH',
|
287 |
+
'code' => 'GHS',
|
288 |
+
) );
|
289 |
+
}
|
290 |
+
|
291 |
+
function _wpsc_fix_guatemala_currency() {
|
292 |
+
$country = new WPSC_Country( array(
|
293 |
+
'isocode' => 'GT',
|
294 |
+
'code' => 'GTQ',
|
295 |
+
) );
|
296 |
+
}
|
297 |
+
|
298 |
+
function _wpsc_fix_guinea_bissau_currency() {
|
299 |
+
$country = new WPSC_Country( array(
|
300 |
+
'isocode' => 'GW',
|
301 |
+
'currency' => __( 'CFA Franc BEAC', 'wp-e-commerce' ),
|
302 |
+
'code' => __('XAF', 'wp-e-commerce'),
|
303 |
+
) );
|
304 |
+
}
|
305 |
+
|
306 |
+
function _wpsc_fix_madagascar_currency() {
|
307 |
+
$country = new WPSC_Country( array(
|
308 |
+
'isocode' => 'MG',
|
309 |
+
'currency' => __( 'Malagasy Ariary', 'wp-e-commerce' ),
|
310 |
+
'code' => __( 'MGA', 'wp-e-commerce' ),
|
311 |
+
) );
|
312 |
+
}
|
313 |
+
|
314 |
+
function _wpsc_fix_malta_currency() {
|
315 |
+
$country = new WPSC_Country( array(
|
316 |
+
'isocode' => 'MT',
|
317 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
318 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
319 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
320 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
321 |
+
) );
|
322 |
+
}
|
323 |
+
|
324 |
+
function _wpsc_fix_mozambique_currency() {
|
325 |
+
$country = new WPSC_Country( array(
|
326 |
+
'isocode' => 'MZ',
|
327 |
+
'code' => __( 'MZN', 'wp-e-commerce' )
|
328 |
+
) );
|
329 |
+
}
|
330 |
+
|
331 |
+
function _wpsc_fix_nicaragua_currency() {
|
332 |
+
$country = new WPSC_Country( array(
|
333 |
+
'isocode' => 'NI',
|
334 |
+
'code' => __( 'NIO', 'wp-e-commerce' )
|
335 |
+
) );
|
336 |
+
}
|
337 |
+
|
338 |
+
function _wpsc_fix_romania_currency() {
|
339 |
+
$country = new WPSC_Country( array(
|
340 |
+
'isocode' => 'RO',
|
341 |
+
'currency' => __( 'Romanian New Leu', 'wp-e-commerce' )
|
342 |
+
) );
|
343 |
+
}
|
344 |
+
|
345 |
+
function _wpsc_fix_san_marino_currency() {
|
346 |
+
$country = new WPSC_Country( array(
|
347 |
+
'isocode' => 'SM',
|
348 |
+
'currency' => __( 'Euro', 'wp-e-commerce' ),
|
349 |
+
'symbol' => __( '€', 'wp-e-commerce' ),
|
350 |
+
'symbol_html' => __( '€', 'wp-e-commerce' ),
|
351 |
+
'code' => __( 'EUR', 'wp-e-commerce' ),
|
352 |
+
) );
|
353 |
+
}
|
354 |
+
|
355 |
+
function _wpsc_fix_somalia_currency() {
|
356 |
+
$country = new WPSC_Country( array(
|
357 |
+
'isocode' => 'SO',
|
358 |
+
'code' => __( 'SOS', 'wp-e-commerce' )
|
359 |
+
) );
|
360 |
+
}
|
361 |
+
|
362 |
+
function _wpsc_fix_suriname_currency() {
|
363 |
+
$country = new WPSC_Country( array(
|
364 |
+
'isocode' => 'SR',
|
365 |
+
'currency' => __( 'Surinamese Dollar', 'wp-e-commerce' ),
|
366 |
+
'code' => __( 'SRD', 'wp-e-commerce' ),
|
367 |
+
) );
|
368 |
+
}
|
369 |
+
|
370 |
+
function _wpsc_fix_taiwan_currency() {
|
371 |
+
$country = new WPSC_Country( array(
|
372 |
+
'isocode' => 'TW',
|
373 |
+
'currency' => __( 'New Taiwanese Dollar', 'wp-e-commerce' )
|
374 |
+
) );
|
375 |
+
}
|
376 |
+
|
377 |
+
function _wpsc_fix_tajikistan_currency() {
|
378 |
+
$country = new WPSC_Country( array(
|
379 |
+
'isocode' => 'TJ',
|
380 |
+
'currency' => __( 'Tajikistan Somoni', 'wp-e-commerce' ),
|
381 |
+
'code' => __( 'TJS', 'wp-e-commerce' ),
|
382 |
+
) );
|
383 |
+
}
|
384 |
+
|
385 |
+
function _wpsc_fix_tunisia_currency() {
|
386 |
+
$country = new WPSC_Country( array(
|
387 |
+
'isocode' => 'TN',
|
388 |
+
'currency' => __( 'Tunisian Dollar', 'wp-e-commerce' )
|
389 |
+
) );
|
390 |
+
}
|
391 |
+
|
392 |
+
function _wpsc_fix_turkey_currency() {
|
393 |
+
$country = new WPSC_Country( array(
|
394 |
+
'isocode' => 'TR',
|
395 |
+
'code' => __( 'TRY', 'wp-e-commerce' )
|
396 |
+
) );
|
397 |
+
}
|
398 |
+
|
399 |
+
function _wpsc_fix_uganda_currency() {
|
400 |
+
$country = new WPSC_Country( array(
|
401 |
+
'isocode' => 'UG',
|
402 |
+
'code' => __( 'UGX', 'wp-e-commerce' )
|
403 |
+
) );
|
404 |
+
}
|
405 |
+
|
406 |
+
function _wpsc_fix_uruguay_currency() {
|
407 |
+
$country = new WPSC_Country( array(
|
408 |
+
'isocode' => 'UY',
|
409 |
+
'code' => __( 'UYU', 'wp-e-commerce' )
|
410 |
+
) );
|
411 |
+
}
|
412 |
+
|
413 |
+
function _wpsc_fix_venezuela_currency() {
|
414 |
+
$country = new WPSC_Country( array(
|
415 |
+
'isocode' => 'VE',
|
416 |
+
'currency' => __( 'Venezuelan Bolivar Fuerte', 'wp-e-commerce' ),
|
417 |
+
'code' => __( 'VEF', 'wp-e-commerce' ),
|
418 |
+
) );
|
419 |
+
}
|
420 |
+
|
421 |
+
function _wpsc_fix_zimbabwe_currency() {
|
422 |
+
$country = new WPSC_Country( array(
|
423 |
+
'isocode' => 'ZW',
|
424 |
+
'currency' => __( 'US Dollar', 'wp-e-commerce' ),
|
425 |
+
'symbol' => __( '$', 'wp-e-commerce' ),
|
426 |
+
'symbol_html' => __( '$', 'wp-e-commerce' ),
|
427 |
+
'code' => 'USD',
|
428 |
+
'continent' => 'asiapacific',
|
429 |
+
) );
|
430 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/3.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_3() {
|
4 |
+
_wpsc_maybe_create_UK();
|
5 |
+
}
|
6 |
+
|
7 |
+
function _wpsc_maybe_create_UK() {
|
8 |
+
$country = new WPSC_Country( array(
|
9 |
+
'isocode' => 'GB',
|
10 |
+
'id' => 138,
|
11 |
+
'country' => __( 'United Kingdom', 'wp-e-commerce' ),
|
12 |
+
'currency' => __( 'Pound Sterling', 'wp-e-commerce' ),
|
13 |
+
'symbol' => __( '£', 'wp-e-commerce' ),
|
14 |
+
'symbol_html' => __( '£', 'wp-e-commerce' ),
|
15 |
+
'code' => __( 'GBP', 'wp-e-commerce' ),
|
16 |
+
'continent' => 'europe',
|
17 |
+
) );
|
18 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/4.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_4() {
|
4 |
+
_wpsc_maybe_update_submitted_form_data_value();
|
5 |
+
_wpsc_maybe_update_user_log_file();
|
6 |
+
}
|
7 |
+
|
8 |
+
function _wpsc_maybe_update_submitted_form_data_value() {
|
9 |
+
global $wpdb;
|
10 |
+
$wpdb->query( 'ALTER TABLE ' . WPSC_TABLE_SUBMITTED_FORM_DATA . ' MODIFY value LONGTEXT;' );
|
11 |
+
}
|
12 |
+
|
13 |
+
function _wpsc_maybe_update_user_log_file() {
|
14 |
+
$hashes = array(
|
15 |
+
'3.8' => '1526bcf18869f9ea2f4061f528a1a21a',
|
16 |
+
'3.8.4' => '1d17c7fb086e2afcf942ca497629b4c9',
|
17 |
+
'3.8.8' => 'f9549ba1b1956c78f96b1551ab965c13',
|
18 |
+
'3.8.9' => '4d0bcba88d211147399e79661cf3b41d',
|
19 |
+
'3.8.10' => '09e2cb9c753587c9228a4e9e8008a82f',
|
20 |
+
);
|
21 |
+
|
22 |
+
if ( function_exists( 'wpsc_flush_theme_transients' ) ) {
|
23 |
+
wpsc_flush_theme_transients( true );
|
24 |
+
}
|
25 |
+
|
26 |
+
// Using TEv2
|
27 |
+
if ( ! function_exists( 'wpsc_get_template_file_path' ) ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
//Make sure the theme has actually been moved.
|
32 |
+
$file = wpsc_get_template_file_path( 'wpsc-user-log.php' );
|
33 |
+
|
34 |
+
if ( false !== strpos( WPSC_CORE_THEME_PATH, $file ) ) {
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
//If it has been moved, but it's the 3.8.10 version, we should be good to go.
|
39 |
+
$hash = md5_file( $file );
|
40 |
+
|
41 |
+
if ( $hashes['3.8.10'] === $hash ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
//At this point, we know the file has been moved to the active file folder. Checking now if it has been modified.
|
46 |
+
if ( in_array( $hash, $hashes ) ) {
|
47 |
+
//We now know that they've moved the file, but haven't actually changed anything. We can safely overwrite the file with the new core file.
|
48 |
+
@ copy( $file, path_join( get_stylesheet_directory(), 'wpsc-user-log.php' ) );
|
49 |
+
} else {
|
50 |
+
//This means they have indeed changed the file. We need to add a notice letting them know about the issue and how to fix it.
|
51 |
+
update_option( '_wpsc_3811_user_log_notice', '1' );
|
52 |
+
}
|
53 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/5.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_5() {
|
4 |
+
_wpsc_maybe_update_product_meta_array_keys();
|
5 |
+
}
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Rename old _wpsc_* product metadata array keys so they no longer include the '_wpsc_' prefix
|
9 |
+
* See https://github.com/wp-e-commerce/WP-e-Commerce/issues/492 for details
|
10 |
+
*/
|
11 |
+
function _wpsc_maybe_update_product_meta_array_keys() {
|
12 |
+
global $wpdb;
|
13 |
+
|
14 |
+
$product_ids = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_wpsc_product_metadata' AND meta_value LIKE '%_wpsc_%'" );
|
15 |
+
|
16 |
+
foreach ( $product_ids as $product_id ) {
|
17 |
+
$metadata_needs_saving = false;
|
18 |
+
$product_metadata = get_post_meta( $product_id, '_wpsc_product_metadata', true );
|
19 |
+
if ( is_array( $product_metadata ) ) {
|
20 |
+
foreach ( $product_metadata as $meta_key => $meta_value ) {
|
21 |
+
if ( '_wpsc_' === substr( $meta_key, 0, 6 ) ) {
|
22 |
+
/*
|
23 |
+
Typical meta keys that need renaming are:
|
24 |
+
wpsc_url_name
|
25 |
+
_wpsc_sku
|
26 |
+
_wpsc_dimensions
|
27 |
+
_wpsc_engraved
|
28 |
+
_wpsc_can_have_uploaded_image
|
29 |
+
_wpsc_unpublish_oos
|
30 |
+
*/
|
31 |
+
$new_meta_key = substr( $meta_key, 6 );
|
32 |
+
|
33 |
+
// remove the old (_wpsc_ prefixed) metadata from the array
|
34 |
+
unset ( $product_metadata[ $meta_key ] );
|
35 |
+
$metadata_needs_saving = true;
|
36 |
+
|
37 |
+
// If metadata doesn't already exist with the new non-prefixed key, add it to the array
|
38 |
+
// This check ensures that we don't overwrite newer product metadata
|
39 |
+
if ( ! isset( $product_metadata[ $new_meta_key ] ) ) {
|
40 |
+
$product_metadata[ $new_meta_key ] = $meta_value;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
if ( $metadata_needs_saving ) {
|
46 |
+
update_post_meta( $product_id, '_wpsc_product_metadata', $product_metadata );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/6.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-init.php' );
|
3 |
+
|
4 |
+
function _wpsc_db_upgrade_6() {
|
5 |
+
_wpsc_maybe_create_meta_tables();
|
6 |
+
}
|
7 |
+
|
8 |
+
function _wpsc_maybe_create_meta_tables() {
|
9 |
+
|
10 |
+
_wpsc_create_cart_item_meta_table();
|
11 |
+
_wpsc_meta_migrate_wpsc_cart_item();
|
12 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/7.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_7() {
|
4 |
+
_wpsc_migrate_user_meta();
|
5 |
+
}
|
6 |
+
|
7 |
+
function _wpsc_migrate_user_meta() {
|
8 |
+
global $wpdb;
|
9 |
+
|
10 |
+
$sql = "
|
11 |
+
SELECT *
|
12 |
+
FROM {$wpdb->usermeta}
|
13 |
+
WHERE
|
14 |
+
meta_key LIKE '_wpsc_%customer_profile';
|
15 |
+
";
|
16 |
+
|
17 |
+
$results = $wpdb->get_results( $sql );
|
18 |
+
|
19 |
+
foreach ( $results as $row ) {
|
20 |
+
preg_match( '/_wpsc_(.*)customer_profile/', $row->meta_key, $matches );
|
21 |
+
$blog_prefix = $matches[1];
|
22 |
+
|
23 |
+
$profile = maybe_unserialize( $row->meta_value );
|
24 |
+
|
25 |
+
foreach ( $profile as $key => $value ) {
|
26 |
+
$internal_key = "{$blog_prefix}_wpsc_{$key}";
|
27 |
+
$current_value = get_user_meta( $row->user_id, $internal_key, true );
|
28 |
+
|
29 |
+
if ( $current_value === '' && $value ) {
|
30 |
+
update_user_meta( $row->user_id, $internal_key, $value );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
delete_user_meta( $row->user_id, $row->meta_key );
|
35 |
+
}
|
36 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/8.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function _wpsc_db_upgrade_8() {
|
4 |
+
_wpsc_fix_bulgaria_currency();
|
5 |
+
}
|
6 |
+
|
7 |
+
function _wpsc_fix_bulgaria_currency() {
|
8 |
+
$country = new WPSC_Country( array(
|
9 |
+
'isocode' => 'BG',
|
10 |
+
'code' => __( 'BGN', 'wp-e-commerce' ),
|
11 |
+
) );
|
12 |
+
}
|
trunk/wpsc-admin/db-upgrades/routines/9.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( WPSC_FILE_PATH . '/wpsc-includes/wpsc-meta-init.php' );
|
4 |
+
|
5 |
+
function _wpsc_db_upgrade_9() {
|
6 |
+
_wpsc_maybe_create_purchase_meta_tables();
|
7 |
+
}
|
8 |
+
|
9 |
+
function _wpsc_maybe_create_purchase_meta_tables() {
|
10 |
+
|
11 |
+
_wpsc_create_purchase_meta_table();
|
12 |
+
_wpsc_meta_migrate_wpsc_purchase();
|
13 |
+
}
|
trunk/wpsc-admin/db-upgrades/upgrade.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Upgrade routines
|
4 |
+
*
|
5 |
+
* @since 3.8.9
|
6 |
+
* @access private
|
7 |
+
* @package wp-e-commerce
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Execute upgrade routines if necessary
|
12 |
+
*
|
13 |
+
* @access private
|
14 |
+
* @since 3.8.9
|
15 |
+
*/
|
16 |
+
function _wpsc_maybe_upgrade() {
|
17 |
+
$current_db_ver = (int) get_option( 'wpsc_db_version', 0 );
|
18 |
+
|
19 |
+
if ( ! _wpsc_needs_upgrade() )
|
20 |
+
return;
|
21 |
+
|
22 |
+
for ( $i = $current_db_ver + 1; $i <= WPSC_DB_VERSION; $i++ ) {
|
23 |
+
$file_path = WPSC_FILE_PATH . '/wpsc-admin/db-upgrades/routines/' . $i . '.php';
|
24 |
+
|
25 |
+
if ( file_exists( $file_path ) ) {
|
26 |
+
require_once( $file_path );
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( ! function_exists( '_wpsc_db_upgrade_' . $i ) ) {
|
30 |
+
continue;
|
31 |
+
}
|
32 |
+
|
33 |
+
wpsc_core_flush_temporary_data();
|
34 |
+
|
35 |
+
call_user_func( '_wpsc_db_upgrade_' . $i );
|
36 |
+
update_option( 'wpsc_db_version', $i );
|
37 |
+
}
|
38 |
+
|
39 |
+
wpsc_core_flush_temporary_data();
|
40 |
+
}
|
41 |
+
|
42 |
+
function _wpsc_upgrade_display_backup_warning() {
|
43 |
+
$message = __( '<strong>Important:</strong> Before proceeding with the database upgrade, <a href="%1$s">please backup your database and files</a>.<br>We recommend using <a href="%2$s">VaultPress</a> or <a href="%3$s">BackupBuddy</a> to regularly backup your WordPress installation.', 'wp-e-commerce' );
|
44 |
+
$message = sprintf(
|
45 |
+
$message,
|
46 |
+
'http://codex.wordpress.org/WordPress_Backups',
|
47 |
+
'http://vaultpress.com/',
|
48 |
+
'http://ithemes.com/member/go.php?r=45982&i=l44'
|
49 |
+
);
|
50 |
+
?>
|
51 |
+
<div id="wpsc-upgrade-warning" class="updated">
|
52 |
+
<p><?php echo $message; ?></p>
|
53 |
+
</div>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
+
|
57 |
+
function _wpsc_upgrade_display_prompt() {
|
58 |
+
$message = __( '<strong>WP eCommerce %1$s is almost ready.</strong> Some database routines need to be run before the upgrade is complete. <a href="%2$s">Click here to start!</a>', 'wp-e-commerce' );
|
59 |
+
$message = sprintf( $message, WPSC_VERSION, admin_url( '?page=wpsc-db-upgrade' ) );
|
60 |
+
?>
|
61 |
+
<div id="wpsc-upgrade-warning" class="error">
|
62 |
+
<p><?php echo $message; ?></p>
|
63 |
+
</div>
|
64 |
+
<?php
|
65 |
+
}
|
66 |
+
|
67 |
+
function _wpsc_upgrade_display_successful() {
|
68 |
+
$message = __( 'WP eCommerce has been successfully updated to %s. Enjoy!', 'wp-e-commerce' );
|
69 |
+
$message = sprintf( $message, WPSC_VERSION );
|
70 |
+
?>
|
71 |
+
<div id="wpsc-upgrade-warning" class="updated">
|
72 |
+
<p><?php echo $message; ?></p>
|
73 |
+
</div>
|
74 |
+
<?php
|
75 |
+
}
|
76 |
+
|
77 |
+
function _wpsc_action_admin_notices_db_upgrade() {
|
78 |
+
if ( ! empty( $_GET['wpsc_db_upgrade_successful'] ) ) {
|
79 |
+
_wpsc_upgrade_display_successful();
|
80 |
+
} elseif ( _wpsc_is_db_upgrade_page() ) {
|
81 |
+
_wpsc_upgrade_display_backup_warning();
|
82 |
+
} elseif ( _wpsc_needs_upgrade() ) {
|
83 |
+
_wpsc_upgrade_display_prompt();
|
84 |
+
}
|
85 |
+
}
|
86 |
+
add_action( 'admin_notices', '_wpsc_action_admin_notices_db_upgrade' );
|
87 |
+
|
88 |
+
function _wpsc_needs_3dot7_db_upgrade() {
|
89 |
+
global $wpdb;
|
90 |
+
|
91 |
+
static $return = null;
|
92 |
+
|
93 |
+
if ( is_null( $return ) ) {
|
94 |
+
// in case this installation was first installed using 3.8.x, then return false
|
95 |
+
if ( ! get_option( 'wpsc_needs_update', false ) ) {
|
96 |
+
$return = false;
|
97 |
+
} else {
|
98 |
+
// in case this installation was first installed using 3.7.x, we need to check whether
|
99 |
+
// the legacy database table exists, and if there are any products remain in that table
|
100 |
+
$table_exists = $wpdb->get_var( "SHOW TABLES LIKE '" . WPSC_TABLE_PRODUCT_LIST . "'" );
|
101 |
+
$product_count = empty( $table_exists ) ? 0 : $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
|
102 |
+
|
103 |
+
$return = $product_count > 0;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
return $return;
|
108 |
+
}
|
109 |
+
|
110 |
+
function _wpsc_needs_upgrade() {
|
111 |
+
if ( ! current_user_can( 'update_plugins' ) )
|
112 |
+
return false;
|
113 |
+
|
114 |
+
$current_db_ver = get_option( 'wpsc_db_version', 0 );
|
115 |
+
|
116 |
+
if ( WPSC_DB_VERSION <= $current_db_ver )
|
117 |
+
return false;
|
118 |
+
|
119 |
+
// if upgrading from 3.7.x, avoid displaying this notification until 3.7.x db has been successfully
|
120 |
+
// migrated
|
121 |
+
if ( _wpsc_needs_3dot7_db_upgrade() )
|
122 |
+
return false;
|
123 |
+
|
124 |
+
return true;
|
125 |
+
}
|
126 |
+
|
127 |
+
function _wpsc_is_db_upgrade_page() {
|
128 |
+
$current_screen = get_current_screen();
|
129 |
+
return ! empty( $current_screen->id ) && 'dashboard_page_wpsc-db-upgrade' == $current_screen->id;
|
130 |
+
}
|
131 |
+
|
132 |
+
function _wpsc_action_admin_menu_db_upgrade() {
|
133 |
+
if ( _wpsc_needs_upgrade() ) {
|
134 |
+
$page_hook = add_submenu_page( 'index.php', __( 'Database Upgrade', 'wp-e-commerce' ), __( 'Database Upgrade', 'wp-e-commerce' ), 'update_plugins', 'wpsc-db-upgrade', '_wpsc_callback_display_db_upgrade_page' );
|
135 |
+
add_action( 'load-' . $page_hook, '_wpsc_action_load_db_upgrade' );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
add_action( 'admin_menu', '_wpsc_action_admin_menu_db_upgrade' );
|
139 |
+
|
140 |
+
function _wpsc_action_load_db_upgrade() {
|
141 |
+
if ( empty( $_REQUEST['action'] ) )
|
142 |
+
return;
|
143 |
+
|
144 |
+
check_admin_referer( 'wpsc_db_upgrade' );
|
145 |
+
|
146 |
+
_wpsc_maybe_upgrade();
|
147 |
+
|
148 |
+
wp_redirect( esc_url_raw( add_query_arg( 'wpsc_db_upgrade_successful', 1, admin_url() ) ) );
|
149 |
+
exit;
|
150 |
+
}
|
151 |
+
|
152 |
+
function _wpsc_callback_display_db_upgrade_page() {
|
153 |
+
$update_title = sprintf( __( 'Your database needs to be upgraded before you can use WP eCommerce %s', 'wp-e-commerce' ), WPSC_VERSION );
|
154 |
+
include( 'views/main.php' );
|
155 |
+
}
|
trunk/wpsc-admin/db-upgrades/views/main.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<div id="icon-tools" class="icon32"><br></div>
|
3 |
+
<h2><?php esc_html_e( 'WP eCommerce Database Upgrade', 'wp-e-commerce' ); ?></h2>
|
4 |
+
<form class="wpsc-db-upgrade" action="" method="post">
|
5 |
+
<h3><?php echo esc_html( $update_title ); ?></h3>
|
6 |
+
<p><?php esc_html_e( 'Click "Start Database Upgrade" when you are ready.', 'wp-e-commerce' ); ?></p>
|
7 |
+
<?php wp_nonce_field( 'wpsc_db_upgrade' ); ?>
|
8 |
+
<input type="hidden" name="action" value="start_upgrade" />
|
9 |
+
<?php submit_button( __( 'Start Database Upgrade', 'wp-e-commerce' ), 'primary', 'submit', false ); ?>
|
10 |
+
</form>
|
11 |
+
</div>
|
trunk/wpsc-admin/display-coupon-add.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="coupon_data">
|
2 |
+
<div id="add_coupon_box">
|
3 |
+
<h2><?php _e( 'Add Coupon', 'wp-e-commerce' ); ?></h2>
|
4 |
+
<form name='add_coupon' method="post" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
|
5 |
+
<table class="form-table">
|
6 |
+
<tbody>
|
7 |
+
|
8 |
+
<?php do_action( 'wpsc_coupon_add_top' ); ?>
|
9 |
+
|
10 |
+
<tr class="form-field">
|
11 |
+
<th scope="row" valign="top">
|
12 |
+
<label for="add_coupon_code"><?php _e( 'Coupon Code', 'wp-e-commerce' ); ?></label>
|
13 |
+
</th>
|
14 |
+
<td>
|
15 |
+
<input name="add_coupon_code" id="add_coupon_code" type="text" style="width: 300px;"/>
|
16 |
+
<p class="description"><?php _e( 'The code entered to receive the discount', 'wp-e-commerce' ); ?></p>
|
17 |
+
</td>
|
18 |
+
</tr>
|
19 |
+
|
20 |
+
<tr class="form-field" id="discount_amount">
|
21 |
+
<th scope="row" valign="top">
|
22 |
+
<label for="add-coupon-code"><?php _e( 'Discount', 'wp-e-commerce' ); ?></label>
|
23 |
+
</th>
|
24 |
+
<td>
|
25 |
+
<input name="add_discount" step=".01" id="add-coupon-code" type="number" class="small-text" min="0" style="width: 300px" />
|
26 |
+
<p class="description"><?php _e( 'The discount amount', 'wp-e-commerce' ); ?></p>
|
27 |
+
</td>
|
28 |
+
</tr>
|
29 |
+
|
30 |
+
<tr class="form-field">
|
31 |
+
<th scope="row" valign="top">
|
32 |
+
<label for="add_discount_type"><?php _e( 'Discount Type', 'wp-e-commerce' ); ?></label>
|
33 |
+
</th>
|
34 |
+
<td>
|
35 |
+
<select name='add_discount_type' id='add_discount_type'>
|
36 |
+
<option value='0'><?php _e( 'Fixed Amount', 'wp-e-commerce' ); ?></option>
|
37 |
+
<option value='1'><?php _e( 'Percentage', 'wp-e-commerce' ); ?></option>
|
38 |
+
<option value='2'><?php _e( 'Free shipping', 'wp-e-commerce' ); ?></option>
|
39 |
+
</select>
|
40 |
+
<p class="description"><?php _e( 'The discount type', 'wp-e-commerce' ); ?></p>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
+
|
44 |
+
<tr class="form-field">
|
45 |
+
<th scope="row" valign="top">
|
46 |
+
<label for="add_start"><?php _e( 'Start and End', 'wp-e-commerce' ); ?></label>
|
47 |
+
</th>
|
48 |
+
<td>
|
49 |
+
<span class="description"><?php _e( 'Start: ', 'wp-e-commerce' ); ?></span>
|
50 |
+
<input name="add_start" id="add_start" type="text" class="regular-text pickdate" style="width: 100px"/>
|
51 |
+
<span class="description"><?php _e( 'End: ', 'wp-e-commerce' ); ?></span>
|
52 |
+
<input name="add_end" id="add_end" type="text" class="regular-text pickdate" style="width: 100px"/>
|
53 |
+
<p class="description"><?php _e( 'If date fields are left empty, there will be no expiration on this coupon.', 'wp-e-commerce' ); ?></p>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
|
57 |
+
<tr>
|
58 |
+
<th scope="row" valign="top">
|
59 |
+
<?php _e( 'Active', 'wp-e-commerce' ); ?>
|
60 |
+
</th>
|
61 |
+
<td>
|
62 |
+
<input type='hidden' value='0' name='add_active' />
|
63 |
+
<input type="checkbox" value='1' checked='checked' name='add_active' id="add_active" />
|
64 |
+
<label for="add_active"><?php _e( 'Activate coupon on creation.', 'wp-e-commerce' ) ?></label>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
|
68 |
+
<tr>
|
69 |
+
<th scope="row" valign="top">
|
70 |
+
<?php _e( 'Use Once', 'wp-e-commerce' ); ?>
|
71 |
+
</th>
|
72 |
+
<td>
|
73 |
+
<input type='hidden' value='0' name='add_use-once' />
|
74 |
+
<input type='checkbox' value='1' name='add_use-once' id="add_use-once" />
|
75 |
+
<label for="add_use-once"><?php _e( 'Deactivate coupon after it has been used.', 'wp-e-commerce' ) ?></label>
|
76 |
+
</td>
|
77 |
+
</tr>
|
78 |
+
|
79 |
+
<tr>
|
80 |
+
<th scope="row" valign="top">
|
81 |
+
<?php _e( 'Apply On All Products', 'wp-e-commerce' ); ?>
|
82 |
+
</th>
|
83 |
+
<td>
|
84 |
+
</span><input type='hidden' value='0' name='add_every_product' />
|
85 |
+
<input type="checkbox" value="1" name='add_every_product' id="add_every-product"/>
|
86 |
+
<label for="add_every-product"><?php _e( 'This coupon affects each product at checkout.', 'wp-e-commerce' ) ?></label>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
|
90 |
+
<tr class="form-field coupon-conditions">
|
91 |
+
<th scope="row" valign="top">
|
92 |
+
<label><strong><?php _e( 'Conditions', 'wp-e-commerce' ); ?></strong></label>
|
93 |
+
</th>
|
94 |
+
<td>
|
95 |
+
<input type="hidden" name="rules[operator][]" value="" />
|
96 |
+
<div class='coupon-condition'>
|
97 |
+
<select class="ruleprops" name="rules[property][]">
|
98 |
+
<option value="item_name" rel="order"><?php _e( 'Item name', 'wp-e-commerce' ); ?></option>
|
99 |
+
<option value="item_quantity" rel="order"><?php _e( 'Item quantity', 'wp-e-commerce' ); ?></option>
|
100 |
+
<option value="total_quantity" rel="order"><?php _e( 'Total quantity', 'wp-e-commerce' ); ?></option>
|
101 |
+
<option value="subtotal_amount" rel="order"><?php _e( 'Subtotal amount', 'wp-e-commerce' ); ?></option>
|
102 |
+
<?php echo apply_filters( 'wpsc_coupon_rule_property_options', '' ); ?>
|
103 |
+
</select>
|
104 |
+
|
105 |
+
<select name="rules[logic][]">
|
106 |
+
<option value="equal"><?php _e( 'Is equal to', 'wp-e-commerce' ); ?></option>
|
107 |
+
<option value="greater"><?php _e( 'Is greater than', 'wp-e-commerce' ); ?></option>
|
108 |
+
<option value="less"><?php _e( 'Is less than', 'wp-e-commerce' ); ?></option>
|
109 |
+
<option value="contains"><?php _e( 'Contains', 'wp-e-commerce' ); ?></option>
|
110 |
+
<option value="not_contain"><?php _e( 'Does not contain', 'wp-e-commerce' ); ?></option>
|
111 |
+
<option value="begins"><?php _e( 'Begins with', 'wp-e-commerce' ); ?></option>
|
112 |
+
<option value="ends"><?php _e( 'Ends with', 'wp-e-commerce' ); ?></option>
|
113 |
+
<option value="category"><?php _e( 'In Category', 'wp-e-commerce' ); ?></option>
|
114 |
+
<?php echo apply_filters( 'wpsc_coupon_rule_logic_options', '' ); ?>
|
115 |
+
</select>
|
116 |
+
|
117 |
+
<input type="text" name="rules[value][]" style="width: 150px;"/>
|
118 |
+
<a title="<?php esc_attr_e( 'Delete condition', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></a>
|
119 |
+
<a title="<?php esc_attr_e( 'Add condition', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x( '+', 'add item', 'wp-e-commerce' ); ?></a>
|
120 |
+
</div>
|
121 |
+
</td>
|
122 |
+
</tr>
|
123 |
+
|
124 |
+
<?php do_action( 'wpsc_coupon_add_bottom' ); ?>
|
125 |
+
|
126 |
+
</tbody>
|
127 |
+
</table>
|
128 |
+
<?php wp_nonce_field( 'wpsc_coupon', 'wpsc-coupon-add' ); ?>
|
129 |
+
<?php submit_button( __( 'Add Coupon', 'wp-e-commerce' ), 'primary', 'add_coupon' ); ?>
|
130 |
+
|
131 |
+
</form>
|
132 |
+
</div>
|
133 |
+
</div><!--end .wrap-->
|
trunk/wpsc-admin/display-coupon-edit.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Die if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
die();
|
6 |
+
}
|
7 |
+
|
8 |
+
$coupon = new WPSC_Coupon( $_GET['coupon'] );
|
9 |
+
|
10 |
+
?>
|
11 |
+
<div class="wrap" id="coupon_data">
|
12 |
+
<div id="edit_coupon_box">
|
13 |
+
<h2><?php _e( 'Edit Coupon', 'wp-e-commerce' ); ?></h2>
|
14 |
+
|
15 |
+
<script type='text/javascript'>
|
16 |
+
jQuery(".pickdate").datepicker();
|
17 |
+
/* jQuery datepicker selector */
|
18 |
+
if (typeof jQuery('.pickdate').datepicker != "undefined") {
|
19 |
+
jQuery('.pickdate').datepicker({ dateFormat: 'yy-mm-dd' });
|
20 |
+
}
|
21 |
+
</script>
|
22 |
+
<form name='edit_coupon' method="post" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
|
23 |
+
<table class="form-table">
|
24 |
+
<tbody>
|
25 |
+
|
26 |
+
<?php do_action( 'wpsc_coupon_edit_top', $coupon->get( 'id' ), $coupon->get_data() ); ?>
|
27 |
+
|
28 |
+
<tr class="form-field">
|
29 |
+
<th scope="row" valign="top">
|
30 |
+
<label for="edit_coupon_code"><?php _e( 'Coupon Code', 'wp-e-commerce' ); ?></label>
|
31 |
+
</th>
|
32 |
+
<td>
|
33 |
+
<input name="edit_coupon_code" id="edit_coupon_code" type="text" value="<?php echo esc_attr( $coupon->get( 'coupon_code' ) ); ?>" style="width: 300px;"/>
|
34 |
+
<p class="description"><?php _e( 'The code entered to receive the discount', 'wp-e-commerce' ); ?></p>
|
35 |
+
</td>
|
36 |
+
</tr>
|
37 |
+
|
38 |
+
<tr class="form-field" id="discount_amount">
|
39 |
+
<th scope="row" valign="top">
|
40 |
+
<label for="edit_coupon_amount"><?php _e( 'Discount', 'wp-e-commerce' ); ?></label>
|
41 |
+
</th>
|
42 |
+
<td>
|
43 |
+
<input name="edit_coupon_amount" id="edit_coupon_amount" type="number" step=".01" value="<?php echo esc_attr( $coupon->get( 'value' ) ); ?>" class="small-text" min="0" style="width: 300px" />
|
44 |
+
<p class="description"><?php _e( 'The discount amount', 'wp-e-commerce' ); ?></p>
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
+
|
48 |
+
<tr class="form-field">
|
49 |
+
<th scope="row" valign="top">
|
50 |
+
<label for="edit_discount_type"><?php _e( 'Discount Type', 'wp-e-commerce' ); ?></label>
|
51 |
+
</th>
|
52 |
+
<td>
|
53 |
+
<?php $type = absint( $coupon->get( 'is-percentage' ) ); ?>
|
54 |
+
<select name='edit_discount_type' id='edit_discount_type'>
|
55 |
+
<option value='0'<?php selected( 0, $type ); ?>><?php _e( 'Fixed Amount', 'wp-e-commerce' ); ?></option>
|
56 |
+
<option value='1'<?php selected( 1, $type ); ?>><?php _e( 'Percentage', 'wp-e-commerce' ); ?></option>
|
57 |
+
<option value='2'<?php selected( 2, $type ); ?>><?php _e( 'Free shipping', 'wp-e-commerce' ); ?></option>
|
58 |
+
</select>
|
59 |
+
<p class="description"><?php _e( 'The discount type', 'wp-e-commerce' ); ?></p>
|
60 |
+
|
61 |
+
<?php $display = $type == 2 ? '' : 'style="display:none;"'; ?>
|
62 |
+
</td>
|
63 |
+
</tr>
|
64 |
+
|
65 |
+
<tr class="form-field">
|
66 |
+
<th scope="row" valign="top">
|
67 |
+
<label for="edit_coupon_start"><?php _e( 'Start and End', 'wp-e-commerce' ); ?></label>
|
68 |
+
</th>
|
69 |
+
<td>
|
70 |
+
<?php
|
71 |
+
$start = $coupon->get( 'start' ) == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon->get( 'start' ), 'Y-m-d' );
|
72 |
+
$end = $coupon->get( 'expiry' ) == '0000-00-00 00:00:00' ? '' : get_date_from_gmt( $coupon->get( 'expiry' ), 'Y-m-d' );
|
73 |
+
?>
|
74 |
+
<span class="description"><?php _e( 'Start: ', 'wp-e-commerce' ); ?></span>
|
75 |
+
<input name="edit_coupon_start" id="edit_coupon_start" type="text" value="<?php echo esc_attr( $start ); ?>" class="regular-text pickdate" style="width: 100px"/>
|
76 |
+
<span class="description"><?php _e( 'End: ', 'wp-e-commerce' ); ?></span>
|
77 |
+
<input name="edit_coupon_end" id="edit_coupon_end" type="text" value="<?php echo esc_attr( $end ); ?>" class="regular-text pickdate" style="width: 100px"/>
|
78 |
+
<p class="description"><?php _e( 'If date fields are left empty, there will be no expiration on this coupon.', 'wp-e-commerce' ); ?></p>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
|
82 |
+
<tr>
|
83 |
+
<th scope="row" valign="top">
|
84 |
+
<?php _e( 'Active', 'wp-e-commerce' ); ?>
|
85 |
+
</th>
|
86 |
+
<td>
|
87 |
+
<input type='hidden' value='0' name='edit_coupon_active' />
|
88 |
+
<input type="checkbox" value='1'<?php checked( 1, $coupon->get( 'active' ) ); ?> name='edit_coupon_active' id="edit_coupon_active" />
|
89 |
+
<label for="edit_coupon_active"><?php _e( 'Is this coupon active?', 'wp-e-commerce' ) ?></label>
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
|
93 |
+
<tr>
|
94 |
+
<th scope="row" valign="top">
|
95 |
+
<?php _e( 'Use Once', 'wp-e-commerce' ); ?>
|
96 |
+
</th>
|
97 |
+
<td>
|
98 |
+
<input type='hidden' value='0' name='edit_coupon_use_once' />
|
99 |
+
<input type='checkbox' value='1'<?php checked( 1, $coupon->get( 'use-once' ) ); ?> name='edit_coupon_use_once' id="edit_coupon_use_once" />
|
100 |
+
<label for="edit_coupon_use_once"><?php _e( 'Deactivate coupon after it has been used.', 'wp-e-commerce' ) ?></label>
|
101 |
+
</td>
|
102 |
+
</tr>
|
103 |
+
|
104 |
+
<tr>
|
105 |
+
<th scope="row" valign="top">
|
106 |
+
<?php _e( 'Apply On All Products', 'wp-e-commerce' ); ?>
|
107 |
+
</th>
|
108 |
+
<td>
|
109 |
+
</span><input type='hidden' value='0' name='edit_coupon_every_product' />
|
110 |
+
<input type="checkbox" value="1"<?php checked( 1, $coupon->get( 'every_product' ) ); ?> name='edit_coupon_every_product' id="edit-coupon-every-product"/>
|
111 |
+
<label for="edit-coupon-every-product"><?php _e( 'This coupon affects each product at checkout.', 'wp-e-commerce' ) ?></label>
|
112 |
+
</td>
|
113 |
+
</tr>
|
114 |
+
|
115 |
+
<tr class="form-field coupon-conditions">
|
116 |
+
<th scope="row" valign="top">
|
117 |
+
<label><strong><?php _e( 'Conditions', 'wp-e-commerce' ); ?></strong></label>
|
118 |
+
</th>
|
119 |
+
<td>
|
120 |
+
<input type="hidden" name="rules[operator][]" value="" />
|
121 |
+
<?php
|
122 |
+
$conditions = maybe_unserialize( $coupon->get( 'condition' ) );
|
123 |
+
|
124 |
+
if ( empty( $conditions ) )
|
125 |
+
$conditions = array(
|
126 |
+
array(
|
127 |
+
'property' => '',
|
128 |
+
'logic' => '',
|
129 |
+
'value' => '',
|
130 |
+
)
|
131 |
+
);
|
132 |
+
foreach ( $conditions as $key => $condition ) :
|
133 |
+
?>
|
134 |
+
<div class='coupon-condition'>
|
135 |
+
<?php
|
136 |
+
if ( isset( $condition["operator"] ) && ! empty( $condition["operator"] ) ) :
|
137 |
+
?>
|
138 |
+
<select name="rules[operator][]">
|
139 |
+
<option value="and"<?php selected( 'and', $condition["operator"] ); ?>><?php _ex( 'AND', 'Coupon comparison logic', 'wp-e-commerce' );?></option>
|
140 |
+
<option value="or"<?php selected( 'or' , $condition["operator"] ); ?>><?php _ex( 'OR' , 'Coupon comparison logic', 'wp-e-commerce' );?></option>
|
141 |
+
</select>
|
142 |
+
<?php endif; ?>
|
143 |
+
<select class="ruleprops" name="rules[property][]">
|
144 |
+
<option value="item_name"<?php selected( 'item_name', $condition['property'] ); ?> rel="order"><?php _e( 'Item name', 'wp-e-commerce' ); ?></option>
|
145 |
+
<option value="item_quantity"<?php selected( 'item_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Item quantity', 'wp-e-commerce' ); ?></option>
|
146 |
+
<option value="total_quantity"<?php selected( 'total_quantity', $condition['property'] ); ?> rel="order"><?php _e( 'Total quantity', 'wp-e-commerce' ); ?></option>
|
147 |
+
<option value="subtotal_amount"<?php selected( 'subtotal_amount', $condition['property'] ); ?> rel="order"><?php _e( 'Subtotal amount', 'wp-e-commerce' ); ?></option>
|
148 |
+
<?php do_action( 'wpsc_coupon_rule_property_options', $condition['property'] ); ?>
|
149 |
+
</select>
|
150 |
+
|
151 |
+
<select name="rules[logic][]">
|
152 |
+
<option value="equal"<?php selected( 'equal', $condition['logic'] ); ?>><?php _e( 'Is equal to', 'wp-e-commerce' ); ?></option>
|
153 |
+
<option value="greater"<?php selected( 'greater', $condition['logic'] ); ?>><?php _e( 'Is greater than', 'wp-e-commerce' ); ?></option>
|
154 |
+
<option value="less"<?php selected( 'less', $condition['logic'] ); ?>><?php _e( 'Is less than', 'wp-e-commerce' ); ?></option>
|
155 |
+
<option value="contains"<?php selected( 'contains', $condition['logic'] ); ?>><?php _e( 'Contains', 'wp-e-commerce' ); ?></option>
|
156 |
+
<option value="not_contain"<?php selected( 'not_contain', $condition['logic'] ); ?>><?php _e( 'Does not contain', 'wp-e-commerce' ); ?></option>
|
157 |
+
<option value="begins"<?php selected( 'begins', $condition['logic'] ); ?>><?php _e( 'Begins with', 'wp-e-commerce' ); ?></option>
|
158 |
+
<option value="ends"<?php selected( 'ends', $condition['logic'] ); ?>><?php _e( 'Ends with', 'wp-e-commerce' ); ?></option>
|
159 |
+
<option value="category"<?php selected( 'category', $condition['logic'] ); ?>><?php _e( 'In Category', 'wp-e-commerce' ); ?></option>
|
160 |
+
</select>
|
161 |
+
|
162 |
+
<input type="text" name="rules[value][]" value="<?php echo esc_attr( $condition['value'] ); ?>" style="width: 150px;"/>
|
163 |
+
<a title="<?php esc_attr_e( 'Delete condition', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></a>
|
164 |
+
<a title="<?php esc_attr_e( 'Add condition', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x( '+', 'add item', 'wp-e-commerce' ); ?></a>
|
165 |
+
</div>
|
166 |
+
<?php endforeach; ?>
|
167 |
+
</td>
|
168 |
+
</tr>
|
169 |
+
|
170 |
+
<?php do_action( 'wpsc_coupon_edit_bottom', $coupon->get( 'id' ), $coupon->get_data() ); ?>
|
171 |
+
|
172 |
+
</tbody>
|
173 |
+
</table>
|
174 |
+
<input type="hidden" name="coupon_id" value="<?php echo esc_attr( $coupon->get( 'id' ) ); ?>"/>
|
175 |
+
<input type="hidden" name="edit_coupon_is_used" value="<?php echo esc_attr( $coupon->get( 'is-used' ) ); ?>"/>
|
176 |
+
<input type="hidden" name="is_edit_coupon" value="true" />
|
177 |
+
|
178 |
+
<?php wp_nonce_field( 'wpsc_coupon', 'wpsc-coupon-edit' ); ?>
|
179 |
+
<?php submit_button( __( 'Update Coupon', 'wp-e-commerce' ), 'primary' ); ?>
|
180 |
+
|
181 |
+
</form>
|
182 |
+
</div>
|
183 |
+
</div><!--end .wrap-->
|
trunk/wpsc-admin/display-coupons.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wpsc_display_coupons_page() {
|
4 |
+
global $wpdb;
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Update / create code that will be abstracted to its own class at some point
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( isset( $_POST ) && is_array( $_POST ) && ! empty( $_POST ) ) {
|
12 |
+
|
13 |
+
if ( isset( $_POST['add_coupon'] ) && (!isset( $_POST['is_edit_coupon'] ) || !($_POST['is_edit_coupon'] == 'true')) ) {
|
14 |
+
|
15 |
+
check_admin_referer( 'wpsc_coupon', 'wpsc-coupon-add' );
|
16 |
+
|
17 |
+
if ( ! function_exists( 'wpsc_is_store_admin' ) || ! wpsc_is_store_admin() ) {
|
18 |
+
wp_die( __( 'Permission denied', 'wpsc' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
$coupon_code = $_POST['add_coupon_code'];
|
22 |
+
$discount = (double)$_POST['add_discount'];
|
23 |
+
$discount_type = (int)$_POST['add_discount_type'];
|
24 |
+
$use_once = (int)(bool)$_POST['add_use-once'];
|
25 |
+
$every_product = (int)(bool)$_POST['add_every_product'];
|
26 |
+
$is_active = (int)(bool)$_POST['add_active'];
|
27 |
+
$start_date = ! empty( $_POST['add_start'] ) ? date( 'Y-m-d', strtotime( $_POST['add_start'] ) ) . " 00:00:00" : "0000-00-00 00:00:00";
|
28 |
+
$end_date = ! empty( $_POST['add_end'] ) ? date( 'Y-m-d', strtotime( $_POST['add_end'] ) ) . " 23:59:59" : "0000-00-00 00:00:00";
|
29 |
+
$rules = $_POST['rules'];
|
30 |
+
$new_rules = array();
|
31 |
+
|
32 |
+
foreach ( $rules as $key => $rule ) {
|
33 |
+
foreach ( $rule as $k => $r ) {
|
34 |
+
$new_rules[$k][$key] = $r;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
foreach ( $new_rules as $key => $rule ) {
|
39 |
+
if ( '' == $rule['value'] )
|
40 |
+
unset( $new_rules[$key] );
|
41 |
+
}
|
42 |
+
|
43 |
+
$new_coupon = new WPSC_Coupon( array(
|
44 |
+
'coupon_code' => $coupon_code,
|
45 |
+
'value' => $discount,
|
46 |
+
'is-percentage' => $discount_type,
|
47 |
+
'use-once' => $use_once,
|
48 |
+
'is-used' => 0,
|
49 |
+
'active' => $is_active,
|
50 |
+
'every_product' => $every_product,
|
51 |
+
'start' => $start_date,
|
52 |
+
'expiry' => $end_date,
|
53 |
+
'condition' => $new_rules
|
54 |
+
) );
|
55 |
+
$insert = $new_coupon->save();
|
56 |
+
|
57 |
+
if ( $insert ) {
|
58 |
+
echo '<div class="updated"><p>' . __( 'The coupon has been added.', 'wp-e-commerce' ) . '</p></div>';
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
// update an existing coupon
|
64 |
+
if ( isset( $_POST['is_edit_coupon'] ) && ($_POST['is_edit_coupon'] == 'true') && !(isset( $_POST['delete_condition'] )) && !(isset( $_POST['submit_condition'] )) ) {
|
65 |
+
|
66 |
+
check_admin_referer( 'wpsc_coupon', 'wpsc-coupon-edit' );
|
67 |
+
|
68 |
+
if ( ! function_exists( 'wpsc_is_store_admin' ) || ! wpsc_is_store_admin() ) {
|
69 |
+
wp_die( __( 'Permission denied', 'wpsc' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
$rules = isset( $_POST['rules'] ) ? $_POST['rules'] : array();
|
73 |
+
$new_rules = array();
|
74 |
+
|
75 |
+
foreach ( $rules as $key => $rule ) {
|
76 |
+
foreach ( $rule as $k => $r ) {
|
77 |
+
$new_rules[$k][$key] = $r;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
foreach ( $new_rules as $key => $rule ) {
|
82 |
+
if ( '' == $rule['value'] )
|
83 |
+
unset( $new_rules[$key] );
|
84 |
+
}
|
85 |
+
|
86 |
+
$update_coupon = new WPSC_Coupon( $_POST['coupon_id'] );
|
87 |
+
$update_coupon->set( array(
|
88 |
+
'coupon_code' => $_POST['edit_coupon_code'],
|
89 |
+
'value' => $_POST['edit_coupon_amount'],
|
90 |
+
'is-percentage' => $_POST['edit_discount_type'],
|
91 |
+
'use-once' => $_POST['edit_coupon_use_once'],
|
92 |
+
'is-used' => $_POST['edit_coupon_is_used'],
|
93 |
+
'active' => $_POST['edit_coupon_active'],
|
94 |
+
'every_product' => $_POST['edit_coupon_every_product'],
|
95 |
+
'start' => ! empty( $_POST['edit_coupon_start'] ) ? get_gmt_from_date( $_POST['edit_coupon_start'] . ' 00:00:00' ) : "0000-00-00 00:00:00",
|
96 |
+
'expiry' => ! empty( $_POST['edit_coupon_end'] ) ? get_gmt_from_date( $_POST['edit_coupon_end'] . ' 23:59:59' ) : "0000-00-00 00:00:00",
|
97 |
+
'condition' => $new_rules
|
98 |
+
) );
|
99 |
+
|
100 |
+
$update = $update_coupon->save();
|
101 |
+
|
102 |
+
if ( $update ) {
|
103 |
+
echo '<div class="updated"><p>' . __( 'The coupon has been updated.', 'wp-e-commerce' ) . '</p></div>';
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Load the selected view
|
111 |
+
*/
|
112 |
+
|
113 |
+
if( isset( $_GET['wpsc-action'] ) && $_GET['wpsc-action'] == 'add_coupon' ) {
|
114 |
+
// load the coupon add screen
|
115 |
+
include( dirname( __FILE__ ) . '/display-coupon-add.php' );
|
116 |
+
|
117 |
+
} elseif( isset( $_GET['wpsc-action'] ) && $_GET['wpsc-action'] == 'edit_coupon' ) {
|
118 |
+
// load the coupon add screen
|
119 |
+
include( dirname( __FILE__ ) . '/display-coupon-edit.php' );
|
120 |
+
|
121 |
+
} else {
|
122 |
+
require_once WPSC_FILE_PATH . '/wpsc-admin/includes/coupon-list-table-class.php';
|
123 |
+
$coupons_table = new WPSC_Coupons_List_Table();
|
124 |
+
$coupons_table->prepare_items(); ?>
|
125 |
+
<div class="wrap">
|
126 |
+
<h2><?php _e( 'Coupons', 'wp-e-commerce' ); ?><a href="<?php echo esc_url( add_query_arg( 'wpsc-action', 'add_coupon' ) ); ?>" class="add-new-h2"><?php _e( 'Add Coupon', 'wp-e-commerce' ); ?></a></h2>
|
127 |
+
<?php do_action( 'wpsc_coupons_page_top' ); ?>
|
128 |
+
<form id="wpsc-coupons-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons' ); ?>">
|
129 |
+
|
130 |
+
<input type="hidden" name="post_type" value="wpsc-product" />
|
131 |
+
<input type="hidden" name="page" value="wpsc-edit-coupons" />
|
132 |
+
|
133 |
+
<?php $coupons_table->views() ?>
|
134 |
+
<?php $coupons_table->display() ?>
|
135 |
+
</form>
|
136 |
+
<?php do_action( 'wpsc_coupons_page_bottom' ); ?>
|
137 |
+
</div>
|
138 |
+
<?php
|
139 |
+
} // end view check
|
140 |
+
}
|
trunk/wpsc-admin/display-items.page.php
ADDED
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP eCommerce edit and add product page functions
|
4 |
+
*
|
5 |
+
* These are the main WPSC Admin functions
|
6 |
+
*
|
7 |
+
* @package wp-e-commerce
|
8 |
+
* @since 3.7
|
9 |
+
*/
|
10 |
+
|
11 |
+
require_once(WPSC_FILE_PATH . '/wpsc-admin/includes/products.php');
|
12 |
+
|
13 |
+
/**
|
14 |
+
* wpsc_additional_column_names function.
|
15 |
+
*
|
16 |
+
* @access public
|
17 |
+
* @param (array) $columns
|
18 |
+
* @return (array) $columns
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
function wpsc_additional_column_names( $columns ){
|
22 |
+
$columns = array();
|
23 |
+
|
24 |
+
$columns['cb'] = '<input type="checkbox" />';
|
25 |
+
$columns['image'] = '';
|
26 |
+
$columns['title'] = __('Name', 'wp-e-commerce');
|
27 |
+
$columns['stock'] = __('Stock', 'wp-e-commerce');
|
28 |
+
$columns['price'] = __('Price', 'wp-e-commerce');
|
29 |
+
$columns['sale_price'] = __('Sale', 'wp-e-commerce');
|
30 |
+
$columns['SKU'] = __('SKU', 'wp-e-commerce');
|
31 |
+
$columns['weight'] = __('Weight', 'wp-e-commerce');
|
32 |
+
$columns['cats'] = __('Categories', 'wp-e-commerce');
|
33 |
+
$columns['featured'] = '<img src="' . WPSC_CORE_IMAGES_URL . '/black-star.png" alt="' . __( 'Featured', 'wp-e-commerce' ) . '" title="' . __( 'Featured', 'wp-e-commerce' ) . '">';
|
34 |
+
$columns['hidden_alerts'] = '';
|
35 |
+
$columns['date'] = __('Date', 'wp-e-commerce');
|
36 |
+
|
37 |
+
return $columns;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param array $columns The array of sortable columns
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
function wpsc_additional_sortable_column_names( $columns ){
|
45 |
+
|
46 |
+
$columns['stock'] = 'stock';
|
47 |
+
$columns['price'] = 'price';
|
48 |
+
$columns['sale_price'] = 'sale_price';
|
49 |
+
$columns['SKU'] = 'SKU';
|
50 |
+
|
51 |
+
return $columns;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Image column in Manage Products page
|
56 |
+
*
|
57 |
+
* @since 3.8.9
|
58 |
+
* @access private
|
59 |
+
*
|
60 |
+
* @param object $post Post object
|
61 |
+
* @param int $post_id Post ID
|
62 |
+
*
|
63 |
+
* @uses wpsc_the_product_thumbnail() Prints URL to the product thumbnail
|
64 |
+
* @uses esc_url() Makes sure we have a safe URL
|
65 |
+
*/
|
66 |
+
function _wpsc_manage_products_column_image( $post, $post_id ) {
|
67 |
+
$src = wpsc_the_product_thumbnail( false, false, $post_id, 'manage-products' );
|
68 |
+
|
69 |
+
if ( $src )
|
70 |
+
echo '<img src="' . esc_url( $src ). '" alt="" />';
|
71 |
+
else
|
72 |
+
echo '<img src="' . esc_url( WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif' ) . '" width="38" height="38" />';
|
73 |
+
}
|
74 |
+
add_action( 'wpsc_manage_products_column_image', '_wpsc_manage_products_column_image', 10, 2 );
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Weight column in Manage Products page
|
78 |
+
*
|
79 |
+
* @since 3.8.9
|
80 |
+
* @access private
|
81 |
+
*
|
82 |
+
* @param object $post Post object
|
83 |
+
* @param int $post_id Post ID
|
84 |
+
* @param boolean $has_variations Whether the product has variations
|
85 |
+
*
|
86 |
+
* @uses esc_html_e() Safe HTML with translation
|
87 |
+
* @uses get_post_meta() Gets post meta given key and post_id
|
88 |
+
* @uses maybe_unserialize() Unserialize value only if it was serialized.
|
89 |
+
* @uses wpsc_convert_weight() Does weight conversions
|
90 |
+
* @uses esc_html() Makes sure things are safe
|
91 |
+
* @uses wpsc_weight_unit_display() Gets weight unit for display
|
92 |
+
*/
|
93 |
+
function _wpsc_manage_products_column_weight( $post, $post_id, $has_variations ) {
|
94 |
+
if( $has_variations ) {
|
95 |
+
esc_html_e( 'N/A', 'wp-e-commerce' );
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
$product_data = array();
|
99 |
+
$product_data['meta'] = array();
|
100 |
+
$product_data['meta'] = get_post_meta( $post->ID, '' );
|
101 |
+
foreach( $product_data['meta'] as $meta_name => $meta_value ) {
|
102 |
+
$product_data['meta'][$meta_name] = maybe_unserialize( array_pop( $meta_value ) );
|
103 |
+
}
|
104 |
+
|
105 |
+
$product_data['transformed'] = array();
|
106 |
+
if( !isset( $product_data['meta']['_wpsc_product_metadata']['weight'] ) )
|
107 |
+
$product_data['meta']['_wpsc_product_metadata']['weight'] = "";
|
108 |
+
if( !isset( $product_data['meta']['_wpsc_product_metadata']['weight_unit'] ) )
|
109 |
+
$product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
|
110 |
+
|
111 |
+
$product_data['transformed']['weight'] = wpsc_convert_weight( $product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'] );
|
112 |
+
|
113 |
+
$weight = $product_data['transformed']['weight'];
|
114 |
+
if( $weight == '' )
|
115 |
+
$weight = '0';
|
116 |
+
|
117 |
+
$unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
118 |
+
|
119 |
+
echo $weight . wpsc_weight_unit_display( $unit );
|
120 |
+
echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . esc_html( $weight ) . '</div>';
|
121 |
+
}
|
122 |
+
add_action( 'wpsc_manage_products_column_weight', '_wpsc_manage_products_column_weight', 10, 3 );
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Stock column in Manage Products page.
|
126 |
+
*
|
127 |
+
* @since 3.8.9
|
128 |
+
* @access private
|
129 |
+
*
|
130 |
+
* @param object $post Post Object
|
131 |
+
* @param int $post_id Post ID
|
132 |
+
* @param boolean $has_variations Whether the product has variations
|
133 |
+
*
|
134 |
+
* @uses get_post_meta() Gets post meta given key and post_id
|
135 |
+
* @uses wpsc_variations_stock_remaining() Gets remaining stock level for given post_id
|
136 |
+
* @uses esc_html() Because we need safe HTML right???
|
137 |
+
*/
|
138 |
+
function _wpsc_manage_products_column_stock( $post, $post_id, $has_variations ) {
|
139 |
+
$stock = get_post_meta( $post->ID, '_wpsc_stock', true );
|
140 |
+
|
141 |
+
if( $stock == '' )
|
142 |
+
$stock = __('N/A', 'wp-e-commerce');
|
143 |
+
|
144 |
+
if ( $has_variations ) {
|
145 |
+
echo '~ ' . wpsc_variations_stock_remaining( $post->ID );
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
echo $stock;
|
150 |
+
echo '<div id="inline_' . $post->ID . '_stock" class="hidden">' . esc_html( $stock ) . '</div>';
|
151 |
+
|
152 |
+
}
|
153 |
+
add_action( 'wpsc_manage_products_column_stock', '_wpsc_manage_products_column_stock', 10, 3 );
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Price column in Manage Products page
|
157 |
+
*
|
158 |
+
* @since 3.8.9
|
159 |
+
* @access private
|
160 |
+
*
|
161 |
+
* @param object $post Post object
|
162 |
+
* @param int $post_id Post ID
|
163 |
+
* @param boolean $has_variations Whether the product has variations
|
164 |
+
*
|
165 |
+
* @uses get_post_meta() Gets post meta given key and post_id
|
166 |
+
* @uses wpsc_currency_display() Returns the currency after dealing with how the user wants it to be displayed
|
167 |
+
* @uses wpsc_product_variation_price_from() Gets the lowest variation price for the given post_id
|
168 |
+
*/
|
169 |
+
function _wpsc_manage_products_column_price( $post, $post_id, $has_variations ) {
|
170 |
+
$price = get_post_meta( $post->ID, '_wpsc_price', true );
|
171 |
+
$has_var = '1';
|
172 |
+
if( ! $has_variations ) {
|
173 |
+
echo wpsc_currency_display( $price );
|
174 |
+
echo '<div id="inline_' . $post->ID . '_price" class="hidden">' . trim( $price ) . '</div>';
|
175 |
+
$has_var = '0';
|
176 |
+
}
|
177 |
+
else
|
178 |
+
echo wpsc_product_variation_price_from( $post->ID, array(
|
179 |
+
'only_normal_price' => true,
|
180 |
+
'from_text' => '%s+'
|
181 |
+
) );
|
182 |
+
echo '<input type="hidden" value="' . $has_var . '" id="inline_' . $post->ID . '_has_var" />';
|
183 |
+
}
|
184 |
+
add_action( 'wpsc_manage_products_column_price', '_wpsc_manage_products_column_price', 10, 3 );
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Sale price column in Manage Products page.
|
188 |
+
*
|
189 |
+
* @since 3.8.9
|
190 |
+
* @access private
|
191 |
+
*
|
192 |
+
* @param object $post Post object
|
193 |
+
* @param int $post_id Post ID
|
194 |
+
* @param boolean $has_variations Whether the product has variations
|
195 |
+
*
|
196 |
+
* @uses get_post_meta() Gets post meta given key and post_id
|
197 |
+
* @uses wpsc_currency_display() Returns currency after taking user display options in to account
|
198 |
+
* @uses wpsc_product_variation_price_from() Gets the lowest variation price for the given post_id
|
199 |
+
*/
|
200 |
+
function _wpsc_manage_products_column_sale_price( $post, $post_id, $has_variations ) {
|
201 |
+
$price = get_post_meta( $post->ID, '_wpsc_special_price', true );
|
202 |
+
if( ! $has_variations ) {
|
203 |
+
echo wpsc_currency_display( $price );
|
204 |
+
echo '<div id="inline_' . $post->ID . '_sale_price" class="hidden">' . $price . '</div>';
|
205 |
+
} else
|
206 |
+
echo wpsc_product_variation_price_from( $post->ID, array( 'from_text' => '%s+' ) );
|
207 |
+
}
|
208 |
+
add_action( 'wpsc_manage_products_column_sale_price', '_wpsc_manage_products_column_sale_price', 10, 3 );
|
209 |
+
|
210 |
+
/**
|
211 |
+
* SKU column in Manage Products page
|
212 |
+
*
|
213 |
+
* @since 3.8.9
|
214 |
+
* @access private
|
215 |
+
*
|
216 |
+
* @param object $post Post object
|
217 |
+
* @param int $post_id Post ID
|
218 |
+
*
|
219 |
+
* @uses get_post_meta() Gets post meta given key and post_id
|
220 |
+
* @uses esc_html() Escapes the stuff inside
|
221 |
+
*/
|
222 |
+
function _wpsc_manage_products_column_sku( $post, $post_id ) {
|
223 |
+
$sku = get_post_meta( $post->ID, '_wpsc_sku', true );
|
224 |
+
if( $sku == '' )
|
225 |
+
$sku = __('N/A', 'wp-e-commerce');
|
226 |
+
|
227 |
+
echo $sku;
|
228 |
+
echo '<div id="inline_' . $post->ID . '_sku" class="hidden">' . esc_html( $sku ) . '</div>';
|
229 |
+
}
|
230 |
+
add_action( 'wpsc_manage_products_column_sku', '_wpsc_manage_products_column_sku', 10, 2 );
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Categories column in Manage Products page
|
234 |
+
*
|
235 |
+
* @since 3.8.9
|
236 |
+
* @access private
|
237 |
+
*
|
238 |
+
* @param object $post Post object
|
239 |
+
* @param int $post_id Post ID
|
240 |
+
*
|
241 |
+
* @uses get_the_product_category() Gets the category for the given post_id
|
242 |
+
* @uses esc_html() Makes sure we have safe HTML
|
243 |
+
* @uses sanitize_term_field() Cleanse the field value in the term based on the context.
|
244 |
+
*/
|
245 |
+
function _wpsc_manage_products_column_cats( $post, $post_id ) {
|
246 |
+
$categories = get_the_product_category( $post->ID );
|
247 |
+
if ( !empty( $categories ) ) {
|
248 |
+
$out = array();
|
249 |
+
foreach ( $categories as $c )
|
250 |
+
$out[] = "<a href='?post_type=wpsc-product&wpsc_product_category={$c->slug}'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) . "</a>";
|
251 |
+
echo join( ', ', $out );
|
252 |
+
} else {
|
253 |
+
_e('Uncategorized', 'wp-e-commerce');
|
254 |
+
}
|
255 |
+
}
|
256 |
+
add_action( 'wpsc_manage_products_column_cats', '_wpsc_manage_products_column_cats', 10, 2 );
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Featured column in Manage Products page.
|
260 |
+
*
|
261 |
+
* @since 3.8.9
|
262 |
+
* @access private
|
263 |
+
*
|
264 |
+
* @param object $post Post object
|
265 |
+
* @param int $post_id Post ID
|
266 |
+
*
|
267 |
+
* @uses get_option() Gets option from the WordPress database
|
268 |
+
* @uses _e() Displays the returned translated text from translate()
|
269 |
+
*/
|
270 |
+
function _wpsc_manage_products_column_featured( $post, $post_id ) {
|
271 |
+
$featured_product_url = wp_nonce_url( "index.php?wpsc_admin_action=update_featured_product&product_id=$post->ID", 'feature_product_' . $post->ID);
|
272 |
+
if ( in_array( $post->ID, (array) get_option( 'sticky_products' ) ) ) {
|
273 |
+
$class = 'gold-star';
|
274 |
+
$title = __( 'Unmark as Featured', 'wp-e-commerce' );
|
275 |
+
} else {
|
276 |
+
$class = 'grey-star';
|
277 |
+
$title = __( 'Mark as Featured', 'wp-e-commerce' );
|
278 |
+
}
|
279 |
+
?>
|
280 |
+
<a class="wpsc_featured_product_toggle featured_toggle_<?php echo $post->ID; ?> <?php echo esc_attr( $class ); ?>" href='<?php echo $featured_product_url; ?>' title="<?php echo esc_attr( $title ); ?>" ></a>
|
281 |
+
<?php
|
282 |
+
}
|
283 |
+
add_action( 'wpsc_manage_products_column_featured', '_wpsc_manage_products_column_featured', 10, 2 );
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Product alert column in Manage Products page
|
287 |
+
*
|
288 |
+
* @since 3.8.9
|
289 |
+
* @access private
|
290 |
+
*
|
291 |
+
* @param object $post Post object
|
292 |
+
* @param int $post_id Post ID
|
293 |
+
*
|
294 |
+
* @uses apply_filters() Calls 'wpsc_product_alert'
|
295 |
+
*/
|
296 |
+
function _wpsc_manage_products_column_hidden_alerts( $post, $post_id ) {
|
297 |
+
$product_alert = apply_filters( 'wpsc_product_alert', array( false, '' ), $post );
|
298 |
+
if( !empty( $product_alert['messages'] ) )
|
299 |
+
$product_alert['messages'] = implode( "\n",( array )$product_alert['messages'] );
|
300 |
+
|
301 |
+
if( $product_alert['state'] === true ) {
|
302 |
+
?>
|
303 |
+
<img alt='<?php echo $product_alert['messages'];?>' title='<?php echo $product_alert['messages'];?>' class='product-alert-image' src='<?php echo WPSC_CORE_IMAGES_URL;?>/product-alert.jpg' alt='' />
|
304 |
+
<?php
|
305 |
+
}
|
306 |
+
|
307 |
+
// If a product alert has stuff to display, show it.
|
308 |
+
// Can be used to add extra icons etc
|
309 |
+
if ( !empty( $product_alert['display'] ) )
|
310 |
+
echo $product_alert['display'];
|
311 |
+
}
|
312 |
+
add_action( 'wpsc_manage_products_column_hidden_alerts', '_wpsc_manage_products_column_hidden_alerts', 10, 2 );
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Adds extra data to post columns
|
317 |
+
*
|
318 |
+
* @access public
|
319 |
+
*
|
320 |
+
* @param (array) $column
|
321 |
+
* @return void
|
322 |
+
*
|
323 |
+
* @todo Need to check titles / alt tags ( I don't think thumbnails have any in this code )
|
324 |
+
* @desc Switch function to generate columns the right way...no more UI hacking!
|
325 |
+
*
|
326 |
+
* @uses get_post() Gets post object from provided post_id
|
327 |
+
* @uses wpsc_product_has_children() Checks if a product has variations or not
|
328 |
+
* @uses do_action() Calls 'wpsc_manage_products_column_$column'
|
329 |
+
*/
|
330 |
+
function wpsc_additional_column_data( $column, $post_id ) {
|
331 |
+
$post = get_post( $post_id );
|
332 |
+
|
333 |
+
$is_parent = wpsc_product_has_children($post_id);
|
334 |
+
$column = strtolower( $column );
|
335 |
+
do_action( "wpsc_manage_products_column_{$column}", $post, $post_id, $is_parent );
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* @param array $vars Array of query vars
|
340 |
+
* @return array $vars Our modified vars
|
341 |
+
*/
|
342 |
+
function wpsc_column_sql_orderby( $vars ) {
|
343 |
+
if ( ! isset( $vars['post_type'] ) || 'wpsc-product' != $vars['post_type'] || ! isset( $vars['orderby'] ) )
|
344 |
+
return $vars;
|
345 |
+
|
346 |
+
switch ( $vars['orderby'] ) :
|
347 |
+
case 'stock' :
|
348 |
+
$vars = array_merge(
|
349 |
+
$vars,
|
350 |
+
array(
|
351 |
+
'meta_key' => '_wpsc_stock',
|
352 |
+
'orderby' => 'meta_value_num'
|
353 |
+
)
|
354 |
+
);
|
355 |
+
break;
|
356 |
+
case 'price' :
|
357 |
+
$vars = array_merge(
|
358 |
+
$vars,
|
359 |
+
array(
|
360 |
+
'meta_key' => '_wpsc_price',
|
361 |
+
'orderby' => 'meta_value_num'
|
362 |
+
)
|
363 |
+
);
|
364 |
+
break;
|
365 |
+
case 'sale_price' :
|
366 |
+
$vars = array_merge(
|
367 |
+
$vars,
|
368 |
+
array(
|
369 |
+
'meta_key' => '_wpsc_special_price',
|
370 |
+
'orderby' => 'meta_value_num'
|
371 |
+
)
|
372 |
+
);
|
373 |
+
|
374 |
+
break;
|
375 |
+
case 'SKU' :
|
376 |
+
$vars = array_merge(
|
377 |
+
$vars,
|
378 |
+
array(
|
379 |
+
'meta_key' => '_wpsc_sku',
|
380 |
+
'orderby' => 'meta_value'
|
381 |
+
)
|
382 |
+
);
|
383 |
+
break;
|
384 |
+
endswitch;
|
385 |
+
|
386 |
+
return $vars;
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
*
|
391 |
+
* @uses get_taxonomy() Retrieves the taxonomy object of $taxonomy.
|
392 |
+
* @uses wpsc_cats_restrict_manage_posts_print_terms() @todo docs
|
393 |
+
*/
|
394 |
+
function wpsc_cats_restrict_manage_posts() {
|
395 |
+
global $typenow;
|
396 |
+
|
397 |
+
if ( $typenow == 'wpsc-product' ) {
|
398 |
+
|
399 |
+
$filters = array( 'wpsc_product_category' );
|
400 |
+
|
401 |
+
foreach ( $filters as $tax_slug ) {
|
402 |
+
// retrieve the taxonomy object
|
403 |
+
$tax_obj = get_taxonomy( $tax_slug );
|
404 |
+
$tax_name = $tax_obj->labels->name;
|
405 |
+
// retrieve array of term objects per taxonomy
|
406 |
+
// output html for taxonomy dropdown filter
|
407 |
+
echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
|
408 |
+
echo "<option value=''>" . esc_html( sprintf( _x( 'Show All %s', 'Show all [category name]', 'wp-e-commerce' ), $tax_name ) ) . "</option>";
|
409 |
+
wpsc_cats_restrict_manage_posts_print_terms($tax_slug);
|
410 |
+
echo "</select>";
|
411 |
+
}
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* @todo docs
|
417 |
+
* @param $taxonomy
|
418 |
+
* @param int $parent
|
419 |
+
* @param int $level
|
420 |
+
*
|
421 |
+
* @uses get_terms() Retrieve the terms in a given taxonomy or list of taxonomies.
|
422 |
+
*/
|
423 |
+
function wpsc_cats_restrict_manage_posts_print_terms( $taxonomy, $parent = 0, $level = 0 ) {
|
424 |
+
$prefix = str_repeat( ' ' , $level );
|
425 |
+
$terms = get_terms( $taxonomy, array( 'parent' => $parent, 'hide_empty' => false ) );
|
426 |
+
if( !($terms instanceof WP_Error) && !empty($terms) )
|
427 |
+
foreach ( $terms as $term ){
|
428 |
+
echo '<option value="'. $term->slug . '"', ( isset($_GET[$term->taxonomy]) && $_GET[$term->taxonomy] == $term->slug) ? ' selected="selected"' : '','>' . $prefix . $term->name .' (' . $term->count .')</option>';
|
429 |
+
wpsc_cats_restrict_manage_posts_print_terms($taxonomy, $term->term_id, $level+1);
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Restrict the products page to showing only parent products and not variations.
|
435 |
+
*
|
436 |
+
* @since 3.8
|
437 |
+
*/
|
438 |
+
function wpsc_no_minors_allowed( $vars ) {
|
439 |
+
$current_screen = get_current_screen();
|
440 |
+
|
441 |
+
if( $current_screen->post_type != 'wpsc-product' )
|
442 |
+
return $vars;
|
443 |
+
|
444 |
+
$vars['post_parent'] = 0;
|
445 |
+
|
446 |
+
return $vars;
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* wpsc_sortable_column_load
|
451 |
+
*
|
452 |
+
* Only sorts columns on edit.php page.
|
453 |
+
* @since 3.8.8
|
454 |
+
*
|
455 |
+
* @uses add_filter()
|
456 |
+
*/
|
457 |
+
function wpsc_sortable_column_load() {
|
458 |
+
add_filter( 'request', 'wpsc_no_minors_allowed' );
|
459 |
+
add_filter( 'request', 'wpsc_column_sql_orderby', 8 );
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Product List Exclude Child Categories
|
464 |
+
*
|
465 |
+
* When filtering the product list by category in the admin this ensures that
|
466 |
+
* only products in the selected category are shown, not any of it's sub-categories.
|
467 |
+
*
|
468 |
+
* @param object $query WP_Query
|
469 |
+
*
|
470 |
+
* @uses get_current_screen()
|
471 |
+
*/
|
472 |
+
function wpsc_product_list_exclude_child_categories( $query ) {
|
473 |
+
|
474 |
+
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! $query->is_main_query() )
|
475 |
+
return;
|
476 |
+
|
477 |
+
if ( 'edit-wpsc-product' == get_current_screen()->id ) {
|
478 |
+
$wpsc_product_category = $query->get( 'wpsc_product_category' );
|
479 |
+
if ( ! empty( $wpsc_product_category ) ) {
|
480 |
+
$category_query = array(
|
481 |
+
'taxonomy' => 'wpsc_product_category',
|
482 |
+
'field' => 'slug',
|
483 |
+
'terms' => array( $wpsc_product_category ),
|
484 |
+
'include_children' => false,
|
485 |
+
'operator' => 'IN'
|
486 |
+
);
|
487 |
+
$query->set( 'tax_query', array( $category_query ) );
|
488 |
+
$query->tax_query->queries = $query->get( 'tax_query' );
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
add_action( 'pre_get_posts', 'wpsc_product_list_exclude_child_categories', 15 );
|
494 |
+
|
495 |
+
add_action( 'load-edit.php' , 'wpsc_sortable_column_load' );
|
496 |
+
add_action( 'restrict_manage_posts' , 'wpsc_cats_restrict_manage_posts' );
|
497 |
+
add_action( 'manage_wpsc-product_posts_custom_column' , 'wpsc_additional_column_data', 10, 2 );
|
498 |
+
add_filter( 'manage_edit-wpsc-product_sortable_columns', 'wpsc_additional_sortable_column_names' );
|
499 |
+
add_filter( 'manage_edit-wpsc-product_columns' , 'wpsc_additional_column_names' );
|
500 |
+
add_filter( 'manage_wpsc-product_posts_columns' , 'wpsc_additional_column_names' );
|
501 |
+
|
502 |
+
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Update featured prodcuts using AJAX.
|
506 |
+
*
|
507 |
+
* @access public
|
508 |
+
* @return void
|
509 |
+
*
|
510 |
+
* @uses check_admin_referer() Makes sure that a user was referred from another admin page.
|
511 |
+
* @uses get_option() Gets option from the WordPress database
|
512 |
+
* @uses update_option() Updates an option in the WordPress database
|
513 |
+
* @uses wp_redirect() Redirects to another page.
|
514 |
+
* @uses wp_get_referer() Retrieve referer from '_wp_http_referer' or HTTP referer.
|
515 |
+
*/
|
516 |
+
function wpsc_update_featured_products() {
|
517 |
+
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) &&
|
518 |
+
! ( isset( $_REQUEST['wpsc_admin_action'] ) &&
|
519 |
+
( $_REQUEST['wpsc_admin_action'] == 'update_featured_product' ) ) )
|
520 |
+
return;
|
521 |
+
|
522 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update_featured_product' !== $_REQUEST['action'] )
|
523 |
+
return;
|
524 |
+
|
525 |
+
$product_id = absint( $_REQUEST['product_id'] );
|
526 |
+
|
527 |
+
if ( ! DOING_AJAX )
|
528 |
+
check_admin_referer( 'feature_product_' . $product_id );
|
529 |
+
|
530 |
+
$status = get_option( 'sticky_products' );
|
531 |
+
|
532 |
+
$new_status = ! in_array( $product_id, $status );
|
533 |
+
|
534 |
+
if ( $new_status ) {
|
535 |
+
$status[] = $product_id;
|
536 |
+
} else {
|
537 |
+
$status = array_diff( $status, array( $product_id ) );
|
538 |
+
$status = array_values( $status );
|
539 |
+
}
|
540 |
+
|
541 |
+
$update = update_option( 'sticky_products', $status );
|
542 |
+
|
543 |
+
do_action( 'wpsc_after_featured_product_update', $update, $status );
|
544 |
+
|
545 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
546 |
+
$json_response = array(
|
547 |
+
'text' => $new_status ? esc_attr__( 'Unmark as Featured', 'wp-e-commerce' ) : esc_attr__( 'Mark as Featured', 'wp-e-commerce' ),
|
548 |
+
'product_id' => $product_id,
|
549 |
+
'color' => $new_status ? 'gold-star' : 'grey-star',
|
550 |
+
'image' => $new_status ? WPSC_CORE_IMAGES_URL . '/gold-star.png' : WPSC_CORE_IMAGES_URL . '/grey-star.png'
|
551 |
+
);
|
552 |
+
|
553 |
+
echo json_encode( $json_response );
|
554 |
+
|
555 |
+
exit();
|
556 |
+
}
|
557 |
+
wp_redirect( wp_get_referer() );
|
558 |
+
exit;
|
559 |
+
}
|
560 |
+
|
561 |
+
add_filter( 'page_row_actions','wpsc_action_row', 10, 2 );
|
562 |
+
|
563 |
+
/**
|
564 |
+
* @param $actions
|
565 |
+
* @param $post
|
566 |
+
* @return mixed
|
567 |
+
*
|
568 |
+
* @uses admin_url() Gets the WordPress admin url
|
569 |
+
* @uses add_query_arg() Adds a query arg to url
|
570 |
+
* @uses esc_url() Makes sure the URL is safe, we like safe
|
571 |
+
* @uses esc_html_x() Displays translated string with gettext context
|
572 |
+
*/
|
573 |
+
function wpsc_action_row( $actions, $post ) {
|
574 |
+
|
575 |
+
if ( $post->post_type != "wpsc-product" )
|
576 |
+
return $actions;
|
577 |
+
|
578 |
+
$url = admin_url( 'edit.php' );
|
579 |
+
$url = add_query_arg( array( 'wpsc_admin_action' => 'duplicate_product', 'product' => $post->ID ), $url );
|
580 |
+
|
581 |
+
$actions['duplicate'] = '<a href="'.esc_url( $url ).'">' . esc_html_x( 'Duplicate', 'row-actions', 'wp-e-commerce' ) . '</a>';
|
582 |
+
return $actions;
|
583 |
+
}
|
584 |
+
|
585 |
+
add_action( 'wp_ajax_update_featured_product', 'wpsc_update_featured_products' );
|
586 |
+
add_action( 'admin_init' , 'wpsc_update_featured_products' );
|
trunk/wpsc-admin/display-options-settings.page.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Display Settings page
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
6 |
+
* @since 3.8
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Get the WPSC_Settings_Page class to display the page
|
11 |
+
*
|
12 |
+
* @since 3.8.9
|
13 |
+
*/
|
14 |
+
function wpsc_display_settings_page() {
|
15 |
+
WPSC_Settings_Page::get_instance()->display();
|
16 |
+
}
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Create settings page tabs
|
20 |
+
*/
|
21 |
+
|
22 |
+
function wpsc_settings_tabs() {
|
23 |
+
return WPSC_Settings_Page::get_instance()->get_tabs();
|
24 |
+
}
|
25 |
+
|
26 |
+
/*
|
27 |
+
* Display settings tabs
|
28 |
+
*/
|
29 |
+
|
30 |
+
function wpsc_the_settings_tabs() {
|
31 |
+
WPSC_Settings_Page::get_instance()->output_tabs();
|
32 |
+
}
|
33 |
+
|
34 |
+
function wpsc_settings_page_update_notification() {
|
35 |
+
|
36 |
+
if ( isset( $_GET['skipped'] ) || isset( $_GET['updated'] ) || isset( $_GET['regenerate'] ) || isset( $_GET['deleted'] ) || isset( $_GET['shipadd'] ) ) { ?>
|
37 |
+
|
38 |
+
<div id="message" class="updated fade"><p>
|
39 |
+
<?php
|
40 |
+
|
41 |
+
if ( isset( $_GET['updated'] ) && (int)$_GET['updated'] ) {
|
42 |
+
printf( _n( '%s Setting options updated.', ' %s Settings options updated.', $_GET['updated'], 'wp-e-commerce' ), absint( $_GET['updated'] ) );
|
43 |
+
unset( $_GET['updated'] );
|
44 |
+
$message = true;
|
45 |
+
}
|
46 |
+
if ( isset( $_GET['deleted'] ) && (int)$_GET['deleted'] ) {
|
47 |
+
printf( _n( '%s Setting option deleted.', '%s Setting option deleted.', $_GET['deleted'], 'wp-e-commerce' ), absint( $_GET['deleted'] ) );
|
48 |
+
unset( $_GET['deleted'] );
|
49 |
+
$message = true;
|
50 |
+
}
|
51 |
+
if ( isset( $_GET['shipadd'] ) && (int)$_GET['shipadd'] ) {
|
52 |
+
printf( _n( '%s Shipping option updated.', '%s Shipping option updated.', $_GET['shipadd'], 'wp-e-commerce' ), absint( $_GET['shipadd'] ) );
|
53 |
+
unset( $_GET['shipadd'] );
|
54 |
+
$message = true;
|
55 |
+
}
|
56 |
+
if ( isset( $_GET['added'] ) && (int)$_GET['added'] ) {
|
57 |
+
printf( _n( '%s Checkout field added.', '%s Checkout fields added.', $_GET['added'], 'wp-e-commerce' ), absint( $_GET['added'] ) );
|
58 |
+
unset( $_GET['added'] );
|
59 |
+
$message = true;
|
60 |
+
}
|
61 |
+
|
62 |
+
if ( ! isset( $message ) )
|
63 |
+
_e( 'Settings successfully updated.', 'wp-e-commerce' );
|
64 |
+
|
65 |
+
$_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array( 'locked', 'regenerate', 'skipped', 'updated', 'deleted', 'wpsc_downloadcsv', 'rss_key', 'start_timestamp', 'end_timestamp', 'email_buyer_id' ), $_SERVER['REQUEST_URI'] ) ); ?>
|
66 |
+
</p></div>
|
67 |
+
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
?>
|
trunk/wpsc-admin/display-sales-logs.php
ADDED
@@ -0,0 +1,812 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP eCommerce edit and view sales page functions
|
4 |
+
*
|
5 |
+
* These are the main WPSC sales page functions
|
6 |
+
*
|
7 |
+
* @package wp-e-commerce
|
8 |
+
* @since 3.8.8
|
9 |
+
*/
|
10 |
+
|
11 |
+
class WPSC_Purchase_Log_Page {
|
12 |
+
|
13 |
+
private $list_table;
|
14 |
+
private $output;
|
15 |
+
private $cols = 0;
|
16 |
+
public $log_id = 0;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* WPSC_Purchase_Log
|
20 |
+
*
|
21 |
+
* @var WPSC_Purchase_Log object.
|
22 |
+
*/
|
23 |
+
public $log = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Whether the purchase log can be modified.
|
27 |
+
*
|
28 |
+
* @var boolean
|
29 |
+
*/
|
30 |
+
protected $can_edit = false;
|
31 |
+
|
32 |
+
public function __construct() {
|
33 |
+
$controller = 'default';
|
34 |
+
$controller_method = 'controller_default';
|
35 |
+
|
36 |
+
// If individual purchase log, setup ID and action links.
|
37 |
+
if ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) {
|
38 |
+
$this->log_id = (int) $_REQUEST['id'];
|
39 |
+
$this->log = new WPSC_Purchase_Log( $this->log_id );
|
40 |
+
$this->notes = new WPSC_Purchase_Log_Notes( $this->log );
|
41 |
+
$this->can_edit = $this->log->can_edit();
|
42 |
+
}
|
43 |
+
|
44 |
+
if ( isset( $_REQUEST['c'] ) && method_exists( $this, 'controller_' . $_REQUEST['c'] ) ) {
|
45 |
+
$controller = $_REQUEST['c'];
|
46 |
+
$controller_method = 'controller_' . $controller;
|
47 |
+
} elseif ( isset( $_REQUEST['id'] ) && is_numeric( $_REQUEST['id'] ) ) {
|
48 |
+
$controller = 'item_details';
|
49 |
+
$controller_method = 'controller_item_details';
|
50 |
+
}
|
51 |
+
|
52 |
+
// Can only edit in the item details view.
|
53 |
+
if ( 'controller_item_details' !== $controller_method ) {
|
54 |
+
$this->can_edit = false;
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->$controller_method();
|
58 |
+
}
|
59 |
+
|
60 |
+
private function needs_update() {
|
61 |
+
global $wpdb;
|
62 |
+
|
63 |
+
if ( get_option( '_wpsc_purchlogs_3.8_updated' ) ) {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
$c = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PURCHASE_LOGS . " WHERE plugin_version IN ('3.6', '3.7')" );
|
68 |
+
|
69 |
+
if ( $c > 0 ) {
|
70 |
+
return true;
|
71 |
+
}
|
72 |
+
|
73 |
+
update_option( '_wpsc_purchlogs_3.8_updated', true );
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function controller_upgrade_purchase_logs_3_7() {
|
78 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_upgrade_purchase_logs_3_7' ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
private function purchase_logs_fix_options( $id ) {
|
82 |
+
?>
|
83 |
+
<select name='<?php echo $id; ?>'>
|
84 |
+
<option value='-1'><?php echo esc_html_x( 'Select an Option', 'Dropdown default when called in uniquename dropdown', 'wp-e-commerce' ); ?></option>
|
85 |
+
<option value='billingfirstname'><?php esc_html_e( 'Billing First Name', 'wp-e-commerce' ); ?></option>
|
86 |
+
<option value='billinglastname'><?php esc_html_e( 'Billing Last Name', 'wp-e-commerce' ); ?></option>
|
87 |
+
<option value='billingaddress'><?php esc_html_e( 'Billing Address', 'wp-e-commerce' ); ?></option>
|
88 |
+
<option value='billingcity'><?php esc_html_e( 'Billing City', 'wp-e-commerce' ); ?></option>
|
89 |
+
<option value='billingstate'><?php esc_html_e( 'Billing State', 'wp-e-commerce' ); ?></option>
|
90 |
+
<option value='billingcountry'><?php esc_html_e( 'Billing Country', 'wp-e-commerce' ); ?></option>
|
91 |
+
<option value='billingemail'><?php esc_html_e( 'Billing Email', 'wp-e-commerce' ); ?></option>
|
92 |
+
<option value='billingphone'><?php esc_html_e( 'Billing Phone', 'wp-e-commerce' ); ?></option>
|
93 |
+
<option value='billingpostcode'><?php esc_html_e( 'Billing Post Code', 'wp-e-commerce' ); ?></option>
|
94 |
+
<option value='shippingfirstname'><?php esc_html_e( 'Shipping First Name', 'wp-e-commerce' ); ?></option>
|
95 |
+
<option value='shippinglastname'><?php esc_html_e( 'Shipping Last Name', 'wp-e-commerce' ); ?></option>
|
96 |
+
<option value='shippingaddress'><?php esc_html_e( 'Shipping Address', 'wp-e-commerce' ); ?></option>
|
97 |
+
<option value='shippingcity'><?php esc_html_e( 'Shipping City', 'wp-e-commerce' ); ?></option>
|
98 |
+
<option value='shippingstate'><?php esc_html_e( 'Shipping State', 'wp-e-commerce' ); ?></option>
|
99 |
+
<option value='shippingcountry'><?php esc_html_e( 'Shipping Country', 'wp-e-commerce' ); ?></option>
|
100 |
+
<option value='shippingpostcode'><?php esc_html_e( 'Shipping Post Code', 'wp-e-commerce' ); ?></option>
|
101 |
+
</select>
|
102 |
+
<?php
|
103 |
+
}
|
104 |
+
|
105 |
+
public function display_upgrade_purchase_logs_3_7() {
|
106 |
+
global $wpdb;
|
107 |
+
$numChanged = 0;
|
108 |
+
$numQueries = 0;
|
109 |
+
$purchlog = "SELECT DISTINCT id FROM `".WPSC_TABLE_PURCHASE_LOGS."` LIMIT 1";
|
110 |
+
$id = $wpdb->get_var($purchlog);
|
111 |
+
$usersql = "SELECT DISTINCT `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITTED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.log_id=".$id." ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`" ;
|
112 |
+
$formfields = $wpdb->get_results($usersql);
|
113 |
+
|
114 |
+
if(count($formfields) < 1){
|
115 |
+
$usersql = "SELECT DISTINCT `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `type` != 'heading'";
|
116 |
+
$formfields = $wpdb->get_results($usersql);
|
117 |
+
}
|
118 |
+
|
119 |
+
if(isset($_POST)){
|
120 |
+
foreach($_POST as $key=>$value){
|
121 |
+
if($value != '-1'){
|
122 |
+
$complete = $wpdb->update(
|
123 |
+
WPSC_TABLE_CHECKOUT_FORMS,
|
124 |
+
array(
|
125 |
+
'unique_name' => $value
|
126 |
+
),
|
127 |
+
array(
|
128 |
+
'id' => $key
|
129 |
+
),
|
130 |
+
'%s',
|
131 |
+
'%d'
|
132 |
+
);
|
133 |
+
}
|
134 |
+
$numChanged++;
|
135 |
+
$numQueries++;
|
136 |
+
}
|
137 |
+
|
138 |
+
$sql = "UPDATE `".WPSC_TABLE_CHECKOUT_FORMS."` SET `unique_name`='delivertoafriend' WHERE `name` = '2. Shipping details'";
|
139 |
+
$wpdb->query($sql);
|
140 |
+
|
141 |
+
add_option('wpsc_purchaselogs_fixed',true);
|
142 |
+
}
|
143 |
+
|
144 |
+
include( 'includes/purchase-logs-page/upgrade.php' );
|
145 |
+
}
|
146 |
+
|
147 |
+
public function display_upgrade_purchase_logs_3_8() {
|
148 |
+
?>
|
149 |
+
<div class="wrap">
|
150 |
+
<h2><?php echo esc_html( __('Sales', 'wp-e-commerce') ); ?> </h2>
|
151 |
+
<div class="updated">
|
152 |
+
<p><?php printf( __( 'Your purchase logs have been updated! <a href="%s">Click here</a> to return.' , 'wp-e-commerce' ), esc_url( remove_query_arg( 'c' ) ) ); ?></p>
|
153 |
+
</div>
|
154 |
+
</div>
|
155 |
+
<?php
|
156 |
+
}
|
157 |
+
|
158 |
+
public function controller_upgrade_purchase_logs_3_8() {
|
159 |
+
if ( $this->needs_update() ) {
|
160 |
+
wpsc_update_purchase_logs();
|
161 |
+
}
|
162 |
+
|
163 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_upgrade_purchase_logs_3_8' ) );
|
164 |
+
}
|
165 |
+
|
166 |
+
function purchase_logs_pagination() {
|
167 |
+
|
168 |
+
$prev_id = $this->log->get_previous_log_id();
|
169 |
+
$next_id = $this->log->get_next_log_id();
|
170 |
+
?>
|
171 |
+
<span class='tablenav'><span class='tablenav-logs'><span class='pagination-links'>
|
172 |
+
<?php if ( $prev_id ) : ?>
|
173 |
+
<a href='<?php echo esc_url( $this->get_purchase_log_url( $prev_id ) ); ?>' class='prev-page'>‹ <?php _e( 'Previous', 'wp-e-commerce' ); ?></a>
|
174 |
+
<?php endif; ?>
|
175 |
+
|
176 |
+
<?php if ( $next_id ) : ?>
|
177 |
+
<a href='<?php echo esc_url( $this->get_purchase_log_url( $next_id ) ); ?>' class='next-page'><?php _e( 'Next', 'wp-e-commerce' ); ?> ›</a>
|
178 |
+
<?php endif; ?>
|
179 |
+
</span></span></span>
|
180 |
+
<?php
|
181 |
+
}
|
182 |
+
|
183 |
+
public function purchase_logs_checkout_fields() {
|
184 |
+
global $purchlogitem;
|
185 |
+
|
186 |
+
foreach( (array) $purchlogitem->additional_fields as $value ) {
|
187 |
+
$value['value'] = maybe_unserialize( $value['value'] );
|
188 |
+
if ( is_array( $value['value'] ) ) {
|
189 |
+
?>
|
190 |
+
<p><strong><?php echo $value['name']; ?> :</strong> <?php echo implode( stripslashes( $value['value'] ), ',' ); ?></p>
|
191 |
+
<?php
|
192 |
+
} else {
|
193 |
+
$thevalue = esc_html( stripslashes( $value['value'] ));
|
194 |
+
if ( empty( $thevalue ) ) {
|
195 |
+
$thevalue = __( '<em>blank</em>', 'wp-e-commerce' );
|
196 |
+
}
|
197 |
+
?>
|
198 |
+
<p><strong><?php echo $value['name']; ?> :</strong> <?php echo $thevalue; ?></p>
|
199 |
+
<?php
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
public function purchase_log_custom_fields() {
|
205 |
+
$messages = wpsc_purchlogs_custommessages();
|
206 |
+
$files = wpsc_purchlogs_customfiles();
|
207 |
+
|
208 |
+
if ( count( $files ) > 0 ) { ?>
|
209 |
+
<h4><?php esc_html_e( 'Cart Items with Custom Files' , 'wp-e-commerce' ); ?>:</h4>
|
210 |
+
<?php
|
211 |
+
foreach( $files as $file ) {
|
212 |
+
echo $file;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
if ( count( $messages ) > 0 ) { ?>
|
216 |
+
<h4><?php esc_html_e( 'Cart Items with Custom Messages' , 'wp-e-commerce' ); ?>:</h4>
|
217 |
+
<?php
|
218 |
+
foreach( $messages as $message ) {
|
219 |
+
echo esc_html( $message['title'] ) . ':<br />' . nl2br( esc_html( $message['message'] ) );
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
public function items_ordered_box() {
|
225 |
+
?>
|
226 |
+
<?php do_action( 'wpsc_purchlogitem_metabox_start', $this->log_id ); ?>
|
227 |
+
|
228 |
+
<form name="wpsc_items_ordered_form" method="post">
|
229 |
+
<table class="widefat" cellspacing="0">
|
230 |
+
<thead>
|
231 |
+
<tr>
|
232 |
+
<?php
|
233 |
+
print_column_headers( 'wpsc_purchase_log_item_details' );
|
234 |
+
?>
|
235 |
+
</tr>
|
236 |
+
</thead>
|
237 |
+
|
238 |
+
<tbody>
|
239 |
+
<?php $this->purchase_log_cart_items(); ?>
|
240 |
+
|
241 |
+
<?php if ( $this->can_edit ) : ?>
|
242 |
+
<tr class="wpsc_purchaselog_add_product">
|
243 |
+
<td colspan="<?php echo $this->cols + 2; ?>">
|
244 |
+
<p class="wpsc-add-row">
|
245 |
+
<button type="button" class="wpsc-add-item-button button"><?php esc_html_e( 'Add Item', 'wp-e-commerce' ); ?></button>
|
246 |
+
</p>
|
247 |
+
</td>
|
248 |
+
</tr>
|
249 |
+
<?php endif; ?>
|
250 |
+
|
251 |
+
<tr class="wpsc_purchaselog_start_totals" id="wpsc_discount_data">
|
252 |
+
<td colspan="<?php echo $this->cols; ?>">
|
253 |
+
<?php if ( wpsc_purchlog_has_discount_data() ): ?>
|
254 |
+
<?php esc_html_e( 'Coupon Code', 'wp-e-commerce' ); ?>: <?php echo wpsc_display_purchlog_discount_data(); ?>
|
255 |
+
<?php endif; ?>
|
256 |
+
</td>
|
257 |
+
<th class='right-col'><?php esc_html_e( 'Discount', 'wp-e-commerce' ); ?> </th>
|
258 |
+
<td><?php echo wpsc_display_purchlog_discount(); ?></td>
|
259 |
+
</tr>
|
260 |
+
|
261 |
+
<?php if ( ! wpec_display_product_tax() ): ?>
|
262 |
+
<tr id="wpsc_total_taxes">
|
263 |
+
<td colspan='<?php echo $this->cols; ?>'></td>
|
264 |
+
<th class='right-col'><?php esc_html_e( 'Taxes', 'wp-e-commerce' ); ?> </th>
|
265 |
+
<td><?php echo wpsc_display_purchlog_taxes(); ?></td>
|
266 |
+
</tr>
|
267 |
+
<?php endif; ?>
|
268 |
+
|
269 |
+
<tr id="wpsc_total_shipping">
|
270 |
+
<td colspan='<?php echo $this->cols; ?>'></td>
|
271 |
+
<th class='right-col'><?php esc_html_e( 'Shipping', 'wp-e-commerce' ); ?> </th>
|
272 |
+
<td><?php echo wpsc_display_purchlog_shipping( false, true ); ?></td>
|
273 |
+
</tr>
|
274 |
+
<tr id="wpsc_final_total">
|
275 |
+
<td colspan='<?php echo $this->cols; ?>'></td>
|
276 |
+
<th class='right-col'><?php esc_html_e( 'Total', 'wp-e-commerce' ); ?> </th>
|
277 |
+
<td><span><?php echo wpsc_display_purchlog_totalprice(); ?></span> <div class="spinner"></div></td>
|
278 |
+
</tr>
|
279 |
+
|
280 |
+
<?php if ( wpsc_payment_gateway_supports( $this->log->get( 'gateway' ), 'refunds' ) ) : ?>
|
281 |
+
<tr>
|
282 |
+
<td colspan="<?php echo $this->cols + 2; ?>">
|
283 |
+
<p class="wpsc-add-row">
|
284 |
+
<button type="button" class="button refund-items"><?php _e( 'Refund', 'wp-e-commerce' ); ?></button>
|
285 |
+
</p>
|
286 |
+
</td>
|
287 |
+
</tr>
|
288 |
+
<tr class="wpsc-refund-ui">
|
289 |
+
<td colspan="<?php echo $this->cols + 2; ?>">
|
290 |
+
<table>
|
291 |
+
<tbody>
|
292 |
+
<tr>
|
293 |
+
<td class="label"><?php _e( 'Amount already refunded', 'wp-e-commerce' ); ?>:</td>
|
294 |
+
<td class="total"><?php echo wpsc_currency_display( $this->log->get_total_refunded() );?></td>
|
295 |
+
</tr>
|
296 |
+
<?php if ( wpsc_payment_gateway_supports( $this->log->get( 'gateway' ), 'partial-refunds' ) ) : ?>
|
297 |
+
<tr>
|
298 |
+
<td class="label"><label for="refund_amount"><?php _e( 'Refund amount', 'wp-e-commerce' ); ?>:</label></td>
|
299 |
+
<td class="total">
|
300 |
+
<input type="text" class="text" id="refund_amount" name="refund_amount" class="wpec_input_price" />
|
301 |
+
<div class="clear"></div>
|
302 |
+
</td>
|
303 |
+
</tr>
|
304 |
+
<?php endif; ?>
|
305 |
+
<tr>
|
306 |
+
<td class="label"><label for="refund_reason"><?php _e( 'Reason for refund (optional)', 'wp-e-commerce' ); ?>:</label></td>
|
307 |
+
<td class="total">
|
308 |
+
<input type="text" class="text" id="refund_reason" name="refund_reason" />
|
309 |
+
<div class="clear"></div>
|
310 |
+
</td>
|
311 |
+
</tr>
|
312 |
+
<tr>
|
313 |
+
<td>
|
314 |
+
<p>
|
315 |
+
<button type="button" class="button tips button-primary do-api-refund"><?php printf( __( 'Refund via %s', 'wp-e-commerce' ), wpsc_get_payment_gateway( $this->log->get( 'gateway' ) )->get_title() ); ?></button>
|
316 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
317 |
+
<button type="button" class="button button-secondary do-manual-refund tips"><?php _e( 'Manual Refund', 'wp-e-commerce' ); ?></button>
|
318 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
319 |
+
</p>
|
320 |
+
</td>
|
321 |
+
</tbody>
|
322 |
+
</table>
|
323 |
+
</td>
|
324 |
+
</tr>
|
325 |
+
<?php endif; ?>
|
326 |
+
</tbody>
|
327 |
+
</table>
|
328 |
+
|
329 |
+
</form>
|
330 |
+
|
331 |
+
<?php do_action( 'wpsc_purchlogitem_metabox_end', $this->log_id ); ?>
|
332 |
+
|
333 |
+
<?php
|
334 |
+
}
|
335 |
+
|
336 |
+
public function purch_notes_box() {
|
337 |
+
?>
|
338 |
+
<div class="wpsc-notes">
|
339 |
+
<?php $this->notes_output(); ?>
|
340 |
+
</div>
|
341 |
+
<form method="post" action="" id="note-submit-form">
|
342 |
+
<?php wp_nonce_field( 'wpsc_log_add_notes_nonce', 'wpsc_log_add_notes_nonce' ); ?>
|
343 |
+
<input type='hidden' name='purchlog_id' value='<?php echo $this->log_id; ?>' />
|
344 |
+
<p>
|
345 |
+
<?php wp_editor( '', 'purchlog_notes', array(
|
346 |
+
'textarea_name' => 'purchlog_notes',
|
347 |
+
'textarea_rows' => 3,
|
348 |
+
'teeny' => true,
|
349 |
+
'tinymce' => false,
|
350 |
+
'media_buttons' => false,
|
351 |
+
) ); ?>
|
352 |
+
</p>
|
353 |
+
<div class="note-submit">
|
354 |
+
<input class="button" type="submit" value="<?php _e( 'Add Note', 'wp-e-commerce' ); ?>" />
|
355 |
+
<div class="spinner"></div>
|
356 |
+
</div>
|
357 |
+
</form>
|
358 |
+
<?php
|
359 |
+
}
|
360 |
+
|
361 |
+
private function edit_contact_details_form() {
|
362 |
+
$args = wpsc_get_customer_settings_form_args( $this->log->form_data() );
|
363 |
+
$args['form_actions'][0]['class'] = 'button';
|
364 |
+
$args['form_actions'][0]['title'] = __( 'Update', 'wp-e-commerce' );
|
365 |
+
echo wpsc_get_form_output( $args );
|
366 |
+
}
|
367 |
+
|
368 |
+
private function purchase_log_cart_items() {
|
369 |
+
while( wpsc_have_purchaselog_details() ) : wpsc_the_purchaselog_item();
|
370 |
+
self::purchase_log_cart_item( $this->can_edit );
|
371 |
+
endwhile;
|
372 |
+
}
|
373 |
+
|
374 |
+
public static function purchase_log_cart_item( $can_edit = false ) {
|
375 |
+
?>
|
376 |
+
<tr class="purchase-log-line-item" id="purchase-log-item-<?php echo wpsc_purchaselog_details_id(); ?>" data-id="<?php echo wpsc_purchaselog_details_id(); ?>" data-productid="<?php echo wpsc_purchaselog_product_id(); ?>">
|
377 |
+
<td><?php echo wpsc_purchaselog_details_name(); ?></td> <!-- NAME! -->
|
378 |
+
<td><?php echo wpsc_purchaselog_details_SKU(); ?></td> <!-- SKU! -->
|
379 |
+
<td>
|
380 |
+
<?php if ( $can_edit ) : ?>
|
381 |
+
<input type="number" step="1" min="0" autocomplete="off" name="wpsc_item_qty" class="wpsc_item_qty" placeholder="0" value="<?php echo wpsc_purchaselog_details_quantity(); ?>" size="4" class="quantity">
|
382 |
+
<?php else: ?>
|
383 |
+
<?php echo wpsc_purchaselog_details_quantity(); ?>
|
384 |
+
<?php endif; ?>
|
385 |
+
</td> <!-- QUANTITY! -->
|
386 |
+
<td>
|
387 |
+
<?php
|
388 |
+
echo wpsc_currency_display( wpsc_purchaselog_details_price() );
|
389 |
+
do_action( 'wpsc_additional_sales_amount_info', wpsc_purchaselog_details_id() );
|
390 |
+
?>
|
391 |
+
</td> <!-- PRICE! -->
|
392 |
+
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_shipping() ); ?></td> <!-- SHIPPING! -->
|
393 |
+
<?php if( wpec_display_product_tax() ): ?>
|
394 |
+
<td><?php echo wpsc_currency_display( wpsc_purchaselog_details_tax() ); ?></td> <!-- TAX! -->
|
395 |
+
<?php endif; ?>
|
396 |
+
<!-- <td><?php echo wpsc_currency_display( wpsc_purchaselog_details_discount() ); ?></td> --> <!-- DISCOUNT! -->
|
397 |
+
<td class="amount"><?php echo wpsc_currency_display( wpsc_purchaselog_details_total() ); ?></td> <!-- TOTAL! -->
|
398 |
+
<?php if ( $can_edit ) : ?>
|
399 |
+
<td class="remove">
|
400 |
+
<div class="wpsc-remove-row">
|
401 |
+
<button type="button" class="wpsc-remove-button wpsc-remove-item-button"><span class="dashicons dashicons-dismiss"></span> <?php esc_html_e( 'Remove Item', 'wp-e-commerce' ); ?></button>
|
402 |
+
</div>
|
403 |
+
</td> <!-- REMOVE! -->
|
404 |
+
<?php endif; ?>
|
405 |
+
</tr>
|
406 |
+
<?php
|
407 |
+
do_action( 'wpsc_additional_sales_item_info', wpsc_purchaselog_details_id() );
|
408 |
+
}
|
409 |
+
|
410 |
+
public function notes_output() {
|
411 |
+
|
412 |
+
foreach ( $this->notes as $note_id => $note_args ) : ?>
|
413 |
+
<?php self::note_output( $this->notes, $note_id, $note_args ); ?>
|
414 |
+
<?php endforeach;
|
415 |
+
}
|
416 |
+
|
417 |
+
public static function note_output( WPSC_Purchase_Log_Notes $notes, $note_id, array $note_args ) {
|
418 |
+
?>
|
419 |
+
<div class="wpsc-note" id="wpsc-note-<?php echo absint( $note_id ); ?>" data-id="<?php echo absint( $note_id ); ?>">
|
420 |
+
<p>
|
421 |
+
<strong class="note-date"><?php echo $notes->get_formatted_date( $note_args ); ?></strong>
|
422 |
+
<a href="#wpsc-note-<?php echo absint( $note_id ); ?>" class="note-number">#<?php echo ( $note_id ); ?></a>
|
423 |
+
<a href="<?php echo wp_nonce_url( add_query_arg( 'note', absint( $note_id ) ), 'delete-note', 'delete-note' ); ?>" class="wpsc-remove-button wpsc-remove-note-button"><span class="dashicons dashicons-dismiss"></span> <?php esc_html_e( 'Delete Note', 'wp-e-commerce' ); ?></a>
|
424 |
+
</p>
|
425 |
+
<div class="wpsc-note-content">
|
426 |
+
<?php echo wpautop( $note_args['content'] ); ?>
|
427 |
+
</div>
|
428 |
+
</div>
|
429 |
+
<?php
|
430 |
+
}
|
431 |
+
|
432 |
+
public static function shipping_address_output() {
|
433 |
+
?>
|
434 |
+
<strong>
|
435 |
+
<?php echo ( wpsc_display_purchlog_shipping_name() != "" ) ? wpsc_display_purchlog_shipping_name() . "<br />" : '<span class="field-blank">' . __( 'Anonymous', 'wp-e-commerce' ) . '</span>' ; ?>
|
436 |
+
</strong>
|
437 |
+
<?php echo ( wpsc_display_purchlog_shipping_address() != "" ) ? wpsc_display_purchlog_shipping_address() . "<br />" : '' ; ?>
|
438 |
+
<?php echo ( wpsc_display_purchlog_shipping_city() != "" ) ? wpsc_display_purchlog_shipping_city() . ", " : '' ; ?>
|
439 |
+
<?php echo ( wpsc_display_purchlog_shipping_state_and_postcode() != "" ) ? wpsc_display_purchlog_shipping_state_and_postcode() . "<br />" : '' ; ?>
|
440 |
+
<?php echo ( wpsc_display_purchlog_shipping_country() != "" ) ? wpsc_display_purchlog_shipping_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wp-e-commerce' ) . '</span>' ; ?>
|
441 |
+
<?php
|
442 |
+
}
|
443 |
+
|
444 |
+
public static function billing_address_output() {
|
445 |
+
?>
|
446 |
+
<strong>
|
447 |
+
<?php echo ( wpsc_display_purchlog_buyers_name() != "" ) ? wpsc_display_purchlog_buyers_name() . "<br />" : '<span class="field-blank">' . __( 'Anonymous', 'wp-e-commerce' ) . '</span>' ; ?>
|
448 |
+
</strong>
|
449 |
+
<?php echo ( wpsc_display_purchlog_buyers_address() != "" ) ? wpsc_display_purchlog_buyers_address() . "<br />" : '' ; ?>
|
450 |
+
<?php echo ( wpsc_display_purchlog_buyers_city() != "" ) ? wpsc_display_purchlog_buyers_city() . ", " : '' ; ?>
|
451 |
+
<?php echo ( wpsc_display_purchlog_buyers_state_and_postcode() != "" ) ? wpsc_display_purchlog_buyers_state_and_postcode() . "<br />" : '' ; ?>
|
452 |
+
<?php echo ( wpsc_display_purchlog_buyers_country() != "" ) ? wpsc_display_purchlog_buyers_country() . "<br />" : '<span class="field-blank">' . __( 'Country not specified', 'wp-e-commerce' ) . '</span>' ; ?>
|
453 |
+
<?php
|
454 |
+
}
|
455 |
+
|
456 |
+
public static function payment_details_output() {
|
457 |
+
?>
|
458 |
+
<strong><?php esc_html_e( 'Phone:', 'wp-e-commerce' ); ?> </strong><?php echo ( wpsc_display_purchlog_buyers_phone() != "" ) ? wpsc_display_purchlog_buyers_phone() : __( '<em class="field-blank">not provided</em>', 'wp-e-commerce' ); ?><br />
|
459 |
+
<strong><?php esc_html_e( 'Email:', 'wp-e-commerce' ); ?> </strong>
|
460 |
+
<a href="mailto:<?php echo wpsc_display_purchlog_buyers_email(); ?>?subject=<?php echo rawurlencode( sprintf( __( 'Message from %s', 'wp-e-commerce' ), site_url() ) ); ?>">
|
461 |
+
<?php echo ( wpsc_display_purchlog_buyers_email() != "" ) ? wpsc_display_purchlog_buyers_email() : __( '<em class="field-blank">not provided</em>', 'wp-e-commerce' ); ?>
|
462 |
+
</a>
|
463 |
+
<br />
|
464 |
+
<strong><?php esc_html_e( 'Payment Method:', 'wp-e-commerce' ); ?> </strong><?php echo wpsc_display_purchlog_paymentmethod(); ?><br />
|
465 |
+
<?php if ( wpsc_display_purchlog_display_howtheyfoundus() ) : ?>
|
466 |
+
<strong><?php esc_html_e( 'How User Found Us:', 'wp-e-commerce' ); ?> </strong><?php echo wpsc_display_purchlog_howtheyfoundus(); ?><br />
|
467 |
+
<?php endif; ?>
|
468 |
+
<?php
|
469 |
+
}
|
470 |
+
|
471 |
+
public function controller_item_details() {
|
472 |
+
if (
|
473 |
+
! isset( $_REQUEST['id'] )
|
474 |
+
|| ( isset( $_REQUEST['id'] ) && ! is_numeric( $_REQUEST['id'] ) )
|
475 |
+
|| ! $this->log->exists()
|
476 |
+
) {
|
477 |
+
wp_die( __( 'Invalid sales log ID', 'wp-e-commerce' ) );
|
478 |
+
}
|
479 |
+
|
480 |
+
if ( isset( $_POST['wpsc_checkout_details'], $_POST['_wp_nonce'] ) ) {
|
481 |
+
self::maybe_update_contact_details_for_log( $this->log, wp_unslash( $_POST['wpsc_checkout_details'] ) );
|
482 |
+
}
|
483 |
+
|
484 |
+
if ( isset( $_POST['wpsc_log_add_notes_nonce'], $_POST['purchlog_notes'] ) ) {
|
485 |
+
self::maybe_add_note_to_log( $this->log, wp_unslash( $_POST['purchlog_notes'] ) );
|
486 |
+
}
|
487 |
+
|
488 |
+
if ( isset( $_REQUEST['delete-note'], $_REQUEST['note'] ) ) {
|
489 |
+
self::maybe_delete_note_from_log( $this->log, absint( $_REQUEST['note'] ) );
|
490 |
+
}
|
491 |
+
|
492 |
+
$this->log->init_items();
|
493 |
+
|
494 |
+
$columns = array(
|
495 |
+
'title' => __( 'Name', 'wp-e-commerce' ),
|
496 |
+
'sku' => __( 'SKU', 'wp-e-commerce' ),
|
497 |
+
'quantity' => __( 'Quantity','wp-e-commerce' ),
|
498 |
+
'price' => __( 'Price', 'wp-e-commerce' ),
|
499 |
+
'shipping' => __( 'Item Shipping', 'wp-e-commerce'),
|
500 |
+
);
|
501 |
+
|
502 |
+
if ( wpec_display_product_tax() ) {
|
503 |
+
$columns['tax'] = __( 'Item Tax', 'wp-e-commerce' );
|
504 |
+
}
|
505 |
+
|
506 |
+
$columns['total'] = __( 'Item Total','wp-e-commerce' );
|
507 |
+
|
508 |
+
if ( $this->can_edit ) {
|
509 |
+
$columns['remove'] = '';
|
510 |
+
|
511 |
+
$this->include_te_v2_resources();
|
512 |
+
$this->enqueue_te_v2_resources();
|
513 |
+
}
|
514 |
+
|
515 |
+
add_filter( 'admin_title', array( $this, 'doc_title' ), 10, 2 );
|
516 |
+
|
517 |
+
register_column_headers( 'wpsc_purchase_log_item_details', $columns );
|
518 |
+
|
519 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_purchase_log' ) );
|
520 |
+
add_action( 'wpsc_purchlog_before_metaboxes' , array( $this, 'register_metaboxes' ) );
|
521 |
+
}
|
522 |
+
|
523 |
+
public function register_metaboxes() {
|
524 |
+
global $purchlogitem;
|
525 |
+
|
526 |
+
add_meta_box( 'wpsc_items_ordered', esc_html__( 'Items Ordered' , 'wp-e-commerce' ), array( $this, 'items_ordered_box' ), get_current_screen()->id, 'normal' );
|
527 |
+
|
528 |
+
add_meta_box( 'purchlogs_notes', esc_html__( 'Order Notes' , 'wp-e-commerce' ), array( $this, 'purch_notes_box' ), get_current_screen()->id, 'low' );
|
529 |
+
|
530 |
+
if ( wpsc_purchlogs_has_customfields() ) {
|
531 |
+
add_meta_box( 'purchlogs_customfields', esc_html__( 'Users Custom Fields' , 'wp-e-commerce' ), array( $this, 'purchase_log_custom_fields' ), get_current_screen()->id, 'normal' );
|
532 |
+
}
|
533 |
+
|
534 |
+
if ( ! empty( $purchlogitem->additional_fields ) ) {
|
535 |
+
add_meta_box( 'custom_checkout_fields', esc_html__( 'Additional Checkout Fields' , 'wp-e-commerce' ), array( $this, 'purchase_logs_checkout_fields' ), get_current_screen()->id, 'normal' );
|
536 |
+
}
|
537 |
+
|
538 |
+
do_action( 'wpsc_purchase_logs_register_metaboxes', get_current_screen(), $this );
|
539 |
+
}
|
540 |
+
|
541 |
+
public static function maybe_update_contact_details_for_log( WPSC_Purchase_Log $log, $details ) {
|
542 |
+
if ( is_array( $details ) ) {
|
543 |
+
|
544 |
+
check_admin_referer( 'wpsc-customer-settings-form', '_wp_nonce' );
|
545 |
+
|
546 |
+
return WPSC_Checkout_Form_Data::save_form(
|
547 |
+
$log,
|
548 |
+
WPSC_Checkout_Form::get()->get_fields(),
|
549 |
+
array_map( 'sanitize_text_field', $details ),
|
550 |
+
false
|
551 |
+
);
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
/**
|
556 |
+
* Update Purchase Log Notes
|
557 |
+
*
|
558 |
+
* @param WPSC_Purchase_Log $log log object.
|
559 |
+
*/
|
560 |
+
public static function maybe_add_note_to_log( WPSC_Purchase_Log $log, $note ) {
|
561 |
+
if ( $note ) {
|
562 |
+
check_admin_referer( 'wpsc_log_add_notes_nonce', 'wpsc_log_add_notes_nonce' );
|
563 |
+
|
564 |
+
wpsc_purchlogs_update_notes( $log, wp_kses_post( $note ) );
|
565 |
+
|
566 |
+
wp_safe_redirect( esc_url_raw( remove_query_arg( 'wpsc_log_add_notes_nonce' ) ) );
|
567 |
+
exit;
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
public static function maybe_delete_note_from_log( WPSC_Purchase_Log $log, $note_id ) {
|
572 |
+
if ( is_numeric( $note_id ) ) {
|
573 |
+
check_admin_referer( 'delete-note', 'delete-note' );
|
574 |
+
|
575 |
+
$notes = new WPSC_Purchase_Log_Notes( $log );
|
576 |
+
|
577 |
+
$notes->remove( $note_id )->save();
|
578 |
+
|
579 |
+
wp_safe_redirect( esc_url_raw( remove_query_arg( 'delete-note', remove_query_arg( 'note' ) ) ) . '#purchlogs_notes' );
|
580 |
+
exit;
|
581 |
+
}
|
582 |
+
}
|
583 |
+
|
584 |
+
public function include_te_v2_resources() {
|
585 |
+
if ( ! defined( 'WPSC_TE_V2_CLASSES_PATH' ) ) {
|
586 |
+
require_once WPSC_FILE_PATH . '/wpsc-components/theme-engine-v2/core.php';
|
587 |
+
_wpsc_te_v2_includes();
|
588 |
+
}
|
589 |
+
|
590 |
+
require_once( WPSC_TE_V2_CLASSES_PATH . '/message-collection.php' );
|
591 |
+
require_once( WPSC_TE_V2_HELPERS_PATH . '/message-collection.php' );
|
592 |
+
require_once( WPSC_TE_V2_HELPERS_PATH . '/template-tags/form.php' );
|
593 |
+
}
|
594 |
+
|
595 |
+
public function enqueue_te_v2_resources() {
|
596 |
+
_wpsc_te2_register_styles();
|
597 |
+
wp_enqueue_style( 'wpsc-common' );
|
598 |
+
|
599 |
+
$engine = WPSC_Template_Engine::get_instance();
|
600 |
+
$scripts = $engine->get_core_scripts_data();
|
601 |
+
$to_enqueue = array(
|
602 |
+
'wpsc-select-autocomplete',
|
603 |
+
'wpsc-country-region',
|
604 |
+
'wpsc-copy-billing-info'
|
605 |
+
);
|
606 |
+
|
607 |
+
foreach ( $to_enqueue as $handle ) {
|
608 |
+
wp_register_script(
|
609 |
+
$handle,
|
610 |
+
WPSC_TE_V2_URL . '/theming/assets/' . $scripts[ $handle ]['path'],
|
611 |
+
$scripts[ $handle ]['dependencies'],
|
612 |
+
$scripts[ $handle ]['version'],
|
613 |
+
true
|
614 |
+
);
|
615 |
+
wpsc_enqueue_script( $handle );
|
616 |
+
}
|
617 |
+
|
618 |
+
wp_localize_script( 'wpsc-copy-billing-info', 'WPSC', array(
|
619 |
+
'is_admin' => true,
|
620 |
+
) );
|
621 |
+
|
622 |
+
_wpsc_action_enqueue_shipping_billing_scripts();
|
623 |
+
|
624 |
+
foreach ( $engine->get_queued_scripts() as $handle => $data ) {
|
625 |
+
_wpsc_enqueue_and_localize_script( $handle, $data );
|
626 |
+
}
|
627 |
+
}
|
628 |
+
|
629 |
+
public function doc_title( $admin_title, $title ) {
|
630 |
+
/* translators: #%d represents the sales log id. */
|
631 |
+
$this_title = sprintf( esc_html__( 'Sales Log #%d', 'wp-e-commerce' ), $this->log_id );
|
632 |
+
$admin_title = str_replace( $title, $this_title, $admin_title );
|
633 |
+
|
634 |
+
return $admin_title;
|
635 |
+
}
|
636 |
+
|
637 |
+
public function controller_packing_slip() {
|
638 |
+
if ( ! isset( $_REQUEST['id'] ) || ( isset( $_REQUEST['id'] ) && ! is_numeric( $_REQUEST['id'] ) ) ) {
|
639 |
+
wp_die( __( 'Invalid sales log ID', 'wp-e-commerce' ) );
|
640 |
+
}
|
641 |
+
|
642 |
+
$this->log->init_items();
|
643 |
+
|
644 |
+
$columns = array(
|
645 |
+
'title' => __( 'Item Name', 'wp-e-commerce' ),
|
646 |
+
'sku' => __( 'SKU', 'wp-e-commerce' ),
|
647 |
+
'quantity' => __( 'Quantity', 'wp-e-commerce' ),
|
648 |
+
'price' => __( 'Price', 'wp-e-commerce' ),
|
649 |
+
'shipping' => __( 'Item Shipping','wp-e-commerce' ),
|
650 |
+
);
|
651 |
+
|
652 |
+
if ( wpec_display_product_tax() ) {
|
653 |
+
$columns['tax'] = __( 'Item Tax', 'wp-e-commerce' );
|
654 |
+
}
|
655 |
+
|
656 |
+
$columns['total'] = __( 'Item Total','wp-e-commerce' );
|
657 |
+
|
658 |
+
$this->cols = count( $columns ) - 2;
|
659 |
+
|
660 |
+
register_column_headers( 'wpsc_purchase_log_item_details', $columns );
|
661 |
+
|
662 |
+
if ( file_exists( get_stylesheet_directory() . '/wpsc-packing-slip.php' ) ) {
|
663 |
+
$packing_slip_file = get_stylesheet_directory() . '/wpsc-packing-slip.php';
|
664 |
+
} else {
|
665 |
+
$packing_slip_file = 'includes/purchase-logs-page/packing-slip.php';
|
666 |
+
}
|
667 |
+
|
668 |
+
$packing_slip_file = apply_filters( 'wpsc_packing_packing_slip_path', $packing_slip_file );
|
669 |
+
|
670 |
+
include( $packing_slip_file );
|
671 |
+
|
672 |
+
exit;
|
673 |
+
}
|
674 |
+
|
675 |
+
public function controller_default() {
|
676 |
+
// Create an instance of our package class...
|
677 |
+
$this->list_table = new WPSC_Purchase_Log_List_Table();
|
678 |
+
$this->process_bulk_action();
|
679 |
+
$this->list_table->prepare_items();
|
680 |
+
add_action( 'wpsc_display_purchase_logs_page', array( $this, 'display_list_table' ) );
|
681 |
+
}
|
682 |
+
|
683 |
+
public function display_purchase_log() {
|
684 |
+
$this->cols = 4;
|
685 |
+
if ( wpec_display_product_tax() ) {
|
686 |
+
$this->cols++;
|
687 |
+
}
|
688 |
+
|
689 |
+
if ( $this->can_edit ) {
|
690 |
+
$this->cols++;
|
691 |
+
}
|
692 |
+
|
693 |
+
$receipt_sent = ! empty( $_GET['sent'] );
|
694 |
+
$receipt_not_sent = isset( $_GET['sent'] ) && ! $_GET['sent'];
|
695 |
+
include( 'includes/purchase-logs-page/item-details.php' );
|
696 |
+
|
697 |
+
global $wp_scripts;
|
698 |
+
|
699 |
+
wp_enqueue_script( 'wp-backbone' );
|
700 |
+
|
701 |
+
if ( isset( $wp_scripts->registered['wp-e-commerce-purchase-logs'] ) ) {
|
702 |
+
// JS needed for modal
|
703 |
+
$wp_scripts->registered['wp-e-commerce-purchase-logs']->deps[] = 'wp-backbone';
|
704 |
+
}
|
705 |
+
|
706 |
+
add_action( 'admin_footer', 'find_posts_div' );
|
707 |
+
}
|
708 |
+
|
709 |
+
public function download_csv() {
|
710 |
+
_wpsc_download_purchase_log_csv();
|
711 |
+
}
|
712 |
+
|
713 |
+
public function process_bulk_action() {
|
714 |
+
global $wpdb;
|
715 |
+
$current_action = $this->list_table->current_action();
|
716 |
+
|
717 |
+
do_action( 'wpsc_sales_log_process_bulk_action', $current_action );
|
718 |
+
|
719 |
+
if ( ! $current_action || ( 'download_csv' != $current_action && empty( $_REQUEST['post'] ) ) ) {
|
720 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
721 |
+
wp_redirect( esc_url_raw( remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'action', 'action2' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ) );
|
722 |
+
exit;
|
723 |
+
}
|
724 |
+
|
725 |
+
unset( $_REQUEST['post'] );
|
726 |
+
return;
|
727 |
+
}
|
728 |
+
|
729 |
+
if ( 'download_csv' == $current_action ) {
|
730 |
+
$this->download_csv();
|
731 |
+
}
|
732 |
+
|
733 |
+
$sendback = remove_query_arg( array(
|
734 |
+
'_wpnonce',
|
735 |
+
'_wp_http_referer',
|
736 |
+
'action',
|
737 |
+
'action2',
|
738 |
+
'confirm',
|
739 |
+
'post',
|
740 |
+
'last_paged'
|
741 |
+
) );
|
742 |
+
|
743 |
+
if ( 'delete' == $current_action ) {
|
744 |
+
|
745 |
+
// delete action
|
746 |
+
if ( empty( $_REQUEST['confirm'] ) ) {
|
747 |
+
$this->list_table->disable_search_box();
|
748 |
+
$this->list_table->disable_bulk_actions();
|
749 |
+
$this->list_table->disable_sortable();
|
750 |
+
$this->list_table->disable_month_filter();
|
751 |
+
$this->list_table->disable_views();
|
752 |
+
$this->list_table->set_per_page(0);
|
753 |
+
add_action( 'wpsc_purchase_logs_list_table_before', array( $this, 'action_list_table_before' ) );
|
754 |
+
return;
|
755 |
+
} else {
|
756 |
+
if ( empty( $_REQUEST['post'] ) )
|
757 |
+
return;
|
758 |
+
|
759 |
+
$ids = array_map( 'intval', $_REQUEST['post'] );
|
760 |
+
|
761 |
+
foreach ( $ids as $id ) {
|
762 |
+
$log = new WPSC_Purchase_Log( $id );
|
763 |
+
$log->delete();
|
764 |
+
}
|
765 |
+
|
766 |
+
$sendback = add_query_arg( array(
|
767 |
+
'paged' => $_REQUEST['last_paged'],
|
768 |
+
'deleted' => count( $_REQUEST['post'] ),
|
769 |
+
), $sendback );
|
770 |
+
|
771 |
+
}
|
772 |
+
}
|
773 |
+
|
774 |
+
// change status actions
|
775 |
+
if ( is_numeric( $current_action ) && ! empty( $_REQUEST['post'] ) ) {
|
776 |
+
|
777 |
+
foreach ( $_REQUEST['post'] as $id )
|
778 |
+
wpsc_purchlog_edit_status( $id, $current_action );
|
779 |
+
|
780 |
+
$sendback = add_query_arg( array(
|
781 |
+
'updated' => count( $_REQUEST['post'] ),
|
782 |
+
), $sendback );
|
783 |
+
}
|
784 |
+
|
785 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
786 |
+
exit;
|
787 |
+
}
|
788 |
+
|
789 |
+
public function action_list_table_before() {
|
790 |
+
include( 'includes/purchase-logs-page/bulk-delete-confirm.php' );
|
791 |
+
}
|
792 |
+
|
793 |
+
public function display_list_table() {
|
794 |
+
if ( ! empty( $this->output ) ) {
|
795 |
+
echo $this->output;
|
796 |
+
return;
|
797 |
+
}
|
798 |
+
|
799 |
+
include( 'includes/purchase-logs-page/list-table.php' );
|
800 |
+
}
|
801 |
+
|
802 |
+
private function get_purchase_log_url( $id ) {
|
803 |
+
$location = add_query_arg( array(
|
804 |
+
'page' => 'wpsc-purchase-logs',
|
805 |
+
'c' => 'item_details',
|
806 |
+
'id' => $id,
|
807 |
+
), admin_url( 'index.php' ) );
|
808 |
+
|
809 |
+
return esc_url( $location );
|
810 |
+
}
|
811 |
+
|
812 |
+
}
|
trunk/wpsc-admin/display-update.page.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP eCommerce database updating page functions
|
4 |
+
*
|
5 |
+
* These are the main WPSC Admin functions
|
6 |
+
*
|
7 |
+
* @package wp-e-commerce
|
8 |
+
* @since 3.8
|
9 |
+
*/
|
10 |
+
|
11 |
+
global $wpdb,$wp_version;
|
12 |
+
$show_update_page = 1;
|
13 |
+
|
14 |
+
// if there's nothing in the children variation cache, refresh it, just to make sure.
|
15 |
+
if ( 0 == count( get_option( 'wpsc-variation_children' ) ) ) {
|
16 |
+
delete_option( 'wpsc-variation_children' );
|
17 |
+
_get_term_hierarchy( 'wpsc-variation' );
|
18 |
+
}
|
19 |
+
|
20 |
+
// if there's nothing in the children variation cache, refresh it, just to make sure.
|
21 |
+
if ( 0 == count( get_option( 'wpsc_product_category_children' ) ) ) {
|
22 |
+
delete_option( 'wpsc_product_category_children' );
|
23 |
+
_get_term_hierarchy( 'wpsc_product_category_children' );
|
24 |
+
}
|
25 |
+
|
26 |
+
$wpsc_version = get_option( 'wpsc_version', '0' );
|
27 |
+
|
28 |
+
// If database is already updated, then no need to update
|
29 |
+
if ( ! get_option( 'wpsc_needs_update', false ) ) {
|
30 |
+
$show_update_page = 0;
|
31 |
+
} else {
|
32 |
+
|
33 |
+
$table_exists = $wpdb->get_var( "SHOW TABLES LIKE '" . WPSC_TABLE_PRODUCT_LIST . "'" );
|
34 |
+
$product_count = empty( $table_exists ) ? 0 : $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST );
|
35 |
+
|
36 |
+
if ( $product_count > 0 ) {
|
37 |
+
|
38 |
+
function wpsc_display_update_notice() {
|
39 |
+
echo "<div id='wpsc-warning' class='error fade'><p><strong>" . __( 'WP eCommerce is almost ready.', 'wp-e-commerce' ) . "</strong> " . sprintf( __( 'You must <a href="%1$s">update your database</a> to import all of your products.', 'wp-e-commerce' ), "admin.php?page=wpsc-update") . "</p></div>";
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'wpsc-update' )
|
43 |
+
add_action( 'admin_notices', 'wpsc_display_update_notice' );
|
44 |
+
|
45 |
+
// There weren't any products, so mark the update as complete
|
46 |
+
} else {
|
47 |
+
update_option( 'wpsc_version', WPSC_VERSION );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Throw a warning if the PHP version is not compatible with WP e-Commerce
|
53 |
+
*
|
54 |
+
* @since 3.8
|
55 |
+
*/
|
56 |
+
function wpsc_display_php_version_notice() {
|
57 |
+
?>
|
58 |
+
<div id='wpsc-warning' class='error fade'><p><?php printf( __( 'You are using PHP %s. WP eCommerce %s requires PHP 5.0 or above. Please contact your hosting provider for further assistance.', 'wp-e-commerce' ), PHP_VERSION, WPSC_VERSION ); ?></p></div>
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Display the "Update WP e-Commerce page"
|
64 |
+
*/
|
65 |
+
function wpsc_display_update_page() {
|
66 |
+
global $wpdb;
|
67 |
+
?>
|
68 |
+
|
69 |
+
<div class="wrap">
|
70 |
+
<h2><?php esc_html_e( 'Update WP eCommerce', 'wp-e-commerce' ); ?> </h2>
|
71 |
+
<br />
|
72 |
+
<?php
|
73 |
+
if ( isset( $_REQUEST['run_updates'] ) ) :
|
74 |
+
ob_implicit_flush( true );
|
75 |
+
$wpsc_update = WPSC_Update::get_instance();
|
76 |
+
$update_stages = array(
|
77 |
+
'convert_category_groups' => __( 'Updating Categories...' , 'wp-e-commerce' ),
|
78 |
+
'convert_variation_sets' => __( 'Updating Variations...' , 'wp-e-commerce' ),
|
79 |
+
'convert_products_to_posts' => __( 'Updating Products ...' , 'wp-e-commerce' ),
|
80 |
+
'convert_variation_combinations' => __( 'Updating Child Products...', 'wp-e-commerce' ),
|
81 |
+
'update_files' => __( 'Updating Product Files...' , 'wp-e-commerce' ),
|
82 |
+
'update_purchase_logs' => __( 'Updating Purchase Logs... ', 'wp-e-commerce' ),
|
83 |
+
'create_or_update_tables' => __( 'Updating Database...' , 'wp-e-commerce' ),
|
84 |
+
'update_database' => '',
|
85 |
+
);
|
86 |
+
|
87 |
+
foreach ( $update_stages as $function => $message ) {
|
88 |
+
$wpsc_update->run( $function, $message );
|
89 |
+
}
|
90 |
+
|
91 |
+
echo '<br /><br /><strong>' . esc_html__( 'WP eCommerce updated successfully!', 'wp-e-commerce' ) . '</strong><br />';
|
92 |
+
if( '' != get_option('permalink_structure')){ ?>
|
93 |
+
<em><?php echo esc_html( sprintf( __( 'Note: It looks like you have custom permalinks, you will need to refresh your permalinks <a href="%s">here</a>', 'wp-e-commerce' ) , admin_url( 'options-permalink.php' ) ) ); ?></em>
|
94 |
+
<?php
|
95 |
+
}
|
96 |
+
update_option('wpsc_version', 3.8);
|
97 |
+
update_option('wpsc_hide_update', true);
|
98 |
+
update_option( 'wpsc_needs_update', false );
|
99 |
+
$wpsc_update->clean_up();
|
100 |
+
ob_implicit_flush( false );
|
101 |
+
else:
|
102 |
+
|
103 |
+
|
104 |
+
esc_html_e( 'Your WP eCommerce database needs to be updated for WP eCommerce 3.8. To perform this update, press the button below. It is highly recommended that you back up your database before performing this update.', 'wp-e-commerce' );
|
105 |
+
?> <br />
|
106 |
+
<br />
|
107 |
+
<em><?php esc_html_e( 'Note: If the server times out or runs out of memory, just reload this page, the server will pick up where it left off.', 'wp-e-commerce' ); ?></em>
|
108 |
+
<br />
|
109 |
+
|
110 |
+
<form action="" method="post" id="setup">
|
111 |
+
<input type="hidden" name="run_updates" value="true" id="run_updates">
|
112 |
+
<p class="step"><input type="submit" class="button" value="<?php esc_attr_e( 'Update WP eCommerce', 'wp-e-commerce' ); ?>" name="Submit"></p>
|
113 |
+
</form>
|
114 |
+
<?php
|
115 |
+
endif;
|
116 |
+
?>
|
117 |
+
</div>
|
118 |
+
|
119 |
+
<?php
|
120 |
+
}
|
121 |
+
|
122 |
+
?>
|
trunk/wpsc-admin/display-upgrades.page.php
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function wpsc_display_upgrades_page() {
|
3 |
+
|
4 |
+
do_action( 'wpsc_upgrades_license_activation' ); ?>
|
5 |
+
|
6 |
+
<div class='wrap'>
|
7 |
+
<div class='metabox-holder wpsc_gold_side'>
|
8 |
+
<div class='metabox-holder'>
|
9 |
+
<form method='post' id='product_license_box' action=''>
|
10 |
+
<div class="postbox">
|
11 |
+
<h3 class="hndle"><?php _e( 'Product License Registration', 'wp-e-commerce' );?></h3>
|
12 |
+
<p>
|
13 |
+
<label for="activation_key"><?php _e( 'License Key ', 'wp-e-commerce' ); ?>:</label>
|
14 |
+
<input type="text" id="activation_key" name="product_license" size="48" value="" class="text" />
|
15 |
+
</p>
|
16 |
+
<p>
|
17 |
+
<input type="hidden" value="true" name="product_license_key" />
|
18 |
+
<button type="submit" name="submit_values" value="submit_values" class="button button-primary"><?php _e( 'Register License', 'wp-e-commerce' ); ?></button>
|
19 |
+
<button type="submit" name="reset_values" value="reset_values"><?php _e( 'Reset License', 'wp-e-commerce' ); ?></button>
|
20 |
+
</p>
|
21 |
+
<p>
|
22 |
+
<?php _e( 'In order to receive automatic plugin updates you need to Register your License for each product that provides one. ', 'wp-e-commerce' ); ?></br>
|
23 |
+
<?php _e( 'Old API Keys will not work! ', 'wp-e-commerce' ); ?>
|
24 |
+
</p>
|
25 |
+
</div>
|
26 |
+
</form>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<?php
|
31 |
+
wpse_license_page_display_licenses();
|
32 |
+
}
|
33 |
+
|
34 |
+
function wpse_license_page_display_licenses () {
|
35 |
+
$licenses = get_option( 'wpec_licenses_active_products', array() );
|
36 |
+
?>
|
37 |
+
<table class="wp-list-table widefat striped">
|
38 |
+
<thead>
|
39 |
+
<tr>
|
40 |
+
<th scope="col" id="product_name" class="manage-column column-product_name column-primary"><?php _e('Product Name', 'wp-e-commerce'); ?></th>
|
41 |
+
<th scope="col" id="product_license" class="manage-column column-product_license"><?php _e('License Key', 'wp-e-commerce'); ?></th>
|
42 |
+
<th scope="col" id="product_expiry" class="manage-column column-product_expiry"><?php _e('License Expiration', 'wp-e-commerce'); ?></th>
|
43 |
+
</tr>
|
44 |
+
</thead>
|
45 |
+
<tbody id="the-list">
|
46 |
+
<?php
|
47 |
+
if ( ! empty( $licenses ) ) {
|
48 |
+
foreach ( (array) $licenses as $license ) { $license_info = get_option( 'wpec_product_' . $license . '_license_active', array() ); ?>
|
49 |
+
<?php do_action( 'wpec_license_individual_license', $license_info ); ?>
|
50 |
+
<tr><td class="product_name column-product_name"><p><strong><?php echo esc_html( $license_info->item_name ); ?></strong></p></td>
|
51 |
+
<td class="product_license column-product_license"><p><strong><?php echo esc_html( $license_info->license_key ); ?></strong></p></td>
|
52 |
+
<td class="product_expiry column-product_expiry"><p><strong><?php if ( $license_info->expiration == 'lifetime' ) { _e('Lifetime', 'wp-e-commerce'); } else { echo esc_html( $license_info->expiration ); } ?></strong></p></td></tr>
|
53 |
+
<?php }
|
54 |
+
} else {
|
55 |
+
?>
|
56 |
+
<tr class="no-items"><td class="colspanchange" colspan="4"><p><?php _e('No Licenses found.', 'wp-e-commerce'); ?></p></td></tr>
|
57 |
+
<?php
|
58 |
+
}
|
59 |
+
?>
|
60 |
+
</tbody>
|
61 |
+
<tfoot>
|
62 |
+
<tr>
|
63 |
+
<th scope="col" class="manage-column column-product_name column-primary"><?php _e('Product Name', 'wp-e-commerce'); ?></th>
|
64 |
+
<th scope="col" class="manage-column column-product_license"><?php _e('License Key', 'wp-e-commerce'); ?></th>
|
65 |
+
<th scope="col" class="manage-column column-product_expiry"><?php _e('License Expiration', 'wp-e-commerce'); ?></th>
|
66 |
+
</tr>
|
67 |
+
</tfoot>
|
68 |
+
</table>
|
69 |
+
<?php
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Activate Gold Cart plugin
|
74 |
+
*/
|
75 |
+
function wpec_licenses_action_stuff() {
|
76 |
+
//Activate a new Product License
|
77 |
+
|
78 |
+
if( ! current_user_can( 'manage_options' ) ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( isset( $_POST['product_license_key'] ) && $_POST['product_license_key'] == 'true' ) {
|
83 |
+
if ( isset( $_POST['product_license'] ) && $_POST['product_license'] != '' ) {
|
84 |
+
|
85 |
+
//Do stuff
|
86 |
+
$params = array (
|
87 |
+
'license' => sanitize_text_field( $_POST['product_license'] ),
|
88 |
+
'url' => home_url()
|
89 |
+
);
|
90 |
+
|
91 |
+
$activation = false;
|
92 |
+
if ( isset( $_POST['submit_values'] ) && $_POST['submit_values'] == 'submit_values' ) {
|
93 |
+
$activation = true;
|
94 |
+
$params['wpec_lic_action'] = 'activate_license';
|
95 |
+
} elseif ( isset( $_POST['reset_values'] ) && $_POST['reset_values'] == 'reset_values' ) {
|
96 |
+
$params['wpec_lic_action'] = 'deactivate_license';
|
97 |
+
}
|
98 |
+
|
99 |
+
$response = wp_remote_post(
|
100 |
+
'https://wpecommerce.org/',
|
101 |
+
array(
|
102 |
+
'timeout' => 15,
|
103 |
+
'sslverify' => false,
|
104 |
+
'body' => $params
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
// Make sure there are no errors
|
109 |
+
if ( is_wp_error( $response ) ) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
// Decode license data
|
114 |
+
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
115 |
+
$active_licenses = get_option( 'wpec_licenses_active_products', array() );
|
116 |
+
|
117 |
+
if( $license_data->success === true ) {
|
118 |
+
if ( $activation ) {
|
119 |
+
// Tell WordPress to look for updates
|
120 |
+
set_site_transient( 'update_plugins', null );
|
121 |
+
$active_licenses[] = $license_data->item_id;
|
122 |
+
update_option( 'wpec_licenses_active_products', $active_licenses );
|
123 |
+
update_option( 'wpec_product_' . $license_data->item_id . '_license_active', $license_data );
|
124 |
+
} else {
|
125 |
+
$key = array_search( $license_data->item_id, $active_licenses );
|
126 |
+
unset( $active_licenses[ $key ] );
|
127 |
+
update_option( 'wpec_licenses_active_products', $active_licenses );
|
128 |
+
delete_option( 'wpec_product_' . $license_data->item_id . '_license_active' );
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
echo '<div class="updated"><p>'.esc_html( $license_data->message ).'</p></div>';
|
133 |
+
} else {
|
134 |
+
echo '<div class="error"><p>'.esc_html( $license_data->message ).'</p></div>';
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
add_action( 'wpsc_upgrades_license_activation', 'wpec_licenses_action_stuff' );
|
140 |
+
|
141 |
+
function wpec_lic_weekly_license_check() {
|
142 |
+
|
143 |
+
if( ! empty( $_POST['product_license_key'] ) ) {
|
144 |
+
return; // Don't fire when saving settings
|
145 |
+
}
|
146 |
+
|
147 |
+
$active_licenses = get_option( 'wpec_licenses_active_products', array() );
|
148 |
+
if( empty( $active_licenses ) ) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
foreach ( (array) $active_licenses as $license ) {
|
153 |
+
$license_info = get_option( 'wpec_product_' . $license . '_license_active' );
|
154 |
+
|
155 |
+
// data to send in our API request
|
156 |
+
$api_params = array(
|
157 |
+
'wpec_lic_action'=> 'check_license',
|
158 |
+
'license' => $license_info->license_key,
|
159 |
+
'item_id' => $license_info->item_id,
|
160 |
+
'url' => home_url()
|
161 |
+
);
|
162 |
+
|
163 |
+
// Call the API
|
164 |
+
$response = wp_remote_post(
|
165 |
+
'https://wpecommerce.org/',
|
166 |
+
array(
|
167 |
+
'timeout' => 15,
|
168 |
+
'sslverify' => false,
|
169 |
+
'body' => $api_params
|
170 |
+
)
|
171 |
+
);
|
172 |
+
|
173 |
+
// make sure the response came back okay
|
174 |
+
if ( is_wp_error( $response ) ) {
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
179 |
+
update_option( 'wpec_product_' . $license . '_license_active', $license_data );
|
180 |
+
}
|
181 |
+
}
|
182 |
+
add_action( 'wpsc_weekly_cron_task', 'wpec_lic_weekly_license_check' ); // For testing use admin_init
|
183 |
+
|
184 |
+
function wpec_license_notices() {
|
185 |
+
if( ! current_user_can( 'manage_options' ) ) {
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
|
189 |
+
$active_licenses = get_option( 'wpec_licenses_active_products', array() );
|
190 |
+
if( empty( $active_licenses ) ) {
|
191 |
+
return;
|
192 |
+
}
|
193 |
+
|
194 |
+
$messages = array();
|
195 |
+
|
196 |
+
foreach ( (array) $active_licenses as $license ) {
|
197 |
+
$license = get_option( 'wpec_product_' . $license . '_license_active' );
|
198 |
+
if( is_object( $license ) && 'valid' !== $license->license && empty( $showed_invalid_message ) ) {
|
199 |
+
if( isset( $_GET['page'] ) && 'wpsc-upgrades' !== $_GET['page'] ) {
|
200 |
+
$messages[] = sprintf(
|
201 |
+
__( 'You have invalid or expired license keys for WP eCommerce. Please go to the <a href="%s" title="Go to Licenses page">Licenses page</a> to correct this issue.', 'wp-e-commerce' ),
|
202 |
+
admin_url( 'index.php?page=wpsc-upgrades' )
|
203 |
+
);
|
204 |
+
$showed_invalid_message = true;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
if( ! empty( $messages ) ) {
|
210 |
+
foreach( $messages as $message ) {
|
211 |
+
echo '<div class="error">';
|
212 |
+
echo '<p>' . $message . '</p>';
|
213 |
+
echo '</div>';
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
add_action( 'admin_notices', 'wpec_license_notices' );
|
trunk/wpsc-admin/includes/coupon-list-table-class.php
ADDED
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Coupon WP List Table Class
|
4 |
+
*
|
5 |
+
* @package WP e-Commerce
|
6 |
+
* @subpackage Coupon List Table Class
|
7 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
+
* @since 3.8.10
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
|
16 |
+
// Load WP_List_Table if not loaded
|
17 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
18 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* WPSC Coupon Codes Table Class
|
23 |
+
*
|
24 |
+
* Renders the Coupons table on the Coupons page
|
25 |
+
*
|
26 |
+
* @access private
|
27 |
+
* @since 3.8.10
|
28 |
+
*/
|
29 |
+
|
30 |
+
class WPSC_Coupons_List_Table extends WP_List_Table {
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Number of results to show per page
|
35 |
+
*
|
36 |
+
* @since 3.8.10
|
37 |
+
*/
|
38 |
+
private $per_page = 30;
|
39 |
+
|
40 |
+
private $total_count;
|
41 |
+
private $active_count;
|
42 |
+
private $inactive_count;
|
43 |
+
private $statuses;
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get things started
|
48 |
+
*
|
49 |
+
* @access private
|
50 |
+
* @since 3.8.10
|
51 |
+
* @return void
|
52 |
+
*/
|
53 |
+
|
54 |
+
public function __construct(){
|
55 |
+
global $status, $page;
|
56 |
+
|
57 |
+
parent::__construct( array(
|
58 |
+
'singular' => 'coupon',
|
59 |
+
'plural' => 'coupons',
|
60 |
+
'ajax' => false
|
61 |
+
) );
|
62 |
+
|
63 |
+
$this->statuses = array(
|
64 |
+
'active' => _x( 'Active', 'coupon status', 'wp-e-commerce' ),
|
65 |
+
'inactive' => _x( 'Inactive', 'coupon status', 'wp-e-commerce' ),
|
66 |
+
'unknown' => _x( 'Unknown', 'coupon status', 'wp-e-commerce' ),
|
67 |
+
);
|
68 |
+
|
69 |
+
$this->process_single_actions();
|
70 |
+
$this->count_coupons();
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Retrieve the view types
|
76 |
+
*
|
77 |
+
* @access private
|
78 |
+
* @since 3.8.10
|
79 |
+
* @return array
|
80 |
+
*/
|
81 |
+
|
82 |
+
public function get_views() {
|
83 |
+
$base = admin_url('edit.php?post_type=wpsc-product&page=wpsc-edit-coupons');
|
84 |
+
|
85 |
+
$current = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
|
86 |
+
$total_count = ' <span class="count">(' . $this->total_count . ')</span>';
|
87 |
+
$active_count = ' <span class="count">(' . $this->active_count . ')</span>';
|
88 |
+
$inactive_count = ' <span class="count">(' . $this->inactive_count . ')</span>';
|
89 |
+
|
90 |
+
$views = array(
|
91 |
+
'all' => sprintf( '<a href="%s"%s>%s</a>', esc_url( remove_query_arg( 'status', $base ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'wp-e-commerce') . $total_count ),
|
92 |
+
'active' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( 'status', '1', $base ) ), $current === '1' ? ' class="current"' : '', __('Active', 'wp-e-commerce') . $active_count ),
|
93 |
+
'inactive' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( 'status', '0', $base ) ), $current === '0' ? ' class="current"' : '', __('Inactive', 'wp-e-commerce') . $inactive_count ),
|
94 |
+
);
|
95 |
+
|
96 |
+
return $views;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Retrieve the table columnds
|
102 |
+
*
|
103 |
+
* @access private
|
104 |
+
* @since 3.8.10
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
|
108 |
+
public function get_columns() {
|
109 |
+
$columns = array(
|
110 |
+
'cb' => '<input type="checkbox" />',
|
111 |
+
'coupon' => __( 'Code', 'wp-e-commerce' ),
|
112 |
+
'discount' => __( 'Discount', 'wp-e-commerce' ),
|
113 |
+
'start' => __( 'Start Date', 'wp-e-commerce' ),
|
114 |
+
'expiry' => __( 'Expiration', 'wp-e-commerce' ),
|
115 |
+
'status' => __( 'Status', 'wp-e-commerce' ),
|
116 |
+
);
|
117 |
+
|
118 |
+
return $columns;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Render most columns
|
124 |
+
*
|
125 |
+
* @access private
|
126 |
+
* @param array $item Contains all the data of the discount code
|
127 |
+
* @param string $column_name The name of the column
|
128 |
+
* @since 3.8.10
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
|
132 |
+
protected function column_default( $item, $column_name ) {
|
133 |
+
switch( $column_name ){
|
134 |
+
case 'start' :
|
135 |
+
|
136 |
+
if( ! empty( $item[ 'start'] ) && '0000-00-00 00:00:00' != $item['start'] ) {
|
137 |
+
$start_date = strtotime( get_date_from_gmt( $item[ $column_name ] ) );
|
138 |
+
$value = date_i18n( get_option( 'date_format' ), $start_date );
|
139 |
+
} else {
|
140 |
+
$value = __( 'None', 'wp-e-commerce' );
|
141 |
+
}
|
142 |
+
|
143 |
+
return $value;
|
144 |
+
|
145 |
+
case 'expiry' :
|
146 |
+
|
147 |
+
if( ! empty( $item[ 'expiry'] ) && '0000-00-00 00:00:00' != $item['expiry'] ) {
|
148 |
+
$expiry_date = strtotime( get_date_from_gmt( $item[ $column_name ] ) );
|
149 |
+
$value = date_i18n( get_option( 'date_format' ), $expiry_date );
|
150 |
+
} else {
|
151 |
+
$value = __( 'None', 'wp-e-commerce' );
|
152 |
+
}
|
153 |
+
|
154 |
+
return $value;
|
155 |
+
|
156 |
+
default:
|
157 |
+
return $item[ $column_name ];
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Render the Name Column
|
163 |
+
*
|
164 |
+
* @access private
|
165 |
+
* @param array $item Contains all the data of the discount code
|
166 |
+
* @since 3.8.10
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
protected function column_coupon( $item ) {
|
170 |
+
|
171 |
+
$base = admin_url( 'edit.php?post_type=wpsc-product&page=wpsc-edit-coupons&wpsc-action=edit_coupon&coupon=' . $item['ID'] );
|
172 |
+
|
173 |
+
$coupon = '<strong><a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . esc_html( $item['coupon'] ) . '</a></strong>';
|
174 |
+
|
175 |
+
$row_actions = array();
|
176 |
+
|
177 |
+
$row_actions['edit'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'edit_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Edit', 'wp-e-commerce' ) . '</a>';
|
178 |
+
|
179 |
+
if( strtolower( $item['status'] ) == 'active' )
|
180 |
+
$row_actions['deactivate'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'deactivate_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Deactivate', 'wp-e-commerce' ) . '</a>';
|
181 |
+
else
|
182 |
+
$row_actions['activate'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'activate_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Activate', 'wp-e-commerce' ) . '</a>';
|
183 |
+
|
184 |
+
$row_actions['delete'] = '<a href="' . esc_url( add_query_arg( array( 'wpsc-action' => 'delete_coupon', 'coupon' => $item['ID'] ) ) ) . '">' . __( 'Delete', 'wp-e-commerce' ) . '</a>';
|
185 |
+
|
186 |
+
$row_actions = apply_filters( 'wpsc_coupon_row_actions', $row_actions, $item['ID'] );
|
187 |
+
|
188 |
+
return $coupon . $this->row_actions( $row_actions );
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Render the checkbox column
|
194 |
+
*
|
195 |
+
* @access private
|
196 |
+
* @since 3.8.10
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
|
200 |
+
protected function column_cb( $item ) {
|
201 |
+
return sprintf(
|
202 |
+
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
203 |
+
/*$1%s*/ $this->_args['singular'],
|
204 |
+
/*$2%s*/ $item['ID']
|
205 |
+
);
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Render the Status Column
|
211 |
+
*
|
212 |
+
* @access private
|
213 |
+
* @param array $item Contains all the data of the discount code
|
214 |
+
* @since 3.8.10
|
215 |
+
* @return string
|
216 |
+
*/
|
217 |
+
|
218 |
+
protected function column_status( $item ) {
|
219 |
+
if ( ! array_key_exists( $item['status'], $this->statuses ) )
|
220 |
+
$item['status'] = 'unknown';
|
221 |
+
|
222 |
+
$column = '<span class="wpsc-coupon-status wpsc-coupon-status-%1$s">%2$s</a>';
|
223 |
+
$column = sprintf( $column, $item['status'], $this->statuses[$item['status']] );
|
224 |
+
|
225 |
+
return $column;
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Render the Discount Column
|
231 |
+
*
|
232 |
+
* @access private
|
233 |
+
* @param array $item Contains all the data of the discount code
|
234 |
+
* @since 3.8.10
|
235 |
+
* @return string
|
236 |
+
*/
|
237 |
+
|
238 |
+
protected function column_discount( $item ) {
|
239 |
+
switch( $item['type'] ) {
|
240 |
+
case 0:
|
241 |
+
return wpsc_currency_display( $item['discount'] );
|
242 |
+
break;
|
243 |
+
case 1:
|
244 |
+
return $item['discount'] . '%';
|
245 |
+
break;
|
246 |
+
case 2:
|
247 |
+
return __( 'Free shipping', 'wp-e-commerce' );
|
248 |
+
break;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Retrieve the bulk actions
|
255 |
+
*
|
256 |
+
* @access private
|
257 |
+
* @since 3.8.10
|
258 |
+
* @return array
|
259 |
+
*/
|
260 |
+
|
261 |
+
public function get_bulk_actions() {
|
262 |
+
$actions = array(
|
263 |
+
'activate' => __( 'Activate', 'wp-e-commerce' ),
|
264 |
+
'deactivate' => __( 'Deactivate', 'wp-e-commerce' ),
|
265 |
+
'delete' => __( 'Delete', 'wp-e-commerce' )
|
266 |
+
);
|
267 |
+
|
268 |
+
return $actions;
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Process the bulk actions
|
274 |
+
*
|
275 |
+
* @access private
|
276 |
+
* @since 3.8.10
|
277 |
+
* @return void
|
278 |
+
*/
|
279 |
+
|
280 |
+
public function process_bulk_action() {
|
281 |
+
|
282 |
+
global $wpdb;
|
283 |
+
|
284 |
+
$ids = isset( $_GET['coupon'] ) ? $_GET['coupon'] : false;
|
285 |
+
|
286 |
+
if ( ! is_array( $ids ) ) {
|
287 |
+
$ids = array( $ids );
|
288 |
+
}
|
289 |
+
|
290 |
+
foreach ( $ids as $id ) {
|
291 |
+
|
292 |
+
$coupon = new WPSC_Coupon( $id );
|
293 |
+
|
294 |
+
if ( 'delete' === $this->current_action() ) {
|
295 |
+
|
296 |
+
// Delete a discount
|
297 |
+
$coupon->delete();
|
298 |
+
|
299 |
+
} elseif( 'activate' === $this->current_action() ) {
|
300 |
+
|
301 |
+
// Activate a discount
|
302 |
+
$coupon->activate();
|
303 |
+
|
304 |
+
} elseif( 'deactivate' === $this->current_action() ) {
|
305 |
+
|
306 |
+
// Deactivate a discount
|
307 |
+
$coupon->deactivate();
|
308 |
+
|
309 |
+
}
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Process single actions
|
317 |
+
*
|
318 |
+
* @access private
|
319 |
+
* @since 3.8.10
|
320 |
+
* @return void
|
321 |
+
*/
|
322 |
+
public function process_single_actions() {
|
323 |
+
|
324 |
+
global $wpdb;
|
325 |
+
|
326 |
+
if ( ! isset( $_GET['wpsc-action'] ) || ! isset( $_GET['coupon'] ) ) {
|
327 |
+
return;
|
328 |
+
}
|
329 |
+
|
330 |
+
$coupon = new WPSC_Coupon( $_GET['coupon'] );
|
331 |
+
|
332 |
+
switch ( $_GET['wpsc-action'] ) {
|
333 |
+
|
334 |
+
case 'activate_coupon':
|
335 |
+
|
336 |
+
$updated = $coupon->activate();
|
337 |
+
|
338 |
+
if ( $updated ) {
|
339 |
+
printf( '<div class="updated"><p>%s</p></div>', __( 'The coupon has been activated.', 'wp-e-commerce' ) );
|
340 |
+
}
|
341 |
+
|
342 |
+
break;
|
343 |
+
|
344 |
+
case 'deactivate_coupon':
|
345 |
+
|
346 |
+
$updated = $coupon->deactivate();
|
347 |
+
|
348 |
+
if ( $updated ) {
|
349 |
+
printf( '<div class="updated"><p>%s</p></div>', __( 'The coupon has been deactivated.', 'wp-e-commerce' ) );
|
350 |
+
}
|
351 |
+
|
352 |
+
break;
|
353 |
+
|
354 |
+
case 'delete_coupon':
|
355 |
+
|
356 |
+
$deleted = $coupon->delete();
|
357 |
+
|
358 |
+
if ( $deleted ) {
|
359 |
+
printf( '<div class="updated"><p>%s</p></div>', __( 'The coupon has been deleted.', 'wp-e-commerce' ) );
|
360 |
+
}
|
361 |
+
|
362 |
+
break;
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Retrieve the discount code counts
|
371 |
+
*
|
372 |
+
* @access private
|
373 |
+
* @since 3.8.10
|
374 |
+
* @return array
|
375 |
+
*/
|
376 |
+
public function count_coupons() {
|
377 |
+
|
378 |
+
global $wpdb;
|
379 |
+
|
380 |
+
// retrieve all discounts here
|
381 |
+
$this->active_count = $wpdb->get_var( "SELECT COUNT(id) AS count FROM " . WPSC_TABLE_COUPON_CODES . " WHERE active=1;" );
|
382 |
+
$this->inactive_count = $wpdb->get_var( "SELECT COUNT(id) AS count FROM " . WPSC_TABLE_COUPON_CODES . " WHERE active=0;" );
|
383 |
+
$this->total_count = $this->active_count + $this->inactive_count;
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Retrieve all the data for all the discount codes
|
389 |
+
*
|
390 |
+
* @access private
|
391 |
+
* @since 3.8.10
|
392 |
+
* @return array
|
393 |
+
*/
|
394 |
+
public function coupons_data() {
|
395 |
+
|
396 |
+
global $wpdb;
|
397 |
+
|
398 |
+
$coupons_data = array();
|
399 |
+
|
400 |
+
if ( isset( $_GET['paged'] ) ) $page = $_GET['paged']; else $page = 1;
|
401 |
+
|
402 |
+
$per_page = $this->per_page;
|
403 |
+
$offset = ( $page - 1 ) * $this->per_page;
|
404 |
+
|
405 |
+
$status = isset( $_GET['status'] ) ? absint( $_GET['status'] ) : false;
|
406 |
+
$where = $status !== false ? "WHERE active = $status" : '';
|
407 |
+
|
408 |
+
$order = isset( $_GET['order'] ) && strtoupper( $_GET['order'] ) === 'ASC' ? 'ASC' : 'DESC';
|
409 |
+
$limit = " LIMIT $offset,$per_page;";
|
410 |
+
$coupons = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` {$where} ORDER BY id {$order} {$limit} ", ARRAY_A );
|
411 |
+
|
412 |
+
if ( $coupons ) {
|
413 |
+
foreach ( $coupons as $data ) {
|
414 |
+
|
415 |
+
$coupon = new WPSC_Coupon( array(
|
416 |
+
'id' => $data['id'],
|
417 |
+
'coupon_code' => $data['coupon_code'],
|
418 |
+
'value' => $data['value'],
|
419 |
+
'is-percentage' => $data['is-percentage'],
|
420 |
+
'start' => $data['start'],
|
421 |
+
'expiry' => $data['expiry'],
|
422 |
+
'active' => $data['active']
|
423 |
+
) );
|
424 |
+
|
425 |
+
// Re-map data to array for legacy handling of this method's return data.
|
426 |
+
// (would be nicer to return an object?)
|
427 |
+
$coupons_data[] = array(
|
428 |
+
'ID' => $coupon->get( 'id' ),
|
429 |
+
'coupon' => $coupon->get( 'coupon_code' ),
|
430 |
+
'discount' => $coupon->get( 'value' ),
|
431 |
+
'type' => $coupon->get( 'is-percentage' ),
|
432 |
+
'start' => $coupon->get( 'start' ),
|
433 |
+
'expiry' => $coupon->get( 'expiry' ),
|
434 |
+
'status' => $coupon->get( 'active' ) == 1 ? 'active' : 'inactive'
|
435 |
+
);
|
436 |
+
|
437 |
+
}
|
438 |
+
}
|
439 |
+
return $coupons_data;
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Setup the final data for the table
|
445 |
+
*
|
446 |
+
* @access private
|
447 |
+
* @since 3.8.10
|
448 |
+
* @return array
|
449 |
+
*/
|
450 |
+
public function prepare_items() {
|
451 |
+
|
452 |
+
$hidden = array();
|
453 |
+
$total_items = 0;
|
454 |
+
$per_page = $this->per_page;
|
455 |
+
$columns = $this->get_columns();
|
456 |
+
$sortable = $this->get_sortable_columns();
|
457 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
458 |
+
|
459 |
+
$this->process_bulk_action();
|
460 |
+
|
461 |
+
$data = $this->coupons_data();
|
462 |
+
$this->items = $data;
|
463 |
+
|
464 |
+
$status = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
|
465 |
+
switch ( $status ) {
|
466 |
+
case '1':
|
467 |
+
$total_items = $this->active_count;
|
468 |
+
break;
|
469 |
+
case '0':
|
470 |
+
$total_items = $this->inactive_count;
|
471 |
+
break;
|
472 |
+
case 'any':
|
473 |
+
$total_items = $this->total_count;
|
474 |
+
break;
|
475 |
+
}
|
476 |
+
|
477 |
+
$this->set_pagination_args( array(
|
478 |
+
'total_items' => $total_items,
|
479 |
+
'per_page' => $per_page,
|
480 |
+
'total_pages' => ceil( $total_items / $per_page )
|
481 |
+
)
|
482 |
+
);
|
483 |
+
}
|
484 |
+
}
|
trunk/wpsc-admin/includes/display-items-functions.php
ADDED
@@ -0,0 +1,1710 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WPSC Product form generation functions
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
6 |
+
* @since 3.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
global $wpsc_product_defaults;
|
10 |
+
|
11 |
+
$wpsc_product_defaults = array(
|
12 |
+
'id' => '0',
|
13 |
+
'name' => '',
|
14 |
+
'description' => '',
|
15 |
+
'additional_description' => '',
|
16 |
+
'price' => '0.00',
|
17 |
+
'weight' => '0',
|
18 |
+
'weight_unit' => 'pound',
|
19 |
+
'pnp' => '0.00',
|
20 |
+
'international_pnp' => '0.00',
|
21 |
+
'file' => '0',
|
22 |
+
'image' => '',
|
23 |
+
'category' => '0',
|
24 |
+
'brand' => '0',
|
25 |
+
'quantity_limited' => '0',
|
26 |
+
'quantity' => '0',
|
27 |
+
'special' => '0',
|
28 |
+
'special_price' => 0.00,
|
29 |
+
'display_frontpage' => '0',
|
30 |
+
'notax' => '0',
|
31 |
+
'publish' => '1',
|
32 |
+
'active' => '1',
|
33 |
+
'donation' => '0',
|
34 |
+
'no_shipping' => '0',
|
35 |
+
'thumbnail_image' => '',
|
36 |
+
'thumbnail_state' => '1',
|
37 |
+
'meta' => array(
|
38 |
+
'external_link' => NULL,
|
39 |
+
'external_link_text' => NULL,
|
40 |
+
'external_link_target' => NULL,
|
41 |
+
'merchant_notes' => NULL,
|
42 |
+
'sku' => NULL,
|
43 |
+
'engraved' => '0',
|
44 |
+
'can_have_uploaded_image' => '0',
|
45 |
+
'table_rate_price' => array(
|
46 |
+
'quantity' => array(
|
47 |
+
0 => '',
|
48 |
+
),
|
49 |
+
'table_price' => array(
|
50 |
+
0 => '',
|
51 |
+
),
|
52 |
+
),
|
53 |
+
),
|
54 |
+
);
|
55 |
+
|
56 |
+
function wpsc_redirect_variation_update( $location, $post_id ) {
|
57 |
+
global $post;
|
58 |
+
|
59 |
+
if ( $post->post_parent > 0 && 'wpsc-product' == $post->post_type )
|
60 |
+
wp_redirect( admin_url( 'post.php?post='.$post->post_parent.'&action=edit' ) );
|
61 |
+
else
|
62 |
+
return $location;
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
add_filter( 'redirect_post_location', 'wpsc_redirect_variation_update', 10, 2 );
|
67 |
+
|
68 |
+
function wpsc_price_control_forms() {
|
69 |
+
global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
|
70 |
+
|
71 |
+
$product_data = get_post_custom( $post->ID );
|
72 |
+
$product_data['meta'] = maybe_unserialize( $product_data );
|
73 |
+
|
74 |
+
foreach ( $product_data['meta'] as $meta_key => $meta_value ) {
|
75 |
+
$product_data['meta'][$meta_key] = $meta_value[0];
|
76 |
+
}
|
77 |
+
|
78 |
+
$product_meta = array();
|
79 |
+
|
80 |
+
if ( ! empty( $product_data['_wpsc_product_metadata'] ) ) {
|
81 |
+
$product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( isset( $product_data['meta']['_wpsc_currency'] ) ) {
|
85 |
+
$product_alt_currency = maybe_unserialize( $product_data['meta']['_wpsc_currency'] );
|
86 |
+
}
|
87 |
+
|
88 |
+
if ( ! isset( $product_data['meta']['_wpsc_table_rate_price'] ) ) {
|
89 |
+
$product_data['meta']['_wpsc_table_rate_price'] = $wpsc_product_defaults['meta']['table_rate_price'];
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( isset( $product_meta['_wpsc_table_rate_price'] ) ) {
|
93 |
+
$product_meta['table_rate_price']['state'] = 1;
|
94 |
+
$product_meta['table_rate_price'] += $product_meta['_wpsc_table_rate_price'];
|
95 |
+
$product_data['meta']['_wpsc_table_rate_price'] = $product_meta['_wpsc_table_rate_price'];
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
if ( ! isset( $product_data['meta']['_wpsc_is_donation'] ) ) {
|
100 |
+
$product_data['meta']['_wpsc_is_donation'] = $wpsc_product_defaults['donation'];
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( ! isset( $product_meta['table_rate_price']['state'] ) ) {
|
104 |
+
$product_meta['table_rate_price']['state'] = null;
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( ! isset( $product_meta['table_rate_price']['quantity'] ) ) {
|
108 |
+
$product_meta['table_rate_price']['quantity'] = $wpsc_product_defaults['meta']['table_rate_price']['quantity'][0];
|
109 |
+
}
|
110 |
+
|
111 |
+
if ( ! isset( $product_data['meta']['_wpsc_price'] ) ) {
|
112 |
+
$product_data['meta']['_wpsc_price'] = $wpsc_product_defaults['price'];
|
113 |
+
}
|
114 |
+
|
115 |
+
if ( ! isset( $product_data['special'] ) ) {
|
116 |
+
$product_data['special'] = $wpsc_product_defaults['special'];
|
117 |
+
}
|
118 |
+
|
119 |
+
if ( ! isset( $product_data['meta']['_wpsc_special_price'] ) ) {
|
120 |
+
$product_data['meta']['_wpsc_special_price'] = $wpsc_product_defaults['special_price'];
|
121 |
+
}
|
122 |
+
|
123 |
+
$product_data['meta']['_wpsc_special_price'] = wpsc_format_number( $product_data['meta']['_wpsc_special_price'] );
|
124 |
+
|
125 |
+
if ( ! isset( $product_data['meta']['_wpsc_price'] ) ) {
|
126 |
+
$product_data['meta']['_wpsc_price'] = 0;
|
127 |
+
}
|
128 |
+
|
129 |
+
$product_data['meta']['_wpsc_price'] = wpsc_format_number( $product_data['meta']['_wpsc_price'] );
|
130 |
+
|
131 |
+
$currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
|
132 |
+
|
133 |
+
/* Get country name and symbol */
|
134 |
+
$currency_type = get_option( 'currency_type' );
|
135 |
+
$country = new WPSC_Country( $currency_type );
|
136 |
+
|
137 |
+
$ct_code = $country->get_currency_code(); // Country currency code
|
138 |
+
$ct_symb = $country->get_currency_symbol(); // Country symbol
|
139 |
+
|
140 |
+
$price = $product_data['meta']['_wpsc_price'];
|
141 |
+
$sale_price = $product_data['meta']['_wpsc_special_price'];
|
142 |
+
|
143 |
+
$wp_38 = version_compare( $GLOBALS['wp_version'], '3.8', '>=' );
|
144 |
+
|
145 |
+
$currency_delete_class = $wp_38 ? ' dashicons dashicons-dismiss' : '';
|
146 |
+
$currency_delete_text = $wp_38 ? '' : 'x';
|
147 |
+
?>
|
148 |
+
<em id="wpsc_product_price_metabox_live_title" class="wpsc_metabox_live_title">
|
149 |
+
<p> <?php echo esc_html( $ct_symb ); ?><span><?php echo esc_html( $sale_price ); ?></span></p>
|
150 |
+
<del><?php echo esc_html( $ct_symb ); ?><span><?php echo esc_html( $price ) ?></span></del>
|
151 |
+
</em>
|
152 |
+
<input type="hidden" id="parent_post" name="parent_post" value="<?php echo $post->post_parent; ?>" />
|
153 |
+
<?php /* Lots of tedious work is avoided with this little line. */ ?>
|
154 |
+
<input type="hidden" id="product_id" name="product_id" value="<?php echo $post->ID; ?>" />
|
155 |
+
|
156 |
+
<?php /* Check product if a product has variations */ ?>
|
157 |
+
<?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
|
158 |
+
<?php $price = wpsc_product_variation_price_from( $post->ID ); ?>
|
159 |
+
<p style="margin-top: 6px;"><?php echo sprintf( __( 'This product has variations. To edit the price, please use the <a href="%s">Variation Controls</a>.' , 'wp-e-commerce' ), '#wpsc_product_variation_forms' ); ?></p>
|
160 |
+
<p><?php printf( __( 'Price: %s and above.' , 'wp-e-commerce' ), $price ); ?></p>
|
161 |
+
<?php else: ?>
|
162 |
+
|
163 |
+
<div class='wpsc_floatleft' style="width:100px;">
|
164 |
+
<label for="wpsc_price"><?php _e( 'Price', 'wp-e-commerce' ); ?></label>
|
165 |
+
<?php echo esc_html( $ct_symb ); ?> <input id="wpsc_price"
|
166 |
+
type="text"
|
167 |
+
style="width: 70px;"
|
168 |
+
name="meta[_wpsc_price]"
|
169 |
+
value="<?php echo esc_attr( $price ); ?>" />
|
170 |
+
</div>
|
171 |
+
|
172 |
+
<div class='wpsc_floatleft' style='width:95px; margin-left:30px;'>
|
173 |
+
<label for='wpsc_sale_price'><?php _e( 'Sale Price', 'wp-e-commerce' ); ?></label>
|
174 |
+
<?php echo esc_html( $ct_symb ); ?> <input id = "wpsc_sale_price"
|
175 |
+
type="text"
|
176 |
+
style="width: 70px;"
|
177 |
+
value="<?php echo esc_attr( $sale_price ); ?>"
|
178 |
+
name='meta[_wpsc_special_price]' />
|
179 |
+
</div>
|
180 |
+
|
181 |
+
<div class="wpsc-currency-layers">
|
182 |
+
<table>
|
183 |
+
<thead>
|
184 |
+
<tr>
|
185 |
+
<th class="type" colspan="2"><?php esc_html_e( 'Alternative Currencies:', 'wp-e-commerce' ); ?></th>
|
186 |
+
<th class="price"><?php esc_html_e( 'Price:', 'wp-e-commerce' ); ?></th>
|
187 |
+
<tr>
|
188 |
+
</thead>
|
189 |
+
<tbody>
|
190 |
+
<?php
|
191 |
+
if ( isset( $product_alt_currency ) && is_array( $product_alt_currency ) ) :
|
192 |
+
$i = 0;
|
193 |
+
foreach ( $product_alt_currency as $iso => $alt_price ) :
|
194 |
+
$i++;
|
195 |
+
?>
|
196 |
+
<tr class="wpsc_additional_currency">
|
197 |
+
<td class="remove"><a href="#" class="wpsc_delete_currency_layer<?php echo $currency_delete_class; ?>" rel="<?php echo $iso; ?>"><?php echo $currency_delete_text; ?></a></td>
|
198 |
+
<td>
|
199 |
+
<select name="newCurrency[]" class="newCurrency">
|
200 |
+
<?php foreach ( $currency_data as $currency ) : ?>
|
201 |
+
<option value="<?php echo absint( $currency['id'] ); ?>" <?php selected( $iso, $currency['isocode'] ); ?>>
|
202 |
+
<?php echo esc_html( $currency['country'] ); ?> (<?php echo esc_html( $currency['currency'] ); ?>)
|
203 |
+
</option>
|
204 |
+
<?php endforeach; ?>
|
205 |
+
</select>
|
206 |
+
</td>
|
207 |
+
<td><input class="newCurrPrice text" size="8" name="newCurrPrice[]" value="<?php echo esc_attr( $alt_price ); ?>" /></td>
|
208 |
+
</tr>
|
209 |
+
<?php
|
210 |
+
endforeach;
|
211 |
+
endif;
|
212 |
+
?>
|
213 |
+
<tr id="wpsc_currency_row_template" class="template hidden">
|
214 |
+
<td class="remove"><a href="#" class="wpsc_delete_currency_layer<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
|
215 |
+
<td>
|
216 |
+
<select name="newCurrency[]" class="newCurrency">
|
217 |
+
<?php foreach ( (array) $currency_data as $currency ) { ?>
|
218 |
+
<option value="<?php echo absint( $currency['id'] ); ?>">
|
219 |
+
<?php echo esc_html( $currency['country'] ); ?>
|
220 |
+
</option>
|
221 |
+
<?php } ?>
|
222 |
+
</select>
|
223 |
+
</td>
|
224 |
+
<td><input class="newCurrPrice text" size="8" name="newCurrPrice[]" value="0.00" /></td>
|
225 |
+
</tr>
|
226 |
+
</tbody>
|
227 |
+
</table>
|
228 |
+
<a href="#wpsc_currency_row_template" class="button button-small wpsc_add_new_currency"><?php esc_html_e( 'Add a Currency Option', 'wp-e-commerce' ); ?></a>
|
229 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-currency-layers', false ); ?>
|
230 |
+
</div>
|
231 |
+
|
232 |
+
<div class="wpsc-quantity-discounts">
|
233 |
+
<table>
|
234 |
+
<thead>
|
235 |
+
<tr>
|
236 |
+
<th class="qty" colspan="2"><?php esc_html_e( 'Quantity:', 'wp-e-commerce' ); ?></th>
|
237 |
+
<th class="curr"><span class="hidden"><?php esc_html_e( 'Currency:', 'wp-e-commerce' ); ?><span></th>
|
238 |
+
<th class="price"><?php esc_html_e( 'Price:', 'wp-e-commerce' ); ?></th>
|
239 |
+
</tr>
|
240 |
+
</thead>
|
241 |
+
<tbody>
|
242 |
+
<?php
|
243 |
+
if ( count( $product_meta['table_rate_price']['quantity'] ) > 0 ) {
|
244 |
+
foreach ( (array) $product_meta['table_rate_price']['quantity'] as $key => $quantity ) {
|
245 |
+
if ( $quantity != '' ) {
|
246 |
+
$table_price = number_format( $product_meta['table_rate_price']['table_price'][ $key ], 2, '.', '' );
|
247 |
+
?>
|
248 |
+
<tr>
|
249 |
+
<td class="remove"><a href="#" class="remove_line<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
|
250 |
+
<td class="qty">
|
251 |
+
<input type="text" size="5" value="<?php echo absint( $quantity ); ?>" name="table_rate_price[quantity][]" />
|
252 |
+
<?php esc_html_e( '+', 'wp-e-commerce' ); ?>
|
253 |
+
</td>
|
254 |
+
<td class="curr"><?php echo $ct_code . ' ' . $ct_symb; ?></td>
|
255 |
+
<td><input class="newCurrPrice text" value="<?php echo $table_price; ?>" name="table_rate_price[table_price][]" /></td>
|
256 |
+
</tr>
|
257 |
+
<?php
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
?>
|
262 |
+
<tr id="wpsc_quantity_discount_row_template" class="template hidden">
|
263 |
+
<td class="remove"><a href="#" class="remove_line<?php echo $currency_delete_class; ?>"><?php echo $currency_delete_text; ?></a></td>
|
264 |
+
<td class="qty">
|
265 |
+
<input size="5" value="0" name="table_rate_price[quantity][]" />
|
266 |
+
<?php esc_html_e( '+', 'wp-e-commerce' ); ?>
|
267 |
+
</td>
|
268 |
+
<td class="curr"><?php echo $ct_code . ' ' . $ct_symb; ?></td>
|
269 |
+
<td><input size="10"class="newCurrPrice text" value="0" name="table_rate_price[table_price][]" /></td>
|
270 |
+
</tr>
|
271 |
+
</tbody>
|
272 |
+
</table>
|
273 |
+
<a href="#wpsc_quantity_discount_row_template" class="add_level button button-small"><?php esc_html_e( 'Add a Quantity Discount', 'wp-e-commerce' ); ?></a>
|
274 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-quantity-discounts', false ); ?>
|
275 |
+
</div>
|
276 |
+
|
277 |
+
<input id="add_form_donation" type="checkbox" name="meta[_wpsc_is_donation]" value="yes" <?php checked( $product_data['meta']['_wpsc_is_donation'], 1 ); ?> />
|
278 |
+
<label for="add_form_donation"><?php _e( 'Purchase is a donation.', 'wp-e-commerce' ) ?></label>
|
279 |
+
<?php wp_nonce_field( 'update', 'wpsc_product_pricing_nonce' ); ?>
|
280 |
+
|
281 |
+
<?php endif;
|
282 |
+
|
283 |
+
}
|
284 |
+
function wpsc_stock_control_forms() {
|
285 |
+
global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
|
286 |
+
|
287 |
+
$product_data = get_post_custom( $post->ID );
|
288 |
+
$product_data['meta'] = maybe_unserialize( $product_data );
|
289 |
+
|
290 |
+
foreach ( $product_data['meta'] as $meta_key => $meta_value ) {
|
291 |
+
$product_data['meta'][$meta_key] = $meta_value[0];
|
292 |
+
}
|
293 |
+
|
294 |
+
$product_meta = array();
|
295 |
+
|
296 |
+
if ( ! empty( $product_data['_wpsc_product_metadata'] ) ) {
|
297 |
+
$product_meta = maybe_unserialize( $product_data["_wpsc_product_metadata"][0] );
|
298 |
+
}
|
299 |
+
|
300 |
+
if ( ! isset( $product_meta['unpublish_when_none_left'] ) ) {
|
301 |
+
$product_meta['unpublish_when_none_left'] = '';
|
302 |
+
}
|
303 |
+
|
304 |
+
if ( ! isset( $product_meta['stock_limit_notify'] ) ) {
|
305 |
+
$product_meta['stock_limit_notify'] = '';
|
306 |
+
}
|
307 |
+
|
308 |
+
// Display live title if stock is set
|
309 |
+
if ( isset( $product_data['meta']['_wpsc_stock'] ) && is_numeric( $product_data['meta']['_wpsc_stock'] ) ) {
|
310 |
+
$live_title = '<em id="wpsc_product_stock_metabox_live_title" class="wpsc_metabox_live_title">';
|
311 |
+
$live_title .= sprintf( '<p><span>%s</span> %s</p>', wpsc_format_number( $product_data['meta']['_wpsc_stock'], 0 ), _x( 'left in stock', 'live preview of stock remaining in admin', 'wp-e-commerce' ) );
|
312 |
+
$live_title .= '</em>';
|
313 |
+
|
314 |
+
echo $live_title;
|
315 |
+
}
|
316 |
+
|
317 |
+
if ( ! empty( $product_meta['unpublish_when_none_left'] ) )
|
318 |
+
?>
|
319 |
+
<label for="wpsc_sku"><abbr title="<?php esc_attr_e( 'Stock Keeping Unit', 'wp-e-commerce' ); ?>"><?php esc_html_e( 'SKU:', 'wp-e-commerce' ); ?></abbr></label>
|
320 |
+
<?php
|
321 |
+
if ( !isset( $product_data['meta']['_wpsc_sku'] ) )
|
322 |
+
$product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku']; ?><br />
|
323 |
+
<input size='32' type='text' class='text' id="wpsc_sku" name='meta[_wpsc_sku]' value='<?php echo esc_html( $product_data['meta']['_wpsc_sku'] ); ?>' />
|
324 |
+
<br style="clear:both" />
|
325 |
+
<?php
|
326 |
+
if ( !isset( $product_data['meta']['_wpsc_stock'] ) )
|
327 |
+
$product_data['meta']['_wpsc_stock'] = ''; ?>
|
328 |
+
<br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) echo 'checked="checked"'; else echo ''; ?> name='meta[_wpsc_limited_stock]' />
|
329 |
+
<label for='add_form_quantity_limited' class='small'><?php esc_html_e( 'Product has limited stock', 'wp-e-commerce' ); ?></label>
|
330 |
+
<?php
|
331 |
+
if ( $post->ID > 0 ) {
|
332 |
+
if ( is_numeric( $product_data['meta']['_wpsc_stock'] ) ) {?>
|
333 |
+
<div class='edit_stock' style='display: block;'> <?php
|
334 |
+
} else { ?>
|
335 |
+
<div class='edit_stock' style='display: none;'><?php
|
336 |
+
} ?>
|
337 |
+
<?php if ( wpsc_product_has_children( $post->ID ) ) : ?>
|
338 |
+
<?php $stock = wpsc_variations_stock_remaining( $post->ID ); ?>
|
339 |
+
<p><?php echo sprintf( __( 'This product has variations. To edit the quantity, please use the <a href="%s">Variation Controls</a> below.' , 'wp-e-commerce' ), '#wpsc_product_variation_forms' ); ?></p>
|
340 |
+
<p><?php printf( _n( "%s variant item in stock.", "%s variant items in stock.", $stock, 'wp-e-commerce' ), $stock ); ?></p>
|
341 |
+
<?php else: ?>
|
342 |
+
<div style="margin-bottom:20px;">
|
343 |
+
<label for="stock_limit_quantity"><?php esc_html_e( 'Quantity in stock', 'wp-e-commerce' ); ?></label>
|
344 |
+
<input type='number' min="0" step="1" style="width:80px; margin-left:50px;"
|
345 |
+
id="stock_limit_quantity" name='meta[_wpsc_stock]'
|
346 |
+
size='3' value='<?php echo absint( $product_data['meta']['_wpsc_stock'] ); ?>'
|
347 |
+
class='stock_limit_quantity' />
|
348 |
+
</div>
|
349 |
+
|
350 |
+
<?php
|
351 |
+
$remaining_quantity = wpsc_get_remaining_quantity( $post->ID );
|
352 |
+
$reserved_quantity = $product_data['meta']['_wpsc_stock'] - $remaining_quantity;
|
353 |
+
if ( $reserved_quantity ) {
|
354 |
+
echo '<p><em>';
|
355 |
+
printf( _n('%s of them is reserved for pending or recently completed orders.',
|
356 |
+
'%s of them are reserved for pending or recently completed orders.',
|
357 |
+
$reserved_quantity, 'wp-e-commerce'), $reserved_quantity );
|
358 |
+
|
359 |
+
echo '</em></p>';
|
360 |
+
}
|
361 |
+
?>
|
362 |
+
<?php endif; ?>
|
363 |
+
<hr>
|
364 |
+
<p><?php esc_html_e( 'Notify site owner via email when stock reduces to :', 'wp-e-commerce' ); ?>
|
365 |
+
<input type='number' min="0" step="1" style="width:70px; margin-left:10px;"
|
366 |
+
id="stock_limit_notify" name='meta[_wpsc_product_metadata][stock_limit_notify]'
|
367 |
+
size='3' value='<?php echo absint( $product_meta['stock_limit_notify'] ); ?>'
|
368 |
+
class='stock_limit_notify' />
|
369 |
+
</p>
|
370 |
+
<hr>
|
371 |
+
<p><?php esc_html_e( 'When stock reduces to zero:', 'wp-e-commerce' ); ?>
|
372 |
+
<div class='unpublish_when_none_left'>
|
373 |
+
<input type='checkbox' id="unpublish_when_oos"
|
374 |
+
name='meta[_wpsc_product_metadata][unpublish_when_none_left]'
|
375 |
+
class='unpublish_when_oos'<?php checked( $product_meta['unpublish_when_none_left'] ); ?> />
|
376 |
+
<label for="unpublish_when_oos"><?php esc_html_e( 'Unpublish product from website', 'wp-e-commerce' ); ?></label>
|
377 |
+
|
378 |
+
</div>
|
379 |
+
</div> <?php
|
380 |
+
} else { ?>
|
381 |
+
<div style='display: none;' class='edit_stock'>
|
382 |
+
<?php esc_html_e( 'Stock Qty', 'wp-e-commerce' ); ?><input type='text' name='meta[_wpsc_stock]' value='0' size='10' />
|
383 |
+
<div style='font-size:9px; padding:5px;'>
|
384 |
+
<input type='checkbox' class='unpublish_when_oos' name='meta[_wpsc_product_metadata][unpublish_when_none_left]' /> <?php esc_html_e( 'Set status to Unpublished if this Product runs out of stock', 'wp-e-commerce' ); ?>
|
385 |
+
</div>
|
386 |
+
</div>
|
387 |
+
<?php
|
388 |
+
}
|
389 |
+
|
390 |
+
wp_nonce_field( 'update', 'wpsc_product_stock_nonce' );
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
function wpsc_product_taxes_forms() {
|
395 |
+
global $post, $wpdb, $wpsc_product_defaults;
|
396 |
+
$product_data = get_post_custom( $post->ID );
|
397 |
+
|
398 |
+
$product_data['meta'] = $product_meta = array();
|
399 |
+
if ( !empty( $product_data['_wpsc_product_metadata'] ) )
|
400 |
+
$product_data['meta'] = $product_meta = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
|
401 |
+
|
402 |
+
if ( !isset( $product_data['meta']['_wpsc_custom_tax'] ) )
|
403 |
+
$product_data['meta']['_wpsc_custom_tax'] = '';
|
404 |
+
$custom_tax = $product_data['meta']['_wpsc_custom_tax'];
|
405 |
+
|
406 |
+
|
407 |
+
if ( !isset( $product_meta['custom_tax'] ) ) {
|
408 |
+
$product_meta['custom_tax'] = 0.00;
|
409 |
+
}
|
410 |
+
|
411 |
+
//Add New WPEC-Taxes Bands Here
|
412 |
+
$wpec_taxes_controller = new wpec_taxes_controller();
|
413 |
+
|
414 |
+
//display tax bands
|
415 |
+
$band_select_settings = array(
|
416 |
+
'id' => 'wpec_taxes_band',
|
417 |
+
'name' => 'meta[_wpsc_product_metadata][wpec_taxes_band]',
|
418 |
+
'label' => __( 'Custom Tax Band', 'wp-e-commerce' )
|
419 |
+
);
|
420 |
+
$wpec_taxes_band = '';
|
421 |
+
if ( isset( $product_meta['wpec_taxes_band'] ) ) {
|
422 |
+
$band = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_band_from_index( $product_meta['wpec_taxes_band'] );
|
423 |
+
$wpec_taxes_band = array( 'index'=>$band['index'], 'name'=>$band['name'] );
|
424 |
+
}
|
425 |
+
|
426 |
+
$taxable_checkbox_settings = array(
|
427 |
+
'type' => 'checkbox',
|
428 |
+
'id' => 'wpec_taxes_taxable',
|
429 |
+
'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable]',
|
430 |
+
'label' => __( 'Product is exempt from taxation.', 'wp-e-commerce' )
|
431 |
+
);
|
432 |
+
|
433 |
+
if ( isset( $product_meta['wpec_taxes_taxable'] ) && 'on' == $product_meta['wpec_taxes_taxable'] ) {
|
434 |
+
$taxable_checkbox_settings['checked'] = 'checked';
|
435 |
+
}
|
436 |
+
|
437 |
+
//add taxable amount only for exclusive tax
|
438 |
+
if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) {
|
439 |
+
$taxable_amount_input_settings = array(
|
440 |
+
'id' => 'wpec_taxes_taxable_amount',
|
441 |
+
'name' => 'meta[_wpsc_product_metadata][wpec_taxes_taxable_amount]',
|
442 |
+
'label' => __( 'Taxable Amount', 'wp-e-commerce' ),
|
443 |
+
'description' => __( 'Taxable amount in your currency, not percentage of price.', 'wp-e-commerce' ),
|
444 |
+
);
|
445 |
+
|
446 |
+
if ( isset( $product_meta['wpec_taxes_taxable_amount'] ) ) {
|
447 |
+
$taxable_amount_input_settings['value'] = $product_meta['wpec_taxes_taxable_amount'];
|
448 |
+
|
449 |
+
if ( ! empty( $product_meta['wpec_taxes_taxable_amount'] ) )
|
450 |
+
$taxable_amount_input_settings['value'] = wpsc_format_number(
|
451 |
+
$taxable_amount_input_settings['value']
|
452 |
+
);
|
453 |
+
}
|
454 |
+
}// if
|
455 |
+
|
456 |
+
$output = '<a name="wpsc_tax"></a>';
|
457 |
+
$output .= '<p>'.$wpec_taxes_controller->wpec_taxes_build_input( $taxable_checkbox_settings ).'</p>';
|
458 |
+
$output .= '<p>'.$wpec_taxes_controller->wpec_taxes_display_tax_bands( $band_select_settings, $wpec_taxes_band ).'</p>';
|
459 |
+
$output .= '<p>';
|
460 |
+
$output .= ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) ? $wpec_taxes_controller->wpec_taxes_build_input( $taxable_amount_input_settings ) : '';
|
461 |
+
$output .= '</p>';
|
462 |
+
|
463 |
+
if ( ! $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_enabled() ) {
|
464 |
+
$output = '<p>' . sprintf( __( 'Taxes are not enabled. See <a href="%s">Settings > Taxes</a>', 'wp-e-commerce' ), admin_url( 'options-general.php?page=wpsc-settings&tab=taxes' ) ) . '</p>';
|
465 |
+
}
|
466 |
+
|
467 |
+
echo $output;
|
468 |
+
|
469 |
+
wp_nonce_field( 'update', 'wpsc_product_tax_nonce' );
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
function wpsc_product_variation_forms() {
|
474 |
+
?>
|
475 |
+
<iframe src="<?php echo _wpsc_get_product_variation_form_url(); ?>"></iframe>
|
476 |
+
<?php
|
477 |
+
}
|
478 |
+
|
479 |
+
function _wpsc_get_product_variation_form_url( $id = false ) {
|
480 |
+
if ( ! $id ) {
|
481 |
+
$id = get_the_ID();
|
482 |
+
}
|
483 |
+
|
484 |
+
return admin_url( 'admin-ajax.php?action=wpsc_product_variations_table&product_id=' . $id . '&_wpnonce=' . wp_create_nonce( 'wpsc_product_variations_table' ) );
|
485 |
+
}
|
486 |
+
|
487 |
+
function wpsc_product_shipping_forms_metabox() {
|
488 |
+
wpsc_product_shipping_forms();
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Dimension Units
|
493 |
+
*
|
494 |
+
* @since 3.8.13
|
495 |
+
*
|
496 |
+
* @return array List of valid dimension units.
|
497 |
+
*/
|
498 |
+
function wpsc_dimension_units() {
|
499 |
+
return array(
|
500 |
+
'in' => __( 'inches', 'wp-e-commerce' ),
|
501 |
+
'cm' => __( 'cm', 'wp-e-commerce' ),
|
502 |
+
'meter' => __( 'meters', 'wp-e-commerce' )
|
503 |
+
);
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Weight Units
|
508 |
+
*
|
509 |
+
* @since 3.8.13
|
510 |
+
*
|
511 |
+
* @return array List of valid weight units.
|
512 |
+
*/
|
513 |
+
function wpsc_weight_units() {
|
514 |
+
return array(
|
515 |
+
'pound' => __( 'pounds', 'wp-e-commerce' ),
|
516 |
+
'ounce' => __( 'ounces', 'wp-e-commerce' ),
|
517 |
+
'gram' => __( 'grams', 'wp-e-commerce' ),
|
518 |
+
'kilogram' => __( 'kilograms', 'wp-e-commerce' )
|
519 |
+
);
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Weight Unit Display
|
524 |
+
*
|
525 |
+
* Returns a weight unit abbreviation for display.
|
526 |
+
*
|
527 |
+
* @since 3.8.13
|
528 |
+
*
|
529 |
+
* @param string $unit Weight unit.
|
530 |
+
* @return string Weight unit string.
|
531 |
+
*/
|
532 |
+
function wpsc_weight_unit_display( $unit ) {
|
533 |
+
switch ( $unit ) {
|
534 |
+
case 'pound' :
|
535 |
+
return __( ' lbs.', 'wp-e-commerce' );
|
536 |
+
case 'ounce' :
|
537 |
+
return __( ' oz.', 'wp-e-commerce' );
|
538 |
+
case 'gram' :
|
539 |
+
return __( ' g', 'wp-e-commerce' );
|
540 |
+
case 'kilograms' :
|
541 |
+
case 'kilogram' :
|
542 |
+
return __( ' kgs.', 'wp-e-commerce' );
|
543 |
+
}
|
544 |
+
return '';
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Validate Dimension Unit
|
549 |
+
*
|
550 |
+
* Returns a valid dimensions unit.
|
551 |
+
* If the unit is not set or invalid it will be filtered using 'wpsc_default_dimension_unit'
|
552 |
+
* so that an alternative default unit can be set.
|
553 |
+
*
|
554 |
+
* @since 3.8.13
|
555 |
+
*
|
556 |
+
* @param string $unit Dimension unit.
|
557 |
+
* @return string Dimension unit string.
|
558 |
+
*
|
559 |
+
* @uses wpsc_default_dimension_unit
|
560 |
+
*/
|
561 |
+
function wpsc_validate_dimension_unit( $unit = '' ) {
|
562 |
+
|
563 |
+
$default_unit = apply_filters( 'wpsc_default_dimension_unit', $unit );
|
564 |
+
|
565 |
+
if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_dimension_units() ) ) {
|
566 |
+
$unit = $default_unit;
|
567 |
+
}
|
568 |
+
|
569 |
+
return $unit;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Validate Weight Unit
|
574 |
+
*
|
575 |
+
* Returns a valid weight unit.
|
576 |
+
* If the unit is not set or invalid it will be filtered using 'wpsc_default_weight_unit'
|
577 |
+
* so that an alternative default unit can be set.
|
578 |
+
*
|
579 |
+
* @since 3.8.13
|
580 |
+
*
|
581 |
+
* @param string $unit Weight unit.
|
582 |
+
* @return string Weight unit string.
|
583 |
+
*
|
584 |
+
* @uses wpsc_default_weight_unit
|
585 |
+
*/
|
586 |
+
function wpsc_validate_weight_unit( $unit = '' ) {
|
587 |
+
|
588 |
+
$default_unit = apply_filters( 'wpsc_default_weight_unit', $unit );
|
589 |
+
|
590 |
+
if ( empty( $unit ) && array_key_exists( $default_unit, wpsc_weight_units() ) ) {
|
591 |
+
$unit = $default_unit;
|
592 |
+
}
|
593 |
+
|
594 |
+
return $unit;
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Product Shipping Forms
|
599 |
+
*
|
600 |
+
* @uses wpsc_validate_weight_unit()
|
601 |
+
* @uses wpsc_validate_dimension_unit()
|
602 |
+
*/
|
603 |
+
function wpsc_product_shipping_forms( $product = false, $field_name_prefix = 'meta[_wpsc_product_metadata]', $bulk = false ) {
|
604 |
+
if ( ! $product )
|
605 |
+
$product_id = get_the_ID();
|
606 |
+
else
|
607 |
+
$product_id = $product->ID;
|
608 |
+
|
609 |
+
$meta = get_post_meta( $product_id, '_wpsc_product_metadata', true );
|
610 |
+
if ( ! is_array( $meta ) )
|
611 |
+
$meta = array();
|
612 |
+
|
613 |
+
$defaults = array(
|
614 |
+
'weight' => '',
|
615 |
+
'weight_unit' => wpsc_validate_weight_unit(),
|
616 |
+
'demension_unit' => wpsc_validate_dimension_unit(),
|
617 |
+
'dimensions' => array(),
|
618 |
+
'shipping' => array(),
|
619 |
+
'no_shipping' => '',
|
620 |
+
'display_weight_as' => '',
|
621 |
+
);
|
622 |
+
$dimensions_defaults = array(
|
623 |
+
'height' => 0,
|
624 |
+
'width' => 0,
|
625 |
+
'length' => 0,
|
626 |
+
);
|
627 |
+
$shipping_defaults = array(
|
628 |
+
'local' => '',
|
629 |
+
'international' => '',
|
630 |
+
);
|
631 |
+
$meta = array_merge( $defaults, $meta );
|
632 |
+
$meta['dimensions'] = array_merge( $dimensions_defaults, $meta['dimensions'] );
|
633 |
+
$meta['shipping'] = array_merge( $shipping_defaults, $meta['shipping'] );
|
634 |
+
|
635 |
+
extract( $meta, EXTR_SKIP );
|
636 |
+
|
637 |
+
foreach ( $shipping as $key => &$val ) {
|
638 |
+
$val = wpsc_format_number( $val );
|
639 |
+
}
|
640 |
+
|
641 |
+
$weight = wpsc_convert_weight( $weight, 'pound', $weight_unit );
|
642 |
+
|
643 |
+
$dimension_units = wpsc_dimension_units();
|
644 |
+
$weight_units = wpsc_weight_units();
|
645 |
+
|
646 |
+
// Why we need this????
|
647 |
+
$measurements = $dimensions;
|
648 |
+
$measurements['weight'] = $weight;
|
649 |
+
$measurements['weight_unit'] = $weight_unit;
|
650 |
+
// End why
|
651 |
+
|
652 |
+
?>
|
653 |
+
<div class="wpsc-stock-editor<?php if ( $bulk ) echo ' wpsc-bulk-edit' ?>">
|
654 |
+
<p class="wpsc-form-field">
|
655 |
+
<input type="checkbox" id="wpsc-product-no-shipping" name="<?php echo esc_attr( $field_name_prefix ); ?>[no_shipping]" value="1" <?php checked( $no_shipping && ! $bulk ); ?>>
|
656 |
+
<label for="wpsc-product-no-shipping"><?php _e( 'Product will <em>not</em> be shipped to customer', 'wp-e-commerce' ); ?></label>
|
657 |
+
</p>
|
658 |
+
|
659 |
+
<div class="wpsc-product-shipping-section wpsc-product-shipping-weight-dimensions">
|
660 |
+
<p><strong><?php esc_html_e( 'Calculate Shipping Costs based on measurements', 'wp-e-commerce' ); ?></strong></p>
|
661 |
+
|
662 |
+
<!-- WEIGHT INPUT -->
|
663 |
+
<p class="wpsc-form-field">
|
664 |
+
<?php if ( $bulk ) : ?>
|
665 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][weight]" value="1" />
|
666 |
+
<?php endif; ?>
|
667 |
+
<label for="wpsc-product-shipping-weight"><?php echo esc_html_e( 'Weight', 'wp-e-commerce' ); ?></label>
|
668 |
+
<span class="wpsc-product-shipping-input">
|
669 |
+
<input type="text" id="wpsc-product-shipping-weight" name="<?php echo esc_attr( $field_name_prefix ); ?>[weight]" value="<?php if ( ! $bulk ) echo esc_attr( wpsc_format_number( $weight ) ); ?>" />
|
670 |
+
<select id="wpsc-product-shipping-weight-unit" name="<?php echo $field_name_prefix; ?>[weight_unit]">
|
671 |
+
<?php foreach ( $weight_units as $unit => $unit_label ): ?>
|
672 |
+
<option value="<?php echo esc_attr( $unit ); ?>" <?php if ( ! $bulk ) selected( $unit, $measurements['weight_unit'] ); ?>><?php echo esc_html( $unit_label ); ?></option>
|
673 |
+
<?php endforeach; ?>
|
674 |
+
</select>
|
675 |
+
</span>
|
676 |
+
</p>
|
677 |
+
<!-- END WEIGHT INPUT -->
|
678 |
+
|
679 |
+
<!-- DIMENSIONS INPUT -->
|
680 |
+
<p class="wpsc-form-field">
|
681 |
+
<?php if ( $bulk ) : ?>
|
682 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][measurements][dimensions]" value="1" />
|
683 |
+
<?php endif; ?>
|
684 |
+
<label for="wpsc-product-shipping-weight"><?php echo esc_html_e( 'Dimensions', 'wp-e-commerce' ); ?></label>
|
685 |
+
<span class="wpsc-product-shipping-input">
|
686 |
+
<input placeholder="L" type="text" id="wpsc-product-shipping-length" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][length]" value="<?php if ( !$bulk && $dimensions['length']>0 ) echo esc_attr( wpsc_format_number( $dimensions['length'] ) ); ?>" /> ×
|
687 |
+
<input placeholder="W" type="text" id="wpsc-product-shipping-width" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][width]" value="<?php if ( !$bulk && $dimensions['width']>0 ) echo esc_attr( wpsc_format_number( $dimensions['width'] ) ); ?>" /> ×
|
688 |
+
<input placeholder="H" type="text" id="wpsc-product-shipping-height" name="<?php echo esc_attr( $field_name_prefix ); ?>[dimensions][height]" value="<?php if ( !$bulk && $dimensions['height']>0 ) echo esc_attr( wpsc_format_number( $dimensions['height'] ) ); ?>" />
|
689 |
+
<select id="wpsc-product-shipping-dimensions-unit" name="<?php echo $field_name_prefix; ?>[dimension_unit]">
|
690 |
+
<?php foreach ( $dimension_units as $unit => $unit_label ): ?>
|
691 |
+
<option value="<?php echo esc_attr( $unit ); ?>" <?php if ( ! $bulk && isset( $meta['dimension_unit'] ) ) selected( $unit, $meta['dimension_unit'] ); // Dirty code ?>><?php echo esc_html( $unit_label ); ?></option>
|
692 |
+
<?php endforeach; ?>
|
693 |
+
</select>
|
694 |
+
</span>
|
695 |
+
</p>
|
696 |
+
<!-- END DEMENSION INPUT -->
|
697 |
+
|
698 |
+
</div>
|
699 |
+
|
700 |
+
<?php
|
701 |
+
$currency_type = get_option( 'currency_type' );
|
702 |
+
$country = new WPSC_Country( $currency_type );
|
703 |
+
|
704 |
+
$ct_symb = $country->get_currency_symbol_html();
|
705 |
+
?>
|
706 |
+
|
707 |
+
<div class="wpsc-product-shipping-section wpsc-product-shipping-flat-rate">
|
708 |
+
<p><strong><?php esc_html_e( 'Flat Rate Settings', 'wp-e-commerce' ); ?></strong></p>
|
709 |
+
<p class="wpsc-form-field">
|
710 |
+
<?php if ( $bulk ): ?>
|
711 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][local]" value="1" />
|
712 |
+
<?php endif; ?>
|
713 |
+
<label for="wpsc-product-shipping-flatrate-local"><?php esc_html_e( 'Local Shipping Fee', 'wp-e-commerce' ); ?></label>
|
714 |
+
<span>
|
715 |
+
<?php echo esc_html( $ct_symb ); ?>
|
716 |
+
<input type="text" id="wpsc-product-shipping-flatrate-local" name="<?php echo esc_html( $field_name_prefix ); ?>[shipping][local]" value="<?php if ( ! $bulk ) echo $shipping['local']; ?>" />
|
717 |
+
</span>
|
718 |
+
</p>
|
719 |
+
<p class="wpsc-form-field">
|
720 |
+
<?php if ( $bulk ): ?>
|
721 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][shipping][international]" value="1" />
|
722 |
+
<?php endif; ?>
|
723 |
+
<label for="wpsc-product-shipping-flatrate-international"><?php esc_html_e( 'International Shipping Fee', 'wp-e-commerce' ); ?></label>
|
724 |
+
<span>
|
725 |
+
<?php echo esc_html( $ct_symb ); ?>
|
726 |
+
<input type="text" id="wpsc-product-shipping-flatrate-international" name="<?php echo esc_html( $field_name_prefix ); ?>[shipping][international]" value="<?php if ( ! $bulk ) echo $shipping['international']; ?>" />
|
727 |
+
</span>
|
728 |
+
</p>
|
729 |
+
</div>
|
730 |
+
</div>
|
731 |
+
<?php
|
732 |
+
|
733 |
+
wp_nonce_field( 'update', 'wpsc_product_shipping_nonce' );
|
734 |
+
|
735 |
+
}
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Product Custom Metadata Form
|
739 |
+
*
|
740 |
+
* @global $post Instance of WP_Post.
|
741 |
+
* @global $wpdb Instance of wpdb.
|
742 |
+
*/
|
743 |
+
function wpsc_product_advanced_forms() {
|
744 |
+
|
745 |
+
global $post, $wpdb;
|
746 |
+
|
747 |
+
$delete_nonce = _wpsc_create_ajax_nonce( 'remove_product_meta' );
|
748 |
+
|
749 |
+
$custom_fields = $wpdb->get_results( "
|
750 |
+
SELECT
|
751 |
+
`meta_id`, `meta_key`, `meta_value`
|
752 |
+
FROM
|
753 |
+
`{$wpdb->postmeta}`
|
754 |
+
WHERE
|
755 |
+
`post_id` = {$post->ID}
|
756 |
+
AND
|
757 |
+
`meta_key` NOT LIKE '\_%'
|
758 |
+
ORDER BY
|
759 |
+
LOWER(meta_key)", ARRAY_A
|
760 |
+
);
|
761 |
+
|
762 |
+
$output = '<table id="wpsc_product_meta_table" class="wp-list-table widefat posts">';
|
763 |
+
$output .= '<thead>';
|
764 |
+
$output .= '<tr>';
|
765 |
+
$output .= '<th id="wpsc_custom_meta_name_th">' . _x( 'Name', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
766 |
+
$output .= '<th id="wpsc_custom_meta_value_th">' . _x( 'Value', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
767 |
+
$output .= '<th id="wpsc_custom_meta_action_th">' . _x( 'Action', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
768 |
+
$output .= '</tr>';
|
769 |
+
$output .= '</thead>';
|
770 |
+
$output .= '<tfoot>';
|
771 |
+
$output .= '<tr>';
|
772 |
+
$output .= '<th>' . _x( 'Name', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
773 |
+
$output .= '<th>' . _x( 'Value', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
774 |
+
$output .= '<th>' . _x( 'Action', 'Product meta UI', 'wp-e-commerce' ) . '</th>';
|
775 |
+
$output .= '</tr>';
|
776 |
+
$output .= '</tfood>';
|
777 |
+
|
778 |
+
$output .= '<tbody>';
|
779 |
+
|
780 |
+
if ( empty( $custom_fields ) ) {
|
781 |
+
$output .= '<tr class="no-meta"><td colspan="3"><p>' . sprintf( __( 'You have no custom metadata. You can set any arbitrary meta you like and access it programatically via the <a href="">Post Meta API</a>.', 'wp-e-commerce' ), esc_url( 'https://codex.wordpress.org/Function_Reference/get_post_meta' ) ) . '</p></td></tr>';
|
782 |
+
} else {
|
783 |
+
// Display all available metadata
|
784 |
+
$alternate = false;
|
785 |
+
foreach ( (array) $custom_fields as $custom_field ) {
|
786 |
+
$i = $custom_field['meta_id'];
|
787 |
+
$alternate = ! $alternate;
|
788 |
+
|
789 |
+
$output .= '<tr'. ($alternate ? ' class="alternate"' : '') .'>';
|
790 |
+
$output .= '<td><input type="text" value="'.esc_attr( $custom_field['meta_key'] ).'" name="custom_meta['.$i.'][name]" id="custom_meta_name_'.$i.'"></input></td>';
|
791 |
+
$output .= '<td><input type="text" value="'.esc_attr( $custom_field['meta_value'] ).'" name="custom_meta['.$i.'][value]" id="custom_meta_value_'.$i.'"></input></td>';
|
792 |
+
$output .= '<td><a href="#" data-nonce="'.esc_attr( $delete_nonce ).'" class="wpsc_remove_meta" onclick="wpsc_remove_custom_meta(this,'.$i.')">'.esc_html( 'Delete', 'wp-e-commerce' ).'</a></td>';
|
793 |
+
$output .= '</tr>';
|
794 |
+
}
|
795 |
+
}
|
796 |
+
|
797 |
+
// Template for new metadata input
|
798 |
+
$output .= '<tr id="wpsc_new_meta_template">';
|
799 |
+
$output .= '<td><input type="text" name="new_custom_meta[name][]" value=""></input></td>';
|
800 |
+
$output .= '<td><input type="text" name="new_custom_meta[value][]" value=""></input></td>';
|
801 |
+
$output .= '<td><a href="#" class="wpsc_remove_meta" onclick="wpsc_remove_empty_meta(this)">'.esc_html( 'Delete', 'wp-e-commerce' ).'</a></td>';
|
802 |
+
$output .= '</tr>';
|
803 |
+
|
804 |
+
$output .= '</tbody>';
|
805 |
+
$output .= '</table>';
|
806 |
+
|
807 |
+
$output .= '<a href="#" class="add_more_meta button button-small" id="wpsc_add_custom_meta">'.esc_html( '+ Add Custom Meta', 'wp-e-commerce' ).'</a>';
|
808 |
+
|
809 |
+
echo $output;
|
810 |
+
|
811 |
+
}
|
812 |
+
|
813 |
+
/**
|
814 |
+
* Display Product External Link Meta Box Form Fields.
|
815 |
+
*
|
816 |
+
* @global $post Instance of WP_Post.
|
817 |
+
*/
|
818 |
+
function wpsc_product_external_link_forms() {
|
819 |
+
|
820 |
+
global $post;
|
821 |
+
|
822 |
+
// Get External Link Values
|
823 |
+
$product_meta = get_post_meta( $post->ID, '_wpsc_product_metadata', true );
|
824 |
+
$product_meta = wp_parse_args( $product_meta, array(
|
825 |
+
'external_link' => '',
|
826 |
+
'external_link_text' => '',
|
827 |
+
'external_link_target' => ''
|
828 |
+
) );
|
829 |
+
|
830 |
+
?>
|
831 |
+
<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
|
832 |
+
<tbody>
|
833 |
+
<tr class="form-field">
|
834 |
+
<th valign="top" scope="row"><label for="external_link"><?php esc_html_e( 'URL', 'wp-e-commerce' ); ?></label></th>
|
835 |
+
<td><input type="text" name="meta[_wpsc_product_metadata][external_link]" id="external_link" value="<?php echo esc_url( $product_meta['external_link'] ); ?>" size="50" style="width: 95%" placeholder="http://" /></td>
|
836 |
+
</tr>
|
837 |
+
<tr class="form-field">
|
838 |
+
<th valign="top" scope="row"><label for="external_link_text"><?php esc_html_e( 'Label', 'wp-e-commerce' ); ?></label></th>
|
839 |
+
<td><input type="text" name="meta[_wpsc_product_metadata][external_link_text]" id="external_link_text" value="<?php echo esc_attr( $product_meta['external_link_text'] ); ?>" size="50" style="width: 95%" placeholder="<?php _e( 'Buy Now', 'wp-e-commerce' ); ?>" /></td>
|
840 |
+
</tr>
|
841 |
+
<tr class="form-field">
|
842 |
+
<th valign="top" scope="row"><label for="external_link_target"><?php esc_html_e( 'Target', 'wp-e-commerce' ); ?></label></th>
|
843 |
+
<td id="external_link_target">
|
844 |
+
|
845 |
+
<label>
|
846 |
+
<input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value=""<?php checked( '', $product_meta['external_link_target'] ); ?> />
|
847 |
+
<?php _ex( 'Default (set by theme)', 'External product link target', 'wp-e-commerce' ); ?>
|
848 |
+
</label>
|
849 |
+
|
850 |
+
<label>
|
851 |
+
<input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value="_self"<?php checked( '_self', $product_meta['external_link_target'] ); ?> />
|
852 |
+
<?php esc_html_e( 'Force open in same window', 'wp-e-commerce' ); ?>
|
853 |
+
</label>
|
854 |
+
|
855 |
+
<label>
|
856 |
+
<input type="radio" name="meta[_wpsc_product_metadata][external_link_target]" value="_blank"<?php checked( '_blank', $product_meta['external_link_target'] ); ?> />
|
857 |
+
<?php esc_html_e( 'Force open in new window', 'wp-e-commerce' ); ?>
|
858 |
+
</label>
|
859 |
+
|
860 |
+
</td>
|
861 |
+
</tr>
|
862 |
+
</tbody>
|
863 |
+
</table>
|
864 |
+
<em><?php esc_html_e( 'This option overrides the "Buy Now" and "Add to Cart" buttons, replacing them with the link you describe here.', 'wp-e-commerce' ); ?></em>
|
865 |
+
<?php
|
866 |
+
|
867 |
+
wp_nonce_field( 'update', 'wpsc_product_external_link_nonce' );
|
868 |
+
|
869 |
+
}
|
870 |
+
|
871 |
+
function wpsc_additional_desc() {
|
872 |
+
?>
|
873 |
+
<textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php echo esc_textarea( get_post_field( 'post_excerpt', get_the_ID() ) ); ?></textarea>
|
874 |
+
<em><?php _e( 'Short Descriptions are optional hand-crafted summaries of your content that can be used in your theme.', 'wp-e-commerce' ); ?></em>
|
875 |
+
<?php
|
876 |
+
|
877 |
+
}
|
878 |
+
|
879 |
+
/**
|
880 |
+
* We really need to either bake this functionality in for 3.9.0 or rip it out into Gold Cart or something else.
|
881 |
+
* So not awesome to have this exposed and unusable.
|
882 |
+
*
|
883 |
+
* @param WP_Post $post Product
|
884 |
+
* @return void
|
885 |
+
*/
|
886 |
+
function wpsc_product_gallery( $post ) {
|
887 |
+
// pull the old iframe source for non JS users
|
888 |
+
$upload_iframe_src = esc_url( get_upload_iframe_src( 'image', $post->ID ) );
|
889 |
+
// get our gallery image IDs if present
|
890 |
+
$images = wpsc_get_admin_product_gallery( $post->ID );
|
891 |
+
// begin HTML output
|
892 |
+
$output = '<div id="wpsc_product_gallery">';
|
893 |
+
$output .= '<ul>';
|
894 |
+
// check for images before beginngin loop
|
895 |
+
if ( $images ) {
|
896 |
+
// now loop images
|
897 |
+
foreach ( $images as $image_id ) {
|
898 |
+
// get the thumbnail URL
|
899 |
+
$thumb_url = wp_get_attachment_thumb_url( absint( $image_id ) );
|
900 |
+
// output each item
|
901 |
+
$output .= '<li><div class="list_gallery_image">';
|
902 |
+
$output .= '<img src="' . esc_url( $thumb_url ) . '">';
|
903 |
+
$output .= '<input type="hidden" name="wpsc-product-gallery-imgs[]" value="' . absint( $image_id ) . '">';
|
904 |
+
|
905 |
+
$output .= '<span class="product_gallery_image_delete_button dashicons dashicons-no-alt"></span></div>';
|
906 |
+
$output .= '<input type="hidden" class="product_gallery_image_id" value="'.$image_id.'">';
|
907 |
+
$output .= '<input type="hidden" class="product_gallery_post_id" value="'.$post->ID.'">';
|
908 |
+
$output .= '</li>';
|
909 |
+
}
|
910 |
+
}
|
911 |
+
$output .= '</ul>';
|
912 |
+
$output .= '<div class="clear"></div>';
|
913 |
+
$output .= '</div>';
|
914 |
+
$nonce_var = wp_create_nonce( 'wpsc_gallery_nonce' );
|
915 |
+
?>
|
916 |
+
<input type="hidden" class="nonce_class" value="<?php echo $nonce_var; ?>">
|
917 |
+
<?php
|
918 |
+
// button for old iframe for non JS people
|
919 |
+
$output .= '<p class="hide-if-no-js">';
|
920 |
+
$output .= '<a class="button button-small thickbox" title="' . esc_attr__( 'Manage Product Image Gallery...', 'wp-e-commerce' ).'" href="' . $upload_iframe_src . '" id="wpsc-manage-product-gallery">';
|
921 |
+
$output .= esc_html__( 'Manage Product Image Gallery...', 'wp-e-commerce' );
|
922 |
+
$output .= '</a>';
|
923 |
+
$output .= '</p>';
|
924 |
+
|
925 |
+
// include a nonce for verification
|
926 |
+
$output .= wp_nonce_field( 'wpsc_product_gallery_nonce', 'wpsc_product_gallery_nonce', false, false );
|
927 |
+
|
928 |
+
// echo the gallery output
|
929 |
+
echo $output;
|
930 |
+
}
|
931 |
+
|
932 |
+
|
933 |
+
function wpsc_product_download_forms() {
|
934 |
+
global $post, $wpdb, $wpsc_product_defaults;
|
935 |
+
$product_data = get_post_custom( $post->ID );
|
936 |
+
$output = '';
|
937 |
+
$product_data['meta'] = array();
|
938 |
+
|
939 |
+
if ( !empty( $product_data['_wpsc_product_metadata'] ) )
|
940 |
+
$product_data['meta'] = maybe_unserialize( $product_data['_wpsc_product_metadata'][0] );
|
941 |
+
|
942 |
+
$upload_max = wpsc_get_max_upload_size();
|
943 |
+
?>
|
944 |
+
<?php echo wpsc_select_product_file( $post->ID ); ?>
|
945 |
+
|
946 |
+
<a href="admin.php?wpsc_admin_action=product_files_existing&product_id=<?php echo absint( $post->ID ); ?>" class="thickbox button button-small" title="<?php echo esc_attr( sprintf( __( 'Select all downloadable files for %s', 'wp-e-commerce' ), $post->post_title ) ); ?>"><?php esc_html_e( 'Add existing files...', 'wp-e-commerce' ); ?></a>
|
947 |
+
|
948 |
+
<div class="wpsc_fileUpload button button-small">
|
949 |
+
<span><?php esc_html_e('Upload new file...','wp-e-commerce'); ?></span>
|
950 |
+
<input type='file' name='file' class="button button-small" value='' onchange="wpsc_push_v2t(this, '#wpsc_fileupload_path')" />
|
951 |
+
</div>
|
952 |
+
<em id="wpsc_fileupload_path"></em>
|
953 |
+
|
954 |
+
<?php
|
955 |
+
if ( function_exists( "make_mp3_preview" ) || function_exists( "wpsc_media_player" ) ) {
|
956 |
+
?>
|
957 |
+
<br />
|
958 |
+
<h4><?php esc_html_e( 'Select an MP3 file to upload as a preview', 'wp-e-commerce' ) ?></h4>
|
959 |
+
<input type='file' name='preview_file' value='' /><br />
|
960 |
+
|
961 |
+
<h4><?php esc_html_e( 'Your preview for this product', 'wp-e-commerce' ) ?>:</h4>
|
962 |
+
|
963 |
+
<?php
|
964 |
+
$args = array(
|
965 |
+
'post_type' => 'wpsc-preview-file',
|
966 |
+
'post_parent' => $post->ID,
|
967 |
+
'numberposts' => -1,
|
968 |
+
'post_status' => 'all'
|
969 |
+
);
|
970 |
+
|
971 |
+
$preview_files = (array) get_posts( $args );
|
972 |
+
|
973 |
+
foreach ( $preview_files as $preview ) {
|
974 |
+
echo $preview->post_title . '<br />';
|
975 |
+
}
|
976 |
+
|
977 |
+
?>
|
978 |
+
<br />
|
979 |
+
<?php
|
980 |
+
}
|
981 |
+
|
982 |
+
$output = apply_filters( 'wpsc_downloads_metabox', $output );
|
983 |
+
}
|
984 |
+
|
985 |
+
/**
|
986 |
+
* Product Personalization Form
|
987 |
+
*
|
988 |
+
* @global $post Instance of WP_Post.
|
989 |
+
*/
|
990 |
+
function wpsc_product_personalization_forms() {
|
991 |
+
|
992 |
+
global $post;
|
993 |
+
|
994 |
+
$product_meta = get_post_meta( $post->ID, '_wpsc_product_metadata', true );
|
995 |
+
$product_meta = wp_parse_args( $product_meta, array(
|
996 |
+
'engraved' => 0,
|
997 |
+
'can_have_uploaded_image' => 0
|
998 |
+
) );
|
999 |
+
|
1000 |
+
?>
|
1001 |
+
<ul id="wpsc_product_personalization_option">
|
1002 |
+
<li>
|
1003 |
+
<input type="checkbox" name="meta[_wpsc_product_metadata][engraved]" <?php checked( $product_meta['engraved'], '1' ); ?> id="add_engrave_text" />
|
1004 |
+
<label for="add_engrave_text"><?php esc_html_e( 'Users can personalize this product by leaving a message on single product page', 'wp-e-commerce' ); ?></label>
|
1005 |
+
</li>
|
1006 |
+
<li>
|
1007 |
+
<input type="checkbox" name="meta[_wpsc_product_metadata][can_have_uploaded_image]" <?php checked( $product_meta['can_have_uploaded_image'], '1' ); ?> id="can_have_uploaded_image" />
|
1008 |
+
<label for="can_have_uploaded_image"> <?php esc_html_e( 'Users can upload images on single product page to purchase logs.', 'wp-e-commerce' ); ?></label>
|
1009 |
+
</li>
|
1010 |
+
<?php do_action( 'wpsc_add_advanced_options', $post->ID ); ?>
|
1011 |
+
</ul>
|
1012 |
+
<em><?php _e( "Form fields for the customer to personalize this product will be shown on it's single product page.", 'wp-e-commerce' ); ?></em>
|
1013 |
+
<?php
|
1014 |
+
|
1015 |
+
wp_nonce_field( 'update', 'wpsc_product_personalization_nonce' );
|
1016 |
+
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
function wpsc_product_delivery_forms(){
|
1020 |
+
$has_variations = wpsc_product_has_variations( get_post()->ID );
|
1021 |
+
|
1022 |
+
$show_if_variation = $has_variations ? 'display: block;' : 'display:none;';
|
1023 |
+
?>
|
1024 |
+
<em id="wpsc_product_delivery_metabox_live_title" class="wpsc_metabox_live_title">
|
1025 |
+
<p></p>
|
1026 |
+
</em>
|
1027 |
+
|
1028 |
+
<div id="wpsc_product_delivery_forms" class="categorydiv wpsc-categorydiv">
|
1029 |
+
<ul id="wpsc_product_delivery_tabs" class="category-tabs">
|
1030 |
+
<li class="tabs"><a href="#wpsc_product_delivery-shipping"><?php _e( 'Shipping', 'wp-e-commerce' ); ?></a></li>
|
1031 |
+
<li><a href="#wpsc_product_delivery-download"><?php _e( 'Download', 'wp-e-commerce' ); ?></a></li>
|
1032 |
+
<li><a href="#wpsc_product_delivery-external_link"><?php _e( 'External Link', 'wp-e-commerce' ); ?></a></li>
|
1033 |
+
</ul>
|
1034 |
+
|
1035 |
+
<div id="wpsc_product_delivery-shipping" class="tabs-panel" style="display:block;">
|
1036 |
+
<?php
|
1037 |
+
if ( ! $has_variations ) {
|
1038 |
+
wpsc_product_shipping_forms();
|
1039 |
+
} else {
|
1040 |
+
echo '<p>' . sprintf( __( 'This product has variations. To edit the shipping, please use the <a href="%s">Variation Controls</a>.', 'wp-e-commerce' ), '#wpsc_product_variation_forms' ) . '</p>';
|
1041 |
+
}
|
1042 |
+
?>
|
1043 |
+
</div>
|
1044 |
+
|
1045 |
+
<div id="wpsc_product_delivery-download" class="tabs-panel" style="display:none;">
|
1046 |
+
<?php wpsc_product_download_forms(); ?>
|
1047 |
+
</div>
|
1048 |
+
|
1049 |
+
<div id="wpsc_product_delivery-external_link" class="tabs-panel" style="display: none;">
|
1050 |
+
<?php wpsc_product_external_link_forms(); ?>
|
1051 |
+
</div>
|
1052 |
+
</div>
|
1053 |
+
<?php
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
function wpsc_product_details_forms(){
|
1057 |
+
?>
|
1058 |
+
<em id="wpsc_product_details_metabox_live_title" class="wpsc_metabox_live_title">
|
1059 |
+
<p></p>
|
1060 |
+
</em>
|
1061 |
+
|
1062 |
+
<div id="wpsc_product_details_forms" class="categorydiv wpsc-categorydiv">
|
1063 |
+
<ul id="wpsc_product_details_tabs" class="category-tabs">
|
1064 |
+
<li class="tabs"><a href="#wpsc_product_details-image"><?php _e( 'Image Gallery', 'wp-e-commerce' ); ?></a></li>
|
1065 |
+
<li><a href="#wpsc_product_details-desc"><?php _e( 'Short Description', 'wp-e-commerce' ); ?></a></li>
|
1066 |
+
<li><a href="#wpsc_product_details-personalization"><?php _e( 'Personalization', 'wp-e-commerce' ); ?></a></li>
|
1067 |
+
<li><a href="#wpsc_product_details-meta"><?php _e( 'Metadata', 'wp-e-commerce' ); ?></a></li>
|
1068 |
+
</ul>
|
1069 |
+
|
1070 |
+
<div id="wpsc_product_details-image" class="tabs-panel" style="display: block;">
|
1071 |
+
<?php wpsc_product_gallery( get_post() ); ?>
|
1072 |
+
</div>
|
1073 |
+
|
1074 |
+
<div id="wpsc_product_details-desc" class="tabs-panel" style="display: none;">
|
1075 |
+
<?php wpsc_additional_desc(); ?>
|
1076 |
+
</div>
|
1077 |
+
|
1078 |
+
<div id="wpsc_product_details-personalization" class="tabs-panel" style="display: none;">
|
1079 |
+
<?php wpsc_product_personalization_forms(); ?>
|
1080 |
+
</div>
|
1081 |
+
|
1082 |
+
<div id="wpsc_product_details-meta" class="tabs-panel" style="display: none;">
|
1083 |
+
<?php wpsc_product_advanced_forms(); ?>
|
1084 |
+
</div>
|
1085 |
+
</div>
|
1086 |
+
<?php
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
function wpsc_form_multipart_encoding() {
|
1090 |
+
echo ' enctype="multipart/form-data"';
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
add_action( 'post_edit_form_tag', 'wpsc_form_multipart_encoding' );
|
1094 |
+
|
1095 |
+
/*
|
1096 |
+
* Modifications to Media Gallery
|
1097 |
+
*/
|
1098 |
+
|
1099 |
+
add_filter( 'attachment_fields_to_edit', 'wpsc_attachment_fields', 11, 2 );
|
1100 |
+
add_filter( 'attachment_fields_to_save', 'wpsc_save_attachment_fields', 9, 2 );
|
1101 |
+
add_filter( 'gettext_with_context', 'wpsc_filter_gettex_with_context', 12, 4);
|
1102 |
+
|
1103 |
+
/*
|
1104 |
+
* This filter overrides string with context translations
|
1105 |
+
*
|
1106 |
+
* @param $translation The current translation
|
1107 |
+
* @param $text The text being translated
|
1108 |
+
* @param $context The domain for the translation
|
1109 |
+
* @param $domain The domain for the translation
|
1110 |
+
* @return string The translated / filtered text.
|
1111 |
+
*/
|
1112 |
+
function wpsc_filter_gettex_with_context( $translation, $text, $context, $domain ) {
|
1113 |
+
|
1114 |
+
if ( 'Taxonomy Parent' == $context && 'Parent' == $text && isset($_GET['taxonomy']) && 'wpsc-variation' == $_GET['taxonomy'] ) {
|
1115 |
+
$translations = get_translations_for_domain( $domain );
|
1116 |
+
return $translations->translate( 'Variation Set', 'wp-e-commerce' );
|
1117 |
+
//this will never happen, this is here only for gettext to pick up the translation
|
1118 |
+
return __( 'Variation Set', 'wp-e-commerce' );
|
1119 |
+
}
|
1120 |
+
return $translation;
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
function wpsc_attachment_fields( $form_fields, $post ) {
|
1124 |
+
$out = '';
|
1125 |
+
|
1126 |
+
if( isset( $_REQUEST["post_id"] ) )
|
1127 |
+
$parent_post = get_post( absint( $_REQUEST["post_id"] ) );
|
1128 |
+
else
|
1129 |
+
$parent_post = get_post( $post->post_parent );
|
1130 |
+
|
1131 |
+
// check if post is set before accessing
|
1132 |
+
if ( isset( $parent_post ) && $parent_post->post_type == "wpsc-product" ) {
|
1133 |
+
|
1134 |
+
//Unfortunate hack, as I'm not sure why the From Computer tab doesn't process filters the same way the Gallery does
|
1135 |
+
ob_start();
|
1136 |
+
echo '
|
1137 |
+
<script type="text/javascript">
|
1138 |
+
|
1139 |
+
jQuery(function(){
|
1140 |
+
|
1141 |
+
jQuery("a.wp-post-thumbnail").each(function(){
|
1142 |
+
var product_image = jQuery(this).text();
|
1143 |
+
if (product_image == "' . esc_js( __( 'Use as featured image', 'wp-e-commerce' ) ) . '") {
|
1144 |
+
jQuery(this).text("' . esc_js( __('Use as Product Thumbnail', 'wp-e-commerce' ) ) . '");
|
1145 |
+
}
|
1146 |
+
});
|
1147 |
+
|
1148 |
+
var trash = jQuery("#media-upload a.del-link").text();
|
1149 |
+
|
1150 |
+
if (trash == "' . esc_js( __( 'Delete', 'wp-e-commerce' ) ) . '") {
|
1151 |
+
jQuery("#media-upload a.del-link").text("' . esc_js( __( 'Trash', 'wp-e-commerce' ) ) . '");
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
|
1155 |
+
});
|
1156 |
+
|
1157 |
+
</script>';
|
1158 |
+
$out .= ob_get_clean();
|
1159 |
+
|
1160 |
+
$size_names = array( 'small-product-thumbnail' => __( 'Default Product Thumbnail Size', 'wp-e-commerce' ), 'medium-single-product' => __( 'Single Product Image Size', 'wp-e-commerce' ), 'full' => __( 'Full Size', 'wp-e-commerce' ) );
|
1161 |
+
|
1162 |
+
$check = get_post_meta( $post->ID, '_wpsc_selected_image_size', true );
|
1163 |
+
if ( !$check )
|
1164 |
+
$check = 'medium-single-product';
|
1165 |
+
|
1166 |
+
$current_size = image_get_intermediate_size( $post->ID, $check );
|
1167 |
+
$settings_width = get_option( 'single_view_image_width' );
|
1168 |
+
$settings_height = get_option( 'single_view_image_height' );
|
1169 |
+
|
1170 |
+
// regenerate size metadata in case it's missing
|
1171 |
+
if ( ! $check || ( $current_size['width'] != $settings_width && $current_size['height'] != $settings_height ) ) {
|
1172 |
+
_wpsc_regenerate_thumbnail_size( $post->ID, $check );
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
//This loop attaches the custom thumbnail/single image sizes to this page
|
1176 |
+
foreach ( $size_names as $size => $name ) {
|
1177 |
+
$downsize = image_downsize( $post->ID, $size );
|
1178 |
+
// is this size selectable?
|
1179 |
+
$enabled = ( $downsize[3] || 'full' == $size );
|
1180 |
+
$css_id = "image-size-{$size}-{$post->ID}";
|
1181 |
+
// if this size is the default but that's not available, don't select it
|
1182 |
+
|
1183 |
+
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][wpsc_image_size]' id='{$css_id}' value='{$size}' " . checked( $size, $check, false ) . " />";
|
1184 |
+
|
1185 |
+
$html .= "<label for='{$css_id}'>$name</label>";
|
1186 |
+
// only show the dimensions if that choice is available
|
1187 |
+
if ( $enabled )
|
1188 |
+
$html .= " <label for='{$css_id}' class='help'>" . sprintf( __( "(%d × %d)", 'wp-e-commerce' ), $downsize[1], $downsize[2] ). "</label>";
|
1189 |
+
|
1190 |
+
$html .= '</div>';
|
1191 |
+
|
1192 |
+
$out .= $html;
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
unset( $form_fields['post_excerpt'], $form_fields['image_url'], $form_fields['post_content'], $form_fields['post_title'], $form_fields['url'], $form_fields['align'], $form_fields['image_alt']['helps'], $form_fields["image-size"] );
|
1196 |
+
$form_fields['image_alt']['helps'] = __( 'Alt text for the product image, e.g. “Rockstar T-Shirt”', 'wp-e-commerce' );
|
1197 |
+
|
1198 |
+
$form_fields["wpsc_image_size"] = array(
|
1199 |
+
'label' => __( 'Single Product Page Thumbnail:', 'wp-e-commerce' ),
|
1200 |
+
'input' => 'html',
|
1201 |
+
'html' => $out,
|
1202 |
+
'helps' => "<span style='text-align:left; clear:both; display:block; padding-top:3px;'>" . __( 'This is the Thumbnail size that will be displayed on the Single Product page. You can change the default sizes under your store settings', 'wp-e-commerce' ) . "</span>"
|
1203 |
+
);
|
1204 |
+
|
1205 |
+
//This is for the custom thumbnail size.
|
1206 |
+
|
1207 |
+
$custom_thumb_size_w = get_post_meta( $post->ID, "_wpsc_custom_thumb_w", true );
|
1208 |
+
$custom_thumb_size_h = get_post_meta( $post->ID, "_wpsc_custom_thumb_h", true );
|
1209 |
+
$custom_thumb_html = "
|
1210 |
+
|
1211 |
+
<input style='width:50px; text-align:center' type='text' name='attachments[{$post->ID}][wpsc_custom_thumb_w]' value='{$custom_thumb_size_w}' /> X <input style='width:50px; text-align:center' type='text' name='attachments[{$post->ID}][wpsc_custom_thumb_h]' value='{$custom_thumb_size_h}' />
|
1212 |
+
|
1213 |
+
";
|
1214 |
+
$form_fields["wpsc_custom_thumb"] = array(
|
1215 |
+
"label" => __( 'Products Page Thumbnail Size:', 'wp-e-commerce' ),
|
1216 |
+
"input" => "html", // this is default if "input" is omitted
|
1217 |
+
"helps" => "<span style='text-align:left; clear:both; display:block; padding-top:3px;'>" . __( 'Custom thumbnail size for this image on the main Product Page', 'wp-e-commerce') . "</span>",
|
1218 |
+
"html" => $custom_thumb_html
|
1219 |
+
);
|
1220 |
+
}
|
1221 |
+
return $form_fields;
|
1222 |
+
|
1223 |
+
}
|
1224 |
+
function wpsc_save_attachment_fields( $post, $attachment ) {
|
1225 |
+
|
1226 |
+
if ( isset( $attachment['wpsc_custom_thumb_w'] ) ) {
|
1227 |
+
update_post_meta( $post['ID'], '_wpsc_custom_thumb_w', $attachment['wpsc_custom_thumb_w'] );
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
if ( isset( $attachment['wpsc_custom_thumb_h'] ) ) {
|
1231 |
+
update_post_meta( $post['ID'], '_wpsc_custom_thumb_h', $attachment['wpsc_custom_thumb_h'] );
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
if ( isset( $attachment['wpsc_image_size'] ) ) {
|
1235 |
+
update_post_meta( $post['ID'], '_wpsc_selected_image_size', $attachment['wpsc_image_size'] );
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
return $post;
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
/**
|
1242 |
+
* Save Product Quick Edit Box
|
1243 |
+
*
|
1244 |
+
* Saves input for the various meta in the quick edit boxes.
|
1245 |
+
*
|
1246 |
+
* @todo UI.
|
1247 |
+
* @todo Data validation / sanitization / security.
|
1248 |
+
* @todo AJAX should probably return weight unit.
|
1249 |
+
*
|
1250 |
+
* @return int $post_id Post ID.
|
1251 |
+
*/
|
1252 |
+
function wpsc_save_quickedit_box( $post_id ) {
|
1253 |
+
|
1254 |
+
global $doaction;
|
1255 |
+
|
1256 |
+
// Only save product if saving (not autosaving) via AJAX.
|
1257 |
+
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || get_post_type( $post_id ) != 'wpsc-product' ) {
|
1258 |
+
return;
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
$bulk = isset( $doaction ) && $doaction == 'edit';
|
1262 |
+
|
1263 |
+
// Map post field to meta key.
|
1264 |
+
$custom_fields = array(
|
1265 |
+
'weight' => 'product_metadata',
|
1266 |
+
'stock' => 'stock',
|
1267 |
+
'price' => 'price',
|
1268 |
+
'sale_price' => 'special_price',
|
1269 |
+
'sku' => 'sku'
|
1270 |
+
);
|
1271 |
+
|
1272 |
+
// Get product variations (if any).
|
1273 |
+
$children = get_children( array(
|
1274 |
+
'post_parent' => $post_id,
|
1275 |
+
'post_type' => 'wpsc-product',
|
1276 |
+
'post_status' => 'inherit'
|
1277 |
+
) );
|
1278 |
+
$is_parent = (bool) $children;
|
1279 |
+
|
1280 |
+
foreach ( $custom_fields as $post_key => $meta_key ) {
|
1281 |
+
|
1282 |
+
// Don't update if field is not set or we're bulk updating and the field is left blank.
|
1283 |
+
if ( ! isset( $_REQUEST[ $post_key ] ) || ( $bulk && empty( $_REQUEST[ $post_key ] ) ) ) {
|
1284 |
+
continue;
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
// Don't update if the product has variations and the field is one of the defined custom fields (unless overridden).
|
1288 |
+
$override_variant = isset( $_REQUEST[ $post_key . '_variant' ] ) && $_REQUEST[ $post_key . '_variant' ] == 'on';
|
1289 |
+
if ( $is_parent && ! $override_variant && in_array( $post_key, array_keys( $custom_fields ) ) ) {
|
1290 |
+
continue;
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
// Select single product or variation IDs.
|
1294 |
+
if ( $is_parent && count( $children ) > 0 ) {
|
1295 |
+
$products = wp_list_pluck( $children, 'ID' );
|
1296 |
+
} else {
|
1297 |
+
$products = array( $post_id );
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
foreach ( $products as $post_id ) {
|
1301 |
+
$value = $_REQUEST[ $post_key ];
|
1302 |
+
|
1303 |
+
// Validate custom field values
|
1304 |
+
switch ( $post_key ) {
|
1305 |
+
|
1306 |
+
case 'weight':
|
1307 |
+
$product_meta = get_post_meta( $post_id, '_wpsc_product_metadata', true );
|
1308 |
+
if ( ! is_array( $product_meta ) ) {
|
1309 |
+
$product_meta = array();
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
// Draft products don't have product metadata set yet
|
1313 |
+
$weight_unit = isset( $product_meta['weight_unit'] ) ? $product_meta['weight_unit'] : 'pound';
|
1314 |
+
$weight = wpsc_convert_weight( $value, $weight_unit, 'pound', true );
|
1315 |
+
|
1316 |
+
if ( isset( $product_meta['weight'] ) ) {
|
1317 |
+
unset( $product_meta['weight'] );
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
$product_meta['weight'] = $weight;
|
1321 |
+
|
1322 |
+
$value = $product_meta;
|
1323 |
+
break;
|
1324 |
+
|
1325 |
+
case 'stock':
|
1326 |
+
if ( ! is_numeric( $value ) ) {
|
1327 |
+
$value = '';
|
1328 |
+
}
|
1329 |
+
break;
|
1330 |
+
|
1331 |
+
case 'sku':
|
1332 |
+
if ( $value == __( 'N/A', 'wp-e-commerce' ) ) {
|
1333 |
+
$value = '';
|
1334 |
+
} else {
|
1335 |
+
$value = sanitize_text_field( $value );
|
1336 |
+
}
|
1337 |
+
break;
|
1338 |
+
default :
|
1339 |
+
$value = sanitize_text_field( $value );
|
1340 |
+
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
update_post_meta( $post_id, "_wpsc_{$meta_key}", $value );
|
1344 |
+
}
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
return $post_id;
|
1348 |
+
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
/**
|
1352 |
+
* wpsc_quick_edit_boxes function
|
1353 |
+
* Creates inputs for the various meta in the quick edit boxes.
|
1354 |
+
*
|
1355 |
+
* @todo UI
|
1356 |
+
* @internal The post_id cannot be accessed here because this gets output at the very end
|
1357 |
+
* of the editor form, and injected within relevant rows using javascript.
|
1358 |
+
*/
|
1359 |
+
|
1360 |
+
function wpsc_quick_edit_boxes( $col_name, $_screen_post_type = null ) {
|
1361 |
+
// Avoid outputting this on term edit screens.
|
1362 |
+
// See http://core.trac.wordpress.org/ticket/16392#comment:9
|
1363 |
+
if ( current_filter() == 'quick_edit_custom_box' && $_screen_post_type == 'edit-tags' )
|
1364 |
+
return;
|
1365 |
+
?>
|
1366 |
+
|
1367 |
+
<fieldset class="inline-edit-col-left wpsc-cols">
|
1368 |
+
<div class="inline-edit-col">
|
1369 |
+
<div class="inline-edit-group">
|
1370 |
+
<?php
|
1371 |
+
switch ( $col_name ) :
|
1372 |
+
case 'SKU' :
|
1373 |
+
?>
|
1374 |
+
<label style="max-width: 85%" class="alignleft">
|
1375 |
+
<span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'SKU:', 'wp-e-commerce' ); ?> </span>
|
1376 |
+
<input type="text" name="sku" class="wpsc_ie_sku" />
|
1377 |
+
<input type="checkbox" name="sku_variant"> <span><?php esc_html_e( 'Update Variants', 'wp-e-commerce');?></span>
|
1378 |
+
|
1379 |
+
</label>
|
1380 |
+
<?php
|
1381 |
+
break;
|
1382 |
+
case 'weight' :
|
1383 |
+
?>
|
1384 |
+
<label style="max-width: 85%" class="alignleft">
|
1385 |
+
<span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Weight:', 'wp-e-commerce' ); ?> </span>
|
1386 |
+
<input type="text" name="weight" class="wpsc_ie_weight" />
|
1387 |
+
<input type="checkbox" name="weight_variant"> <span><?php esc_html_e( 'Update Variants', 'wp-e-commerce');?></span>
|
1388 |
+
</label>
|
1389 |
+
<?php
|
1390 |
+
break;
|
1391 |
+
case 'stock' :
|
1392 |
+
?>
|
1393 |
+
<label style="max-width: 85%" class="alignleft">
|
1394 |
+
<span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Stock:', 'wp-e-commerce' ); ?> </span>
|
1395 |
+
<input type="text" name="stock" class="wpsc_ie_stock" />
|
1396 |
+
<input type="checkbox" name="stock_variant"> <span><?php esc_html_e( 'Update Variants', 'wp-e-commerce');?></span>
|
1397 |
+
</label>
|
1398 |
+
<?php
|
1399 |
+
break;
|
1400 |
+
case 'price' :
|
1401 |
+
?>
|
1402 |
+
<label style="max-width: 85%" class="alignleft">
|
1403 |
+
<span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Price:', 'wp-e-commerce' ); ?> </span>
|
1404 |
+
<input type="text" name="price" class="wpsc_ie_price" />
|
1405 |
+
<input type="checkbox" name="price_variant"> <span><?php esc_html_e( 'Update Variants', 'wp-e-commerce');?></span>
|
1406 |
+
</label>
|
1407 |
+
<?php
|
1408 |
+
break;
|
1409 |
+
case 'sale_price' :
|
1410 |
+
?>
|
1411 |
+
<label style="max-width: 85%" class="alignleft">
|
1412 |
+
<span class="checkbox-title wpsc-quick-edit"><?php esc_html_e( 'Sale Price:', 'wp-e-commerce' ); ?> </span>
|
1413 |
+
<input type="text" name="sale_price" class="wpsc_ie_sale_price" />
|
1414 |
+
<input type="checkbox" name="sale_price_variant"> <span><?php esc_html_e( 'Update Variants', 'wp-e-commerce');?></span>
|
1415 |
+
</label>
|
1416 |
+
<?php
|
1417 |
+
break;
|
1418 |
+
endswitch;
|
1419 |
+
?>
|
1420 |
+
</div>
|
1421 |
+
</div>
|
1422 |
+
</fieldset>
|
1423 |
+
<?php
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
add_action( 'quick_edit_custom_box', 'wpsc_quick_edit_boxes', 10, 2 );
|
1427 |
+
add_action( 'bulk_edit_custom_box', 'wpsc_quick_edit_boxes', 10, 2 );
|
1428 |
+
add_action( 'save_post', 'wpsc_save_quickedit_box' );
|
1429 |
+
|
1430 |
+
/**
|
1431 |
+
* If it doesn't exist, let's create a multi-dimensional associative array
|
1432 |
+
* that will contain all of the term/price associations
|
1433 |
+
*
|
1434 |
+
* @param <type> $variation
|
1435 |
+
*/
|
1436 |
+
function variation_price_field( $variation ) {
|
1437 |
+
$term_prices = get_option( 'term_prices' );
|
1438 |
+
|
1439 |
+
if ( is_object( $variation ) )
|
1440 |
+
$term_id = $variation->term_id;
|
1441 |
+
|
1442 |
+
if ( empty( $term_prices ) || !is_array( $term_prices ) ) {
|
1443 |
+
|
1444 |
+
$term_prices = array( );
|
1445 |
+
if ( isset( $term_id ) ) {
|
1446 |
+
$term_prices[$term_id] = array( );
|
1447 |
+
$term_prices[$term_id]["price"] = '';
|
1448 |
+
$term_prices[$term_id]["checked"] = '';
|
1449 |
+
}
|
1450 |
+
add_option( 'term_prices', $term_prices );
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
if ( isset( $term_id ) && is_array( $term_prices ) && array_key_exists( $term_id, $term_prices ) )
|
1454 |
+
$price = esc_attr( $term_prices[$term_id]["price"] );
|
1455 |
+
else
|
1456 |
+
$price = '';
|
1457 |
+
|
1458 |
+
if( !isset( $_GET['action'] ) ) {
|
1459 |
+
?>
|
1460 |
+
<div class="form-field">
|
1461 |
+
<label for="variation_price"><?php esc_html_e( 'Variation Price', 'wp-e-commerce' ); ?></label>
|
1462 |
+
<input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
|
1463 |
+
<span class="description"><?php esc_html_e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wp-e-commerce' ); ?></span>
|
1464 |
+
</div>
|
1465 |
+
<script type="text/javascript">
|
1466 |
+
jQuery('#parent option:contains(" ")').remove();
|
1467 |
+
jQuery('#parent').mousedown(function(){
|
1468 |
+
jQuery('#parent option:contains(" ")').remove();
|
1469 |
+
});
|
1470 |
+
</script>
|
1471 |
+
<?php
|
1472 |
+
} else{
|
1473 |
+
?>
|
1474 |
+
<tr class="form-field">
|
1475 |
+
<th scope="row" valign="top">
|
1476 |
+
<label for="variation_price"><?php esc_html_e( 'Variation Price', 'wp-e-commerce' ); ?></label>
|
1477 |
+
</th>
|
1478 |
+
<td>
|
1479 |
+
<input type="text" name="variation_price" id="variation_price" style="width:50px;" value="<?php echo $price; ?>"><br />
|
1480 |
+
<span class="description"><?php esc_html_e( 'You can list a default price here for this variation. You can list a regular price (18.99), differential price (+1.99 / -2) or even a percentage-based price (+50% / -25%).', 'wp-e-commerce' ); ?></span>
|
1481 |
+
</td>
|
1482 |
+
</tr>
|
1483 |
+
<?php
|
1484 |
+
}
|
1485 |
+
}
|
1486 |
+
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field' );
|
1487 |
+
add_action( 'wpsc-variation_add_form_fields', 'variation_price_field' );
|
1488 |
+
|
1489 |
+
/*
|
1490 |
+
WordPress doesnt let you change the custom post type taxonomy form very easily
|
1491 |
+
Use Jquery to move the set variation (parent) field to the top and add a description
|
1492 |
+
*/
|
1493 |
+
function variation_set_field(){
|
1494 |
+
?>
|
1495 |
+
<script>
|
1496 |
+
/* change the text on the variation set from (none) to new variation set*/
|
1497 |
+
jQuery("#parent option[value='-1']").text("New Variation Set");
|
1498 |
+
/* Move to the top of the form and add a description */
|
1499 |
+
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>') );
|
1500 |
+
/*
|
1501 |
+
create a small description about variations below the add variation / set title
|
1502 |
+
we can then get rid of the big red danger warning
|
1503 |
+
*/
|
1504 |
+
( 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>') );
|
1505 |
+
</script>
|
1506 |
+
<?php
|
1507 |
+
}
|
1508 |
+
add_action( 'wpsc-variation_edit_form_fields', 'variation_set_field' );
|
1509 |
+
add_action( 'wpsc-variation_add_form_fields', 'variation_set_field' );
|
1510 |
+
|
1511 |
+
|
1512 |
+
function category_edit_form(){
|
1513 |
+
?>
|
1514 |
+
<script type="text/javascript">
|
1515 |
+
|
1516 |
+
</script>
|
1517 |
+
<?php
|
1518 |
+
}
|
1519 |
+
|
1520 |
+
function variation_price_field_check( $variation ) {
|
1521 |
+
|
1522 |
+
$term_prices = get_option( 'term_prices' );
|
1523 |
+
|
1524 |
+
if ( is_array( $term_prices ) && array_key_exists( $variation->term_id, $term_prices ) )
|
1525 |
+
$checked = ($term_prices[$variation->term_id]["checked"] == 'checked') ? 'checked' : '';
|
1526 |
+
else
|
1527 |
+
$checked = ''; ?>
|
1528 |
+
|
1529 |
+
<tr class="form-field">
|
1530 |
+
<th scope="row" valign="top"><label for="apply_to_current"><?php esc_html_e( 'Apply to current variations?', 'wp-e-commerce' ) ?></label></th>
|
1531 |
+
<td>
|
1532 |
+
<span class="description"><input type="checkbox" name="apply_to_current" id="apply_to_current" <?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.', 'wp-e-commerce' ); ?></span>
|
1533 |
+
</td>
|
1534 |
+
</tr>
|
1535 |
+
<?php
|
1536 |
+
}
|
1537 |
+
add_action( 'wpsc-variation_edit_form_fields', 'variation_price_field_check' );
|
1538 |
+
|
1539 |
+
|
1540 |
+
|
1541 |
+
/**
|
1542 |
+
* @todo - Should probably refactor this at some point - very procedural,
|
1543 |
+
* WAY too many foreach loops for my liking :) But it does the trick
|
1544 |
+
*
|
1545 |
+
* @param <type> $term_id
|
1546 |
+
*/
|
1547 |
+
function save_term_prices( $term_id ) {
|
1548 |
+
// First - Saves options from input
|
1549 |
+
if ( isset( $_POST['variation_price'] ) || isset( $_POST["apply_to_current"] ) ) {
|
1550 |
+
|
1551 |
+
$term_prices = get_option( 'term_prices' );
|
1552 |
+
|
1553 |
+
$term_prices[$term_id]["price"] = sanitize_text_field( $_POST["variation_price"] );
|
1554 |
+
$term_prices[$term_id]["checked"] = (isset( $_POST["apply_to_current"] )) ? "checked" : "unchecked";
|
1555 |
+
|
1556 |
+
update_option( 'term_prices', $term_prices );
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
// Second - If box was checked, let's then check whether or not it was flat, differential, or percentile, then let's apply the pricing to every product appropriately
|
1560 |
+
if ( isset( $_POST["apply_to_current"] ) ) {
|
1561 |
+
|
1562 |
+
//Now, find all products with this term_id, update their pricing structure (terms returned include only parents at this point, we'll grab relevent children soon)
|
1563 |
+
$products_to_mod = get_objects_in_term( $term_id, "wpsc-variation" );
|
1564 |
+
$product_parents = array( );
|
1565 |
+
|
1566 |
+
foreach ( (array)$products_to_mod as $get_parent ) {
|
1567 |
+
|
1568 |
+
$post = get_post( $get_parent );
|
1569 |
+
|
1570 |
+
if ( !$post->post_parent )
|
1571 |
+
$product_parents[] = $post->ID;
|
1572 |
+
}
|
1573 |
+
|
1574 |
+
//Now that we have all parent IDs with this term, we can get the children (only the ones that are also in $products_to_mod, we don't want to apply pricing to ALL kids)
|
1575 |
+
|
1576 |
+
foreach ( $product_parents as $parent ) {
|
1577 |
+
$args = array(
|
1578 |
+
'post_parent' => $parent,
|
1579 |
+
'post_type' => 'wpsc-product'
|
1580 |
+
);
|
1581 |
+
$children = get_children( $args, ARRAY_A );
|
1582 |
+
|
1583 |
+
foreach ( $children as $childrens ) {
|
1584 |
+
$parent = $childrens["post_parent"];
|
1585 |
+
$children_ids[$parent][] = $childrens["ID"];
|
1586 |
+
$children_ids[$parent] = array_intersect( $children_ids[$parent], $products_to_mod );
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
|
1590 |
+
//Got the right kids, let's grab their parent pricing and modify their pricing based on var_price_type
|
1591 |
+
|
1592 |
+
foreach ( (array)$children_ids as $parents => $kids ) {
|
1593 |
+
|
1594 |
+
$kids = array_values( $kids );
|
1595 |
+
|
1596 |
+
foreach ( $kids as $kiddos ) {
|
1597 |
+
$price = wpsc_determine_variation_price( $kiddos );
|
1598 |
+
update_product_meta( $kiddos, 'price', $price );
|
1599 |
+
}
|
1600 |
+
}
|
1601 |
+
}
|
1602 |
+
}
|
1603 |
+
add_action( 'edited_wpsc-variation', 'save_term_prices' );
|
1604 |
+
add_action( 'created_wpsc-variation', 'save_term_prices' );
|
1605 |
+
|
1606 |
+
function wpsc_delete_variations( $postid ) {
|
1607 |
+
$post = get_post( $postid );
|
1608 |
+
if ( $post->post_type != 'wpsc-product' || $post->post_parent != 0 )
|
1609 |
+
return;
|
1610 |
+
$variations = get_posts( array(
|
1611 |
+
'post_type' => 'wpsc-product',
|
1612 |
+
'post_parent' => $postid,
|
1613 |
+
'post_status' => 'any',
|
1614 |
+
'numberposts' => -1,
|
1615 |
+
) );
|
1616 |
+
|
1617 |
+
if ( ! empty( $variations ) )
|
1618 |
+
foreach ( $variations as $variation ) {
|
1619 |
+
wp_delete_post( $variation->ID, true );
|
1620 |
+
}
|
1621 |
+
}
|
1622 |
+
add_action( 'before_delete_post', 'wpsc_delete_variations' );
|
1623 |
+
|
1624 |
+
|
1625 |
+
/**
|
1626 |
+
* fetch the items for display inside the admin product gallery
|
1627 |
+
* differs from the original `wpsc_get_product_gallery` in that
|
1628 |
+
* it only checks the postmeta for an actual gallery generated by
|
1629 |
+
* the user instead of pulling all attachments
|
1630 |
+
*
|
1631 |
+
* @since 3.8.14.2
|
1632 |
+
*
|
1633 |
+
* @param integer $product_id the product ID of the product
|
1634 |
+
* @return array $gallery the attachment IDs of the gallery if present
|
1635 |
+
*/
|
1636 |
+
function wpsc_get_admin_product_gallery( $product_id = 0 ) {
|
1637 |
+
|
1638 |
+
// grab our meta from the DB
|
1639 |
+
$gallery = get_post_meta( $product_id, '_wpsc_product_gallery', true );
|
1640 |
+
|
1641 |
+
// no custom gallery was created, so return nothing
|
1642 |
+
if ( ! $gallery ) {
|
1643 |
+
return;
|
1644 |
+
}
|
1645 |
+
|
1646 |
+
// now make sure the IDs present are actual attachments
|
1647 |
+
// by looping and unsetting them
|
1648 |
+
//
|
1649 |
+
// may want to add a MIME type check here, but not sure
|
1650 |
+
// if that would cause issues if people use non-images
|
1651 |
+
// in their galleries
|
1652 |
+
foreach( $gallery as $key => $image_id ) {
|
1653 |
+
if ( get_post_type( $image_id ) !== 'attachment' ) {
|
1654 |
+
unset( $gallery[ $key ] );
|
1655 |
+
}
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
// somehow everything in the gallery
|
1659 |
+
// was not an attachment, so bail
|
1660 |
+
if ( empty( $gallery ) ) {
|
1661 |
+
return;
|
1662 |
+
}
|
1663 |
+
|
1664 |
+
// send it back
|
1665 |
+
return $gallery;
|
1666 |
+
|
1667 |
+
}
|
1668 |
+
|
1669 |
+
/**
|
1670 |
+
* save our gallery IDs on post save
|
1671 |
+
*
|
1672 |
+
* @since 3.8.14.2
|
1673 |
+
* @param integer $product_id the post ID being passed
|
1674 |
+
* @return void
|
1675 |
+
*/
|
1676 |
+
function wpsc_new_gallery_save( $product_id = 0 ) {
|
1677 |
+
|
1678 |
+
// do our nonce check. ALWAYS A NONCE CHECK
|
1679 |
+
if ( ! isset( $_POST['wpsc_product_gallery_nonce'] ) || ! wp_verify_nonce( $_POST['wpsc_product_gallery_nonce'], 'wpsc_product_gallery_nonce' ) ) {
|
1680 |
+
return $product_id;
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
// set an empty array for the image IDs
|
1684 |
+
$image_ids = array();
|
1685 |
+
|
1686 |
+
// ok. we have image IDs to work with. do some filtering
|
1687 |
+
if ( ! empty( $_POST['wpsc-product-gallery-imgs'] ) ) {
|
1688 |
+
// make sure our IDs are set to an array
|
1689 |
+
$image_ids = (array) $_POST['wpsc-product-gallery-imgs'];
|
1690 |
+
// ensure nothing non-numeric got added in
|
1691 |
+
$image_ids = wp_parse_id_list( $image_ids );
|
1692 |
+
// filter out any empty items
|
1693 |
+
$image_ids = array_filter( $image_ids );
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
// now if we have image IDs left after filtering, save them
|
1697 |
+
// if not, delete the meta key
|
1698 |
+
if ( ! empty( $image_ids ) ) {
|
1699 |
+
update_post_meta( $product_id, '_wpsc_product_gallery', $image_ids );
|
1700 |
+
} else {
|
1701 |
+
delete_post_meta( $product_id, '_wpsc_product_gallery' );
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
// add an action for after the gallery being saved
|
1705 |
+
// passing the post ID and the image IDs
|
1706 |
+
do_action( 'wpsc_after_gallery_save', $product_id, $image_ids );
|
1707 |
+
|
1708 |
+
}
|
1709 |
+
|
1710 |
+
add_action( 'wpsc_edit_product', 'wpsc_new_gallery_save' );
|
trunk/wpsc-admin/includes/duplicate-product-class.php
ADDED
@@ -0,0 +1,447 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Duplicate Product Class
|
5 |
+
*
|
6 |
+
* @package WP eCommerce
|
7 |
+
* @subpackage Duplicate Product Class
|
8 |
+
* @since 4.0
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* WPSC Duplicate Product Class
|
13 |
+
*
|
14 |
+
* Used to duplicate products.
|
15 |
+
*
|
16 |
+
* @since 4.0
|
17 |
+
*/
|
18 |
+
class WPSC_Duplicate_Product {
|
19 |
+
|
20 |
+
private $post_id = null;
|
21 |
+
private $new_post_id = null;
|
22 |
+
private $new_parent_id = false;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Create new duplicate product
|
26 |
+
*
|
27 |
+
* @since 4.0
|
28 |
+
*
|
29 |
+
* @param int $post_id Post ID.
|
30 |
+
* @param int|false $new_parent_id Optional. New post parent ID.
|
31 |
+
* @param int|null $new_post_id Optional. New post ID if copying to exisiting post.
|
32 |
+
*/
|
33 |
+
public function __construct( $post_id, $new_parent_id = false, $new_post_id = null ) {
|
34 |
+
|
35 |
+
$this->post_id = absint( $post_id );
|
36 |
+
$this->new_parent_id = is_numeric( $new_parent_id ) ? absint( $new_parent_id ) : false;
|
37 |
+
$this->new_post_id = is_numeric( $new_post_id ) ? absint( $new_post_id ) : null;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Duplicates a product
|
42 |
+
*
|
43 |
+
* @since 4.0
|
44 |
+
*
|
45 |
+
* @uses wp_insert_post() Inserts a new post to the database.
|
46 |
+
*
|
47 |
+
* @return int|WP_Error New post ID or error.
|
48 |
+
*/
|
49 |
+
public function duplicate_product_process() {
|
50 |
+
|
51 |
+
$post = get_post( $this->get_post_id() );
|
52 |
+
|
53 |
+
// If no new post ID yet, duplicate the product post
|
54 |
+
if ( ! $this->get_new_post_id() ) {
|
55 |
+
|
56 |
+
$new_parent_id = $this->get_new_parent_id( $post->post_parent );
|
57 |
+
|
58 |
+
$new_post_date = $post->post_date;
|
59 |
+
$new_post_date_gmt = get_gmt_from_date( $new_post_date );
|
60 |
+
|
61 |
+
$new_post_type = $post->post_type;
|
62 |
+
$post_content = $post->post_content;
|
63 |
+
$post_content_filtered = $post->post_content_filtered;
|
64 |
+
$post_excerpt = $post->post_excerpt;
|
65 |
+
$post_title = sprintf( __( '%s (Duplicate)', 'wp-e-commerce' ), $post->post_title );
|
66 |
+
$post_name = $post->post_name;
|
67 |
+
$comment_status = $post->comment_status;
|
68 |
+
$ping_status = $post->ping_status;
|
69 |
+
|
70 |
+
$defaults = array(
|
71 |
+
'post_status' => $post->post_status,
|
72 |
+
'post_type' => $new_post_type,
|
73 |
+
'ping_status' => $ping_status,
|
74 |
+
'post_parent' => $new_parent_id,
|
75 |
+
'menu_order' => $post->menu_order,
|
76 |
+
'to_ping' => $post->to_ping,
|
77 |
+
'pinged' => $post->pinged,
|
78 |
+
'post_excerpt' => $post_excerpt,
|
79 |
+
'post_title' => $post_title,
|
80 |
+
'post_content' => $post_content,
|
81 |
+
'post_content_filtered' => $post_content_filtered,
|
82 |
+
'post_mime_type' => $post->post_mime_type,
|
83 |
+
'import_id' => 0
|
84 |
+
);
|
85 |
+
|
86 |
+
if ( 'attachment' == $post->post_type ) {
|
87 |
+
$defaults['guid'] = $post->guid;
|
88 |
+
}
|
89 |
+
|
90 |
+
$defaults = stripslashes_deep( $defaults );
|
91 |
+
|
92 |
+
// Insert the new template in the post table
|
93 |
+
$this->new_post_id = wp_insert_post( $defaults );
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
// Copy the taxonomies
|
98 |
+
$this->duplicate_taxonomies();
|
99 |
+
|
100 |
+
// Copy the meta information
|
101 |
+
$this->duplicate_product_meta();
|
102 |
+
|
103 |
+
do_action( 'wpsc_duplicate_product', $post, $this->get_new_post_id() );
|
104 |
+
|
105 |
+
// Finds children (which includes product files AND product images), their meta values, and duplicates them.
|
106 |
+
$duplicated_children = $this->duplicate_children();
|
107 |
+
|
108 |
+
// Update product gallery meta (resetting duplicated meta value IDs)
|
109 |
+
$this->update_duplicate_product_gallery_meta( $duplicated_children );
|
110 |
+
|
111 |
+
// Copy product thumbnail (resetting duplicated meta value)
|
112 |
+
$this->duplicate_product_thumbnail();
|
113 |
+
|
114 |
+
return $this->get_new_post_id();
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Copy the taxonomies of a post to another post
|
119 |
+
*
|
120 |
+
* @since 4.0
|
121 |
+
*
|
122 |
+
* @uses get_object_taxonomies() Gets taxonomies for the given object.
|
123 |
+
* @uses wpsc_get_product_terms() Gets terms for the product taxonomies.
|
124 |
+
* @uses wp_set_object_terms() Sets the terms for a post object.
|
125 |
+
*/
|
126 |
+
public function duplicate_taxonomies() {
|
127 |
+
|
128 |
+
$new_post_id = $this->get_new_post_id();
|
129 |
+
|
130 |
+
if ( $new_post_id ) {
|
131 |
+
|
132 |
+
$id = $this->get_post_id();
|
133 |
+
$post_type = get_post_type( $id );
|
134 |
+
$taxonomies = get_object_taxonomies( $post_type );
|
135 |
+
|
136 |
+
foreach ( $taxonomies as $taxonomy ) {
|
137 |
+
$post_terms = wpsc_get_product_terms( $id, $taxonomy );
|
138 |
+
foreach ( $post_terms as $post_term ) {
|
139 |
+
wp_set_object_terms( $new_post_id, $post_term->slug, $taxonomy, true );
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Copy the meta information of a post to another post
|
147 |
+
*
|
148 |
+
* @since 4.0
|
149 |
+
*
|
150 |
+
* @uses $wpdb WordPress database object for queries.
|
151 |
+
* @uses get_results() Gets generic multirow results from the database.
|
152 |
+
* @uses prepare() Prepares a database query making it safe.
|
153 |
+
* @uses query() Runs an SQL query.
|
154 |
+
*/
|
155 |
+
public function duplicate_product_meta() {
|
156 |
+
|
157 |
+
global $wpdb;
|
158 |
+
|
159 |
+
$new_post_id = $this->get_new_post_id();
|
160 |
+
|
161 |
+
if ( $new_post_id ) {
|
162 |
+
|
163 |
+
$post_meta_infos = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = %d", $this->get_post_id() ) );
|
164 |
+
|
165 |
+
if ( count( $post_meta_infos ) ) {
|
166 |
+
|
167 |
+
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
168 |
+
$values = array();
|
169 |
+
$sql_query_sel = array();
|
170 |
+
|
171 |
+
foreach ( $post_meta_infos as $meta_info ) {
|
172 |
+
$meta_key = $meta_info->meta_key;
|
173 |
+
$meta_value = addslashes( $meta_info->meta_value );
|
174 |
+
|
175 |
+
$sql_query_sel[] = "( $new_post_id, '$meta_key', '$meta_value' )";
|
176 |
+
$values[] = $new_post_id;
|
177 |
+
$values[] = $meta_key;
|
178 |
+
$values[] = $meta_value;
|
179 |
+
$values += array( $new_post_id, $meta_key, $meta_value );
|
180 |
+
}
|
181 |
+
|
182 |
+
$sql_query .= implode( ",", $sql_query_sel );
|
183 |
+
$sql_query = $wpdb->prepare( $sql_query, $values );
|
184 |
+
$wpdb->query( $sql_query );
|
185 |
+
clean_post_cache( $new_post_id );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Update Duplicate Product Gallery Meta
|
192 |
+
*
|
193 |
+
* When a product is duplicated its meta values are copied, too
|
194 |
+
* including the gallery meta array of IDs.
|
195 |
+
*
|
196 |
+
* After the product's children (including attachments) have been
|
197 |
+
* duplicated this function is used to update the gallery meta to
|
198 |
+
* refer to the IDs of any duplicated media.
|
199 |
+
*
|
200 |
+
* @since 4.0
|
201 |
+
*
|
202 |
+
* @param array $duplicated_children Associative array mapping original child IDs to duplicated child IDs.
|
203 |
+
*/
|
204 |
+
private function update_duplicate_product_gallery_meta( $duplicated_children ) {
|
205 |
+
|
206 |
+
$new_post_id = $this->get_new_post_id();
|
207 |
+
|
208 |
+
if ( $new_post_id ) {
|
209 |
+
|
210 |
+
$gallery = get_post_meta( $new_post_id, '_wpsc_product_gallery', true );
|
211 |
+
$new_gallery = array();
|
212 |
+
|
213 |
+
// Loop through duplicated gallery IDs.
|
214 |
+
if ( is_array( $gallery ) ) {
|
215 |
+
foreach ( $gallery as $gallery_id ) {
|
216 |
+
|
217 |
+
// If product image should be duplicated
|
218 |
+
if ( apply_filters( 'wpsc_duplicate_product_attachment', true, $gallery_id, $new_post_id ) ) {
|
219 |
+
|
220 |
+
// Update attached image IDs and copy non-attached image IDs
|
221 |
+
if ( array_key_exists( $gallery_id, $duplicated_children ) ) {
|
222 |
+
$new_gallery[] = $duplicated_children[ $gallery_id ];
|
223 |
+
} else {
|
224 |
+
$new_gallery[] = $gallery_id;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
update_post_meta( $new_post_id, '_wpsc_product_gallery', $new_gallery );
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Duplicate Featured Image
|
236 |
+
*
|
237 |
+
* When a product is duplicated, the featured image ID is copied when the post
|
238 |
+
* meta is duplicated.
|
239 |
+
*
|
240 |
+
* When the featured image is attached to the duplicated product, if the image
|
241 |
+
* is duplicated the featured image ID is updated to the duplicated image ID
|
242 |
+
* otherwise the featured image ID is removed.
|
243 |
+
*
|
244 |
+
* If the featured image is not attached to the product the featured image ID
|
245 |
+
* remains the same as the original product.
|
246 |
+
*
|
247 |
+
* This function will remove the featured image if the image is not attached to
|
248 |
+
* the duplicated product and offers the opportunity to change the featured image
|
249 |
+
* of the duplicated product via the 'wpsc_duplicate_product_thumbnail' filter.
|
250 |
+
*
|
251 |
+
* @since 4.0
|
252 |
+
*/
|
253 |
+
private function duplicate_product_thumbnail() {
|
254 |
+
|
255 |
+
$new_post_id = $this->get_new_post_id();
|
256 |
+
|
257 |
+
if ( $new_post_id ) {
|
258 |
+
|
259 |
+
$thumbnail_id = $original_thumbnail_id = has_post_thumbnail( $new_post_id ) ? get_post_thumbnail_id( $new_post_id ) : 0;
|
260 |
+
|
261 |
+
// If not duplicating product attachments, ensure featured image ID is zero
|
262 |
+
if ( ! apply_filters( 'wpsc_duplicate_product_attachment', true, $thumbnail_id, $new_post_id ) ) {
|
263 |
+
$thumbnail_id = 0;
|
264 |
+
}
|
265 |
+
|
266 |
+
// Filter featured product image ID
|
267 |
+
$thumbnail_id = absint( apply_filters( 'wpsc_duplicate_product_thumbnail', $thumbnail_id, $original_thumbnail_id, $this->get_post_id(), $new_post_id ) );
|
268 |
+
|
269 |
+
if ( $thumbnail_id > 0 ) {
|
270 |
+
set_post_thumbnail( $new_post_id, $thumbnail_id );
|
271 |
+
} else {
|
272 |
+
delete_post_thumbnail( $new_post_id );
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Duplicates product children and meta
|
279 |
+
*
|
280 |
+
* @since 4.0
|
281 |
+
*
|
282 |
+
* @uses get_posts() Gets an array of posts given array of arguments.
|
283 |
+
*
|
284 |
+
* @return array Array mapping old child IDs to duplicated child IDs.
|
285 |
+
*/
|
286 |
+
private function duplicate_children() {
|
287 |
+
|
288 |
+
$new_parent_id = $this->get_new_post_id();
|
289 |
+
|
290 |
+
// Map duplicate child IDs
|
291 |
+
$converted_child_ids = array();
|
292 |
+
|
293 |
+
if ( $new_parent_id ) {
|
294 |
+
|
295 |
+
// Get children products and duplicate them
|
296 |
+
$child_posts = get_posts( array(
|
297 |
+
'post_parent' => $this->get_post_id(),
|
298 |
+
'post_type' => 'any',
|
299 |
+
'post_status' => 'any',
|
300 |
+
'numberposts' => -1,
|
301 |
+
'order' => 'ASC'
|
302 |
+
) );
|
303 |
+
|
304 |
+
// Duplicate product images and child posts
|
305 |
+
foreach ( $child_posts as $child_post ) {
|
306 |
+
|
307 |
+
$duplicate_child = new WPSC_Duplicate_Product( $child_post->ID, $new_parent_id );
|
308 |
+
|
309 |
+
// Duplicate image or post
|
310 |
+
if ( 'attachment' == get_post_type( $child_post ) ) {
|
311 |
+
$new_child_id = $duplicate_child->duplicate_product_image_process();
|
312 |
+
} else {
|
313 |
+
$new_child_id = $duplicate_child->duplicate_product_process();
|
314 |
+
}
|
315 |
+
|
316 |
+
// Map child ID to new child ID
|
317 |
+
if ( $new_child_id && ! is_wp_error( $new_child_id ) ) {
|
318 |
+
$converted_child_ids[ $child_post->ID ] = $new_child_id;
|
319 |
+
}
|
320 |
+
|
321 |
+
do_action( 'wpsc_duplicate_product_child', $child_post, $new_parent_id, $new_child_id );
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
return $converted_child_ids;
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Duplicates a product image.
|
330 |
+
*
|
331 |
+
* Uses a portion of code from media_sideload_image() in `wp-admin/includes/media.php`
|
332 |
+
* to check file before downloading from URL.
|
333 |
+
*
|
334 |
+
* @since 4.0
|
335 |
+
*
|
336 |
+
* @uses get_post_type() Gets post type.
|
337 |
+
* @uses wp_get_attachment_url() Gets attachment URL.
|
338 |
+
* @uses download_url() Download file from URl to temp location.
|
339 |
+
* @uses is_wp_error() Is WP error?
|
340 |
+
* @uses media_handle_sideload() Handle creation of new attachment and attach to post.
|
341 |
+
*
|
342 |
+
* @return int|bool Attachment ID or false.
|
343 |
+
*/
|
344 |
+
public function duplicate_product_image_process() {
|
345 |
+
|
346 |
+
$child_post = get_post( $this->get_post_id() );
|
347 |
+
$new_parent_id = $this->get_new_parent_id( $child_post->post_parent );
|
348 |
+
|
349 |
+
if ( 'attachment' == get_post_type( $child_post ) && apply_filters( 'wpsc_duplicate_product_attachment', true, $child_post->ID, $new_parent_id ) ) {
|
350 |
+
|
351 |
+
$file = wp_get_attachment_url( $child_post->ID );
|
352 |
+
|
353 |
+
if ( ! empty( $file ) ) {
|
354 |
+
|
355 |
+
// Set variables for storage, fix file filename for query strings.
|
356 |
+
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
|
357 |
+
$file_array = array();
|
358 |
+
$file_array['name'] = basename( $matches[0] );
|
359 |
+
|
360 |
+
// Download file to temp location.
|
361 |
+
$file_array['tmp_name'] = download_url( $file );
|
362 |
+
|
363 |
+
// If error storing temporarily, return the error.
|
364 |
+
if ( is_wp_error( $file_array['tmp_name'] ) ) {
|
365 |
+
return $file_array['tmp_name'];
|
366 |
+
}
|
367 |
+
|
368 |
+
// Do the validation and storage stuff.
|
369 |
+
$new_post_id = media_handle_sideload( $file_array, $new_parent_id );
|
370 |
+
|
371 |
+
// If error storing permanently, unlink.
|
372 |
+
if ( is_wp_error( $new_post_id ) ) {
|
373 |
+
@ unlink( $file_array['tmp_name'] );
|
374 |
+
}
|
375 |
+
|
376 |
+
// Re-attribute featured image
|
377 |
+
if ( has_post_thumbnail( $new_parent_id ) && $child_post->ID == get_post_thumbnail_id( $new_parent_id ) ) {
|
378 |
+
set_post_thumbnail( $new_parent_id, $new_post_id );
|
379 |
+
}
|
380 |
+
|
381 |
+
// Copy attachment data
|
382 |
+
$post_data = array(
|
383 |
+
'ID' => $new_post_id,
|
384 |
+
'post_content' => $child_post->post_content,
|
385 |
+
'post_title' => $child_post->post_title,
|
386 |
+
'post_excerpt' => $child_post->post_excerpt,
|
387 |
+
'post_status' => $child_post->post_status,
|
388 |
+
'comment_status' => $child_post->comment_status,
|
389 |
+
'ping_status' => $child_post->ping_status,
|
390 |
+
'post_password' => $child_post->post_password,
|
391 |
+
'post_content_filtered' => $child_post->post_content_filtered,
|
392 |
+
'menu_order' => $child_post->menu_order
|
393 |
+
);
|
394 |
+
|
395 |
+
wp_update_post( $post_data );
|
396 |
+
|
397 |
+
// Copy alt text
|
398 |
+
update_post_meta( $new_post_id, '_wp_attachment_image_alt', get_post_meta( $child_post->ID, '_wp_attachment_image_alt', true ) );
|
399 |
+
|
400 |
+
return $new_post_id;
|
401 |
+
}
|
402 |
+
|
403 |
+
} elseif ( has_post_thumbnail( $new_parent_id ) && $child_post->ID == get_post_thumbnail_id( $new_parent_id ) ) {
|
404 |
+
|
405 |
+
delete_post_meta( $new_parent_id, '_thumbnail_id' );
|
406 |
+
}
|
407 |
+
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Get Post ID
|
413 |
+
*
|
414 |
+
* @since 4.0
|
415 |
+
*
|
416 |
+
* @return int Post ID.
|
417 |
+
*/
|
418 |
+
public function get_post_id() {
|
419 |
+
|
420 |
+
return $this->post_id;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Get New Post ID
|
425 |
+
*
|
426 |
+
* @since 4.0
|
427 |
+
*
|
428 |
+
* @return int Post ID.
|
429 |
+
*/
|
430 |
+
public function get_new_post_id() {
|
431 |
+
|
432 |
+
return $this->new_post_id;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Get New Parent ID
|
437 |
+
*
|
438 |
+
* @since 4.0
|
439 |
+
*
|
440 |
+
* @param int $default Default parent ID.
|
441 |
+
* @return int Post ID.
|
442 |
+
*/
|
443 |
+
public function get_new_parent_id( $default = 0 ) {
|
444 |
+
|
445 |
+
return false === $this->new_parent_id ? $default : $this->new_parent_id;
|
446 |
+
}
|
447 |
+
}
|
trunk/wpsc-admin/includes/product-functions.php
ADDED
@@ -0,0 +1,1233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WPSC Product modifying functions
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
6 |
+
* @since 3.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
function wpsc_get_max_upload_size(){
|
10 |
+
return size_format( wp_max_upload_size() );
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* wpsc_admin_submit_product function
|
15 |
+
* @internal Was going to completely refactor sanitise forms and wpsc_insert_product, but they are also used by the import system
|
16 |
+
* which I'm not really familiar with...so I'm not touching them :) Erring on the side of redundancy and caution I'll just
|
17 |
+
* refactor this to do the job.
|
18 |
+
* @return nothing
|
19 |
+
*/
|
20 |
+
function wpsc_admin_submit_product( $post_ID, $post ) {
|
21 |
+
|
22 |
+
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || $post->post_type != 'wpsc-product' ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
//Type-casting ( not so much sanitization, which would be good to do )
|
27 |
+
$post_data = stripslashes_deep( $_POST );
|
28 |
+
$product_id = $post_ID;
|
29 |
+
|
30 |
+
$post_data['additional_description'] = isset( $post_data['additional_description'] ) ? $post_data['additional_description'] : '';
|
31 |
+
|
32 |
+
if ( ! isset( $post_data['meta'] ) && isset( $_POST['meta'] ) ) {
|
33 |
+
$post_data['meta'] = (array) $_POST['meta'];
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( isset( $post_data['meta']['_wpsc_price'] ) )
|
37 |
+
$post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
|
38 |
+
|
39 |
+
if ( isset( $post_data['meta']['_wpsc_special_price'] ) )
|
40 |
+
$post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
|
41 |
+
|
42 |
+
if ( isset( $post_data['meta']['_wpsc_sku'] ) && $post_data['meta']['_wpsc_sku'] == __('N/A', 'wp-e-commerce') ) {
|
43 |
+
$post_data['meta']['_wpsc_sku'] = '';
|
44 |
+
}
|
45 |
+
|
46 |
+
// Update donation setting
|
47 |
+
if ( isset( $post_data['wpsc_product_pricing_nonce'] ) && wp_verify_nonce( $post_data['wpsc_product_pricing_nonce'], 'update' ) ) {
|
48 |
+
$post_data['meta']['_wpsc_is_donation'] = isset( $post_data['meta']['_wpsc_is_donation'] ) ? 1 : 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( ! isset( $post_data['meta']['_wpsc_limited_stock'] ) ){
|
52 |
+
$post_data['meta']['_wpsc_stock'] = false;
|
53 |
+
} else {
|
54 |
+
$post_data['meta']['_wpsc_stock'] = isset( $post_data['meta']['_wpsc_stock'] ) ? (int) $post_data['meta']['_wpsc_stock'] : 0;
|
55 |
+
}
|
56 |
+
|
57 |
+
// Update low stock notifications
|
58 |
+
if ( isset( $post_data['meta']['_wpsc_stock'] ) && isset( $post_data['meta']['_wpsc_product_metadata'] ) && ( $post_data['meta']['_wpsc_stock'] > $post_data['meta']['_wpsc_product_metadata']['stock_limit_notify'] ) ) {
|
59 |
+
// Check if notification has been sent
|
60 |
+
$notify_sent = get_product_meta( $product_id, 'stock_limit_notify_sent', true );
|
61 |
+
if( ! empty( $notify_sent ) ) {
|
62 |
+
delete_product_meta( $product_id, 'stock_limit_notify_sent' );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
unset($post_data['meta']['_wpsc_limited_stock']);
|
67 |
+
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
68 |
+
if(!isset($post_data['special'])) $post_data['special'] = '';
|
69 |
+
|
70 |
+
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
71 |
+
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
72 |
+
|
73 |
+
// Update Stock Options
|
74 |
+
if ( isset( $_POST['wpsc_product_stock_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_stock_nonce'], 'update' ) ) {
|
75 |
+
|
76 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
|
77 |
+
'unpublish_when_none_left' => 0
|
78 |
+
) );
|
79 |
+
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] );
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
// Update shipping setting
|
84 |
+
if ( isset( $_POST['wpsc_product_shipping_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_shipping_nonce'], 'update' ) ) {
|
85 |
+
|
86 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
|
87 |
+
'no_shipping' => 0
|
88 |
+
) );
|
89 |
+
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] );
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
// Product Weight
|
94 |
+
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
95 |
+
|
96 |
+
if ( isset( $post_data['meta']['_wpsc_product_metadata']['weight'] ) ) {
|
97 |
+
$weight = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['weight'] );
|
98 |
+
$weight = wpsc_convert_weight( $weight, $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
99 |
+
$post_data['meta']['_wpsc_product_metadata']['weight'] = $weight;
|
100 |
+
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( isset( $post_data['meta']['_wpsc_product_metadata']['dimensions'] ) ) {
|
104 |
+
$dimensions =& $post_data['meta']['_wpsc_product_metadata']['dimensions'];
|
105 |
+
foreach ( $dimensions as $key => $value ) {
|
106 |
+
if ( ! in_array( $key, array( 'height', 'width', 'length' ) ) )
|
107 |
+
continue;
|
108 |
+
|
109 |
+
$dimensions[$key] = wpsc_string_to_float( $value );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
// Update the table rate prices (quantity discounts)
|
114 |
+
if ( isset( $post_data['wpsc-update-quantity-discounts'] ) && wp_verify_nonce( $post_data['wpsc-update-quantity-discounts'], 'update-options' ) ) {
|
115 |
+
$post_data['meta']['_wpsc_product_metadata']['table_rate_price'] = isset( $post_data['table_rate_price'] ) ? $post_data['table_rate_price'] : array();
|
116 |
+
|
117 |
+
// If table_rate_price is empty, set empty table rate price arrays
|
118 |
+
if ( empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price'] ) ) {
|
119 |
+
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] = array();
|
120 |
+
$post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] = array();
|
121 |
+
}
|
122 |
+
|
123 |
+
// Remove any rates with no quantity or price
|
124 |
+
if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] ) ) {
|
125 |
+
foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'] as $key => $value ) {
|
126 |
+
if ( empty( $value ) ) {
|
127 |
+
unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][ $key ] );
|
128 |
+
unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][ $key ] );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
foreach ( (array) $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'] as $key => $value ) {
|
132 |
+
if ( empty( $value ) ) {
|
133 |
+
unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['table_price'][ $key ] );
|
134 |
+
unset( $post_data['meta']['_wpsc_product_metadata']['table_rate_price']['quantity'][ $key ] );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( isset( $post_data['meta']['_wpsc_product_metadata']['shipping'] ) ) {
|
141 |
+
$post_data['meta']['_wpsc_product_metadata']['shipping']['local'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['local'] );
|
142 |
+
$post_data['meta']['_wpsc_product_metadata']['shipping']['international'] = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['shipping']['international'] );
|
143 |
+
}
|
144 |
+
|
145 |
+
// Update product taxes
|
146 |
+
if ( isset( $_POST['wpsc_product_tax_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_tax_nonce'], 'update' ) ) {
|
147 |
+
|
148 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
|
149 |
+
'wpec_taxes_taxable_amount' => '',
|
150 |
+
'wpec_taxes_taxable' => ''
|
151 |
+
) );
|
152 |
+
if ( ! empty( $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] ) ) {
|
153 |
+
$post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] = wpsc_string_to_float($post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable_amount'] );
|
154 |
+
}
|
155 |
+
$post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'] = $post_data['meta']['_wpsc_product_metadata']['wpec_taxes_taxable'];
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
// External Link Options
|
160 |
+
if ( isset( $_POST['wpsc_product_external_link_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_external_link_nonce'], 'update' ) ) {
|
161 |
+
|
162 |
+
// Parse post meta to ensure default values
|
163 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
|
164 |
+
'external_link' => '',
|
165 |
+
'external_link_text' => '',
|
166 |
+
'external_link_target' => ''
|
167 |
+
) );
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
// Advanced Options
|
172 |
+
if ( isset( $_POST['wpsc_product_personalization_nonce'] ) && wp_verify_nonce( $_POST['wpsc_product_personalization_nonce'], 'update' ) ) {
|
173 |
+
|
174 |
+
// Parse post meta to ensure default values (especially checkboxes)
|
175 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], array(
|
176 |
+
'engraved' => 0,
|
177 |
+
'can_have_uploaded_image' => 0
|
178 |
+
) );
|
179 |
+
|
180 |
+
$post_data['meta']['_wpsc_product_metadata']['engraved'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['engraved'] );
|
181 |
+
$post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] = absint( (bool) $post_data['meta']['_wpsc_product_metadata']['can_have_uploaded_image'] );
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( ! isset($post_data['meta']['_wpsc_product_metadata']['google_prohibited'])) $post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = '';
|
186 |
+
$post_data['meta']['_wpsc_product_metadata']['google_prohibited'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['google_prohibited'];
|
187 |
+
|
188 |
+
// Fill in any missing meta values with existing values.
|
189 |
+
$post_data['meta'] = wp_parse_args( $post_data['meta'], array(
|
190 |
+
'_wpsc_is_donation' => get_product_meta( $product_id, 'is_donation', true )
|
191 |
+
) );
|
192 |
+
|
193 |
+
// Fill in any missing product meta values with existing values.
|
194 |
+
$default_meta_values = wp_parse_args( get_product_meta( $product_id, 'product_metadata', true ), array(
|
195 |
+
'unpublish_when_none_left' => 0,
|
196 |
+
'no_shipping' => 0,
|
197 |
+
'external_link' => '',
|
198 |
+
'external_link_text' => '',
|
199 |
+
'external_link_target' => '',
|
200 |
+
'engraved' => 0,
|
201 |
+
'can_have_uploaded_image' => 0
|
202 |
+
) );
|
203 |
+
|
204 |
+
$post_data['meta']['_wpsc_product_metadata'] = wp_parse_args( $post_data['meta']['_wpsc_product_metadata'], $default_meta_values );
|
205 |
+
|
206 |
+
$post_data['files'] = $_FILES;
|
207 |
+
|
208 |
+
if(isset($post_data['post_title']) && $post_data['post_title'] != '') {
|
209 |
+
|
210 |
+
$product_columns = array(
|
211 |
+
'name' => '',
|
212 |
+
'description' => '',
|
213 |
+
'additional_description' => '',
|
214 |
+
'price' => null,
|
215 |
+
'weight' => null,
|
216 |
+
'weight_unit' => '',
|
217 |
+
'pnp' => null,
|
218 |
+
'international_pnp' => null,
|
219 |
+
'file' => null,
|
220 |
+
'image' => '0',
|
221 |
+
'quantity_limited' => '',
|
222 |
+
'quantity' => null,
|
223 |
+
'special' => null,
|
224 |
+
'special_price' => null,
|
225 |
+
'display_frontpage' => null,
|
226 |
+
'notax' => null,
|
227 |
+
'publish' => null,
|
228 |
+
'active' => null,
|
229 |
+
'donation' => null,
|
230 |
+
'no_shipping' => null,
|
231 |
+
'thumbnail_image' => null,
|
232 |
+
'thumbnail_state' => null
|
233 |
+
);
|
234 |
+
|
235 |
+
foreach ( $product_columns as $column => $default ) {
|
236 |
+
if ( ! isset( $post_data[ $column ] ) ) {
|
237 |
+
$post_data[ $column ] = '';
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
// if we succeed, we can do further editing (todo - if_wp_error)
|
242 |
+
|
243 |
+
// if we have no categories selected, assign one.
|
244 |
+
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){
|
245 |
+
$post_data['tax_input']['wpsc_product_category'][1] = wpsc_add_product_category_default($product_id);
|
246 |
+
}
|
247 |
+
|
248 |
+
// and the meta
|
249 |
+
wpsc_update_product_meta($product_id, $post_data['meta']);
|
250 |
+
|
251 |
+
// and the custom meta
|
252 |
+
wpsc_update_custom_meta($product_id, $post_data);
|
253 |
+
|
254 |
+
// Update the alternative currencies
|
255 |
+
if ( isset( $post_data['wpsc-update-currency-layers'] ) && wp_verify_nonce( $post_data['wpsc-update-currency-layers'], 'update-options' ) ) {
|
256 |
+
|
257 |
+
// Clear currencies before re-saving to make sure deleted currencies are removed
|
258 |
+
update_product_meta( $product_id, 'currency', array() );
|
259 |
+
|
260 |
+
if ( ! empty( $post_data['newCurrency'] ) ) {
|
261 |
+
foreach( (array) $post_data['newCurrency'] as $key =>$value ) {
|
262 |
+
wpsc_update_alt_product_currency( $product_id, $value, $post_data['newCurrPrice'][ $key ] );
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
if ( isset( $post_data['files']['file'] ) && $post_data['files']['file']['tmp_name'] != '' ) {
|
268 |
+
wpsc_item_process_file($product_id, $post_data['files']['file']);
|
269 |
+
} else {
|
270 |
+
if (!isset($post_data['select_product_file'])) $post_data['select_product_file'] = null;
|
271 |
+
wpsc_item_reassign_file($product_id, $post_data['select_product_file']);
|
272 |
+
}
|
273 |
+
|
274 |
+
if(isset($post_data['files']['preview_file']['tmp_name']) && ($post_data['files']['preview_file']['tmp_name'] != '')) {
|
275 |
+
wpsc_item_add_preview_file($product_id, $post_data['files']['preview_file']);
|
276 |
+
}
|
277 |
+
do_action('wpsc_edit_product', $product_id);
|
278 |
+
}
|
279 |
+
return $product_id;
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
function wpsc_pre_update( $data, $postarr ) {
|
284 |
+
if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || $postarr["post_type"] != 'wpsc-product' )
|
285 |
+
return $data;
|
286 |
+
if( isset( $postarr["additional_description"] ) )
|
287 |
+
$data["post_excerpt"] = $postarr["additional_description"];
|
288 |
+
|
289 |
+
if( isset( $postarr["parent_post"] ) && !empty( $postarr["parent_post"] ) )
|
290 |
+
$data["post_parent"] = $postarr["parent_post"];
|
291 |
+
|
292 |
+
// Sanitize status for variations (see #324)
|
293 |
+
if ( $data['post_parent'] && ( ! isset( $data['ID'] ) || $data['post_parent'] != $data['ID'] ) && $data['post_status'] == 'publish' ) {
|
294 |
+
$data['post_status'] = 'inherit';
|
295 |
+
}
|
296 |
+
|
297 |
+
if ( ! empty( $postarr['meta'] ) && ( ! isset( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) || $postarr['meta']['_wpsc_product_metadata']['enable_comments'] == 0 || empty( $postarr['meta']['_wpsc_product_metadata']['enable_comments'] ) ) ) {
|
298 |
+
$data["comment_status"] = "closed";
|
299 |
+
} else {
|
300 |
+
$data["comment_status"] = "open";
|
301 |
+
}
|
302 |
+
|
303 |
+
return $data;
|
304 |
+
}
|
305 |
+
add_filter( 'wp_insert_post_data','wpsc_pre_update', 99, 2 );
|
306 |
+
add_action( 'save_post', 'wpsc_admin_submit_product', 5, 2 );
|
307 |
+
add_action( 'admin_notices', 'wpsc_admin_submit_notices' );
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Remove category meta box from variation editor. This would disassociate variations
|
311 |
+
* with the default category. See #431 (http://code.google.com/p/wp-e-commerce/issues/detail?id=431)
|
312 |
+
*
|
313 |
+
*/
|
314 |
+
function wpsc_variation_remove_metaboxes() {
|
315 |
+
global $post;
|
316 |
+
if ( ! $post->post_parent )
|
317 |
+
return;
|
318 |
+
|
319 |
+
remove_meta_box( 'wpsc_product_categorydiv', 'wpsc-product', 'side' );
|
320 |
+
}
|
321 |
+
add_action( 'add_meta_boxes_wpsc-product', 'wpsc_variation_remove_metaboxes', 99 );
|
322 |
+
|
323 |
+
function wpsc_admin_submit_notices() {
|
324 |
+
global $current_screen, $post;
|
325 |
+
|
326 |
+
if( $current_screen->id != 'wpsc-product' || !isset( $_SESSION['product_error_messages'] ) )
|
327 |
+
return;
|
328 |
+
foreach ( $_SESSION['product_error_messages'] as $error )
|
329 |
+
echo "<div id=\"message\" class=\"updated below-h2\"><p>".$error."</p></div>";
|
330 |
+
unset( $_SESSION['product_error_messages'] );
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* wpsc_add_product_category_default, if there is no category assigned assign first product category as default
|
335 |
+
*
|
336 |
+
* @since 3.8
|
337 |
+
* @param $product_id (int) the Post ID
|
338 |
+
* @return null
|
339 |
+
*/
|
340 |
+
function wpsc_add_product_category_default( $product_id ){
|
341 |
+
$terms = get_terms( 'wpsc_product_category', array( 'orderby' => 'id', 'hide_empty' => 0 ) );
|
342 |
+
if ( ! empty( $terms ) ) {
|
343 |
+
$default = array_shift( $terms );
|
344 |
+
wp_set_object_terms( $product_id , array( $default->slug ) , 'wpsc_product_category' );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
/**
|
348 |
+
* wpsc_sanitise_product_forms function
|
349 |
+
*
|
350 |
+
* @return array - Sanitised product details
|
351 |
+
*/
|
352 |
+
function wpsc_sanitise_product_forms($post_data = null) {
|
353 |
+
if ( empty($post_data) ) {
|
354 |
+
$post_data = &$_POST;
|
355 |
+
}
|
356 |
+
|
357 |
+
$post_data = stripslashes_deep( $post_data );
|
358 |
+
|
359 |
+
$post_data['name'] = isset($post_data['post_title']) ? $post_data['post_title'] : '';
|
360 |
+
$post_data['title'] = $post_data['name'];
|
361 |
+
$post_data['description'] = isset($post_data['content']) ? $post_data['content'] : '';
|
362 |
+
$post_data['additional_description'] = isset($post_data['additional_description']) ? $post_data['additional_description'] : '';
|
363 |
+
$post_data['post_status'] = 'draft';
|
364 |
+
|
365 |
+
if(isset($post_data['publish'])) {
|
366 |
+
$post_data['post_status'] = 'publish';
|
367 |
+
} else if(isset($post_data['unpublish'])) {
|
368 |
+
$post_data['post_status'] = 'draft';
|
369 |
+
}
|
370 |
+
|
371 |
+
$post_data['meta']['_wpsc_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_price'] );
|
372 |
+
$post_data['meta']['_wpsc_special_price'] = wpsc_string_to_float( $post_data['meta']['_wpsc_special_price'] );
|
373 |
+
if (!isset($post_data['meta']['_wpsc_is_donation'])) $post_data['meta']['_wpsc_is_donation'] = '';
|
374 |
+
$post_data['meta']['_wpsc_is_donation'] = (int)(bool)$post_data['meta']['_wpsc_is_donation'];
|
375 |
+
$post_data['meta']['_wpsc_stock'] = (int)$post_data['meta']['_wpsc_stock'];
|
376 |
+
|
377 |
+
if (!isset($post_data['meta']['_wpsc_limited_stock'])) $post_data['meta']['_wpsc_limited_stock'] = '';
|
378 |
+
if((bool)$post_data['meta']['_wpsc_limited_stock'] !== true) {
|
379 |
+
$post_data['meta']['_wpsc_stock'] = false;
|
380 |
+
}
|
381 |
+
unset($post_data['meta']['_wpsc_limited_stock']);
|
382 |
+
if(!isset($post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'])) $post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = '';
|
383 |
+
if(!isset($post_data['quantity_limited'])) $post_data['quantity_limited'] = '';
|
384 |
+
if(!isset($post_data['special'])) $post_data['special'] = '';
|
385 |
+
if(!isset($post_data['meta']['_wpsc_product_metadata']['no_shipping'])) $post_data['meta']['_wpsc_product_metadata']['no_shipping'] = '';
|
386 |
+
|
387 |
+
$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
388 |
+
$post_data['meta']['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$post_data['quantity_limited'];
|
389 |
+
$post_data['meta']['_wpsc_product_metadata']['special'] = (int)(bool)$post_data['special'];
|
390 |
+
$post_data['meta']['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['no_shipping'];
|
391 |
+
|
392 |
+
// Product Weight
|
393 |
+
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
394 |
+
if(!isset($post_data['meta']['_wpsc_product_metadata']['display_weight_as'])) $post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = '';
|
395 |
+
|
396 |
+
$weight = wpsc_string_to_float( $post_data['meta']['_wpsc_product_metadata']['weight'] );
|
397 |
+
$weight = wpsc_convert_weight( $weight, $post_data['meta']['_wpsc_product_metadata']['weight_unit'], "pound", true);
|
398 |
+
$post_data['meta']['_wpsc_product_metadata']['weight'] = $weight;
|
399 |
+
$post_data['meta']['_wpsc_product_metadata']['display_weight_as'] = $post_data['meta']['_wpsc_product_metadata']['weight_unit'];
|
400 |
+
|
401 |
+
$post_data['files'] = $_FILES;
|
402 |
+
return $post_data;
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* wpsc_insert_product function
|
407 |
+
*
|
408 |
+
* @param unknown
|
409 |
+
* @return unknown
|
410 |
+
*/
|
411 |
+
function wpsc_insert_product($post_data, $wpsc_error = false) {
|
412 |
+
global $wpdb, $user_ID;
|
413 |
+
$adding = false;
|
414 |
+
$update = false;
|
415 |
+
|
416 |
+
$product_columns = array(
|
417 |
+
'name' => '',
|
418 |
+
'description' => '',
|
419 |
+
'additional_description' => '',
|
420 |
+
'price' => null,
|
421 |
+
'weight' => null,
|
422 |
+
'weight_unit' => '',
|
423 |
+
'pnp' => null,
|
424 |
+
'international_pnp' => null,
|
425 |
+
'file' => null,
|
426 |
+
'image' => '0',
|
427 |
+
'quantity_limited' => '',
|
428 |
+
'quantity' => null,
|
429 |
+
'special' => null,
|
430 |
+
'special_price' => null,
|
431 |
+
'display_frontpage' => null,
|
432 |
+
'notax' => null,
|
433 |
+
'publish' => null,
|
434 |
+
'active' => null,
|
435 |
+
'donation' => null,
|
436 |
+
'no_shipping' => null,
|
437 |
+
'thumbnail_image' => null,
|
438 |
+
'thumbnail_state' => null
|
439 |
+
);
|
440 |
+
|
441 |
+
foreach ( $product_columns as $column => $default ) {
|
442 |
+
if ( ! isset( $post_data[ $column ] ) ) {
|
443 |
+
$post_data[ $column ] = '';
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
$product_post_values = array(
|
448 |
+
'post_author' => $user_ID,
|
449 |
+
'post_content' => $post_data['description'],
|
450 |
+
'post_excerpt' => $post_data['additional_description'],
|
451 |
+
'post_title' => $post_data['name'],
|
452 |
+
'post_status' => $post_data['post_status'],
|
453 |
+
'post_type' => "wpsc-product",
|
454 |
+
'post_name' => sanitize_title($post_data['name'])
|
455 |
+
);
|
456 |
+
$product_post_values["comment_status"] = "open";
|
457 |
+
|
458 |
+
$product_id = wp_insert_post($product_post_values);
|
459 |
+
if ( isset ( $post_data["sticky"] ) ) {
|
460 |
+
stick_post($product_id);
|
461 |
+
}else {
|
462 |
+
unstick_post($product_id);
|
463 |
+
}
|
464 |
+
|
465 |
+
$adding = true;
|
466 |
+
|
467 |
+
// if we succeed, we can do further editing
|
468 |
+
|
469 |
+
// and the meta
|
470 |
+
wpsc_update_product_meta($product_id, $post_data['meta']);
|
471 |
+
do_action('wpsc_edit_product', $product_id);
|
472 |
+
return $product_id;
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* term_id_price function
|
477 |
+
* Retreives associated price, if any, with term_id
|
478 |
+
* @param integer term ID
|
479 |
+
* @param integer parent product price
|
480 |
+
* @return integer modified price for child product, based on term ID price and parent price
|
481 |
+
*/
|
482 |
+
|
483 |
+
function term_id_price($term_id, $parent_price) {
|
484 |
+
|
485 |
+
$term_price_arr = get_option( 'term_prices' );
|
486 |
+
|
487 |
+
if ( isset($term_price_arr[$term_id]) ) {
|
488 |
+
$price = $term_price_arr[$term_id]["price"];
|
489 |
+
} else {
|
490 |
+
$price = 0;
|
491 |
+
}
|
492 |
+
|
493 |
+
//Check for flat, percentile or differential
|
494 |
+
$var_price_type = '';
|
495 |
+
|
496 |
+
if (flat_price($price)) {
|
497 |
+
$var_price_type = 'flat';
|
498 |
+
$price = floatval($price);
|
499 |
+
} elseif ( differential_price($price) ) {
|
500 |
+
$var_price_type = 'differential';
|
501 |
+
} elseif (percentile_price($price)) {
|
502 |
+
$var_price_type = 'percentile';
|
503 |
+
}
|
504 |
+
|
505 |
+
if (strchr($price, '-') ) {
|
506 |
+
$positive = false;
|
507 |
+
} else {
|
508 |
+
$positive = true;
|
509 |
+
}
|
510 |
+
|
511 |
+
if ($positive) {
|
512 |
+
|
513 |
+
if ( $var_price_type == 'differential' ) {
|
514 |
+
$differential = (floatval($price));
|
515 |
+
$price = $parent_price + $differential;
|
516 |
+
} elseif ( $var_price_type == 'percentile' ) {
|
517 |
+
$percentage = (floatval($price) / 100);
|
518 |
+
$price = $parent_price + ($parent_price * $percentage);
|
519 |
+
}
|
520 |
+
} else {
|
521 |
+
|
522 |
+
if ( $var_price_type == 'differential' ) {
|
523 |
+
$differential = (floatval($price));
|
524 |
+
$price = $parent_price - $differential;
|
525 |
+
} elseif ( $var_price_type == 'percentile' ) {
|
526 |
+
$percentage = (floatval($price) / 100);
|
527 |
+
$price = $parent_price - ($parent_price * $percentage);
|
528 |
+
}
|
529 |
+
}
|
530 |
+
return $price;
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Determine the price of a variation product based on the variation it's assigned
|
535 |
+
* to. Because each variation term can have its own price (eg. 10, +10, -5%), this
|
536 |
+
* function also takes those into account.
|
537 |
+
*
|
538 |
+
* @since 3.8.6
|
539 |
+
* @param int $variation_id ID of the variation product
|
540 |
+
* @param string $terms Optional. Defaults to false. Variation terms assigned to
|
541 |
+
* the variation product. Pass this argument to save one SQL query.
|
542 |
+
* @return float Calculated price of the variation
|
543 |
+
*/
|
544 |
+
function wpsc_determine_variation_price( $variation_id, $term_ids = false ) {
|
545 |
+
$flat = array();
|
546 |
+
$diff = 0;
|
547 |
+
|
548 |
+
$variation = get_post( $variation_id );
|
549 |
+
$price = (float) get_product_meta( $variation->post_parent, 'price', true );
|
550 |
+
|
551 |
+
if ( ! $term_ids )
|
552 |
+
$term_ids = wpsc_get_product_terms( $variation_id, 'wpsc-variation', 'term_id' );
|
553 |
+
|
554 |
+
$term_price_arr = get_option( 'term_prices' );
|
555 |
+
foreach ( $term_ids as $term_id ) {
|
556 |
+
if ( isset( $term_price_arr[$term_id] ) )
|
557 |
+
$term_price = trim( $term_price_arr[$term_id]['price'] );
|
558 |
+
else
|
559 |
+
continue;
|
560 |
+
if ( flat_price( $term_price ) ) {
|
561 |
+
$flat[] = $term_price;
|
562 |
+
} elseif ( differential_price( $term_price ) ) {
|
563 |
+
$diff += (float) $term_price;
|
564 |
+
} elseif ( percentile_price( $term_price ) ) {
|
565 |
+
$diff += (float) $term_price / 100 * $price;
|
566 |
+
}
|
567 |
+
}
|
568 |
+
// Variation price should at least be the maximum of all flat prices
|
569 |
+
if ( ! empty( $flat ) )
|
570 |
+
$price = max( $flat );
|
571 |
+
$price += $diff;
|
572 |
+
return $price;
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* wpsc_edit_product_variations function.
|
577 |
+
* this is the function to make child products using variations
|
578 |
+
*
|
579 |
+
* @access public
|
580 |
+
* @param mixed $product_id
|
581 |
+
* @param mixed $post_data
|
582 |
+
* @return void
|
583 |
+
*/
|
584 |
+
function wpsc_edit_product_variations($product_id, $post_data) {
|
585 |
+
global $user_ID;
|
586 |
+
|
587 |
+
$parent = get_post_field( 'post_parent', $product_id );
|
588 |
+
|
589 |
+
if( ! empty( $parent ) )
|
590 |
+
return;
|
591 |
+
|
592 |
+
$variations = array();
|
593 |
+
$product_children = array();
|
594 |
+
if (!isset($post_data['edit_var_val']))
|
595 |
+
$post_data['edit_var_val'] = '';
|
596 |
+
|
597 |
+
$variations = (array) $post_data['edit_var_val'];
|
598 |
+
|
599 |
+
// Generate the arrays for variation sets, values and combinations
|
600 |
+
$wpsc_combinator = new wpsc_variation_combinator($variations);
|
601 |
+
|
602 |
+
// Retrieve the array containing the variation set IDs
|
603 |
+
$variation_sets = $wpsc_combinator->return_variation_sets();
|
604 |
+
|
605 |
+
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
606 |
+
$variation_values = $wpsc_combinator->return_variation_values();
|
607 |
+
|
608 |
+
// Retrieve the array containing the combinations of each variation set to be associated with this product.
|
609 |
+
$combinations = $wpsc_combinator->return_combinations();
|
610 |
+
|
611 |
+
$product_terms = wpsc_get_product_terms( $product_id, 'wpsc-variation' );
|
612 |
+
|
613 |
+
$variation_sets_and_values = array_merge($variation_sets, $variation_values);
|
614 |
+
$variation_sets_and_values = apply_filters('wpsc_edit_product_variation_sets_and_values', $variation_sets_and_values, $product_id);
|
615 |
+
|
616 |
+
wp_set_object_terms($product_id, $variation_sets_and_values, 'wpsc-variation');
|
617 |
+
|
618 |
+
$parent_id = absint( $_REQUEST['product_id'] );
|
619 |
+
|
620 |
+
$child_product_template = array(
|
621 |
+
'post_author' => $user_ID,
|
622 |
+
'post_content' => get_post_field( 'post_content', $parent_id, 'raw' ),
|
623 |
+
'post_excerpt' => get_post_field( 'post_excerpt', $parent_id, 'raw' ),
|
624 |
+
'post_title' => get_post_field( 'post_title', $parent_id, 'raw' ),
|
625 |
+
'post_status' => 'inherit',
|
626 |
+
'post_type' => "wpsc-product",
|
627 |
+
'post_parent' => $product_id
|
628 |
+
);
|
629 |
+
|
630 |
+
$child_product_meta = get_post_custom($product_id);
|
631 |
+
|
632 |
+
// here we loop through the combinations, get the term data and generate custom product names
|
633 |
+
foreach($combinations as $combination) {
|
634 |
+
$term_names = array();
|
635 |
+
$term_ids = array();
|
636 |
+
$term_slugs = array();
|
637 |
+
$product_values = $child_product_template;
|
638 |
+
|
639 |
+
$combination_terms = get_terms('wpsc-variation', array(
|
640 |
+
'hide_empty' => 0,
|
641 |
+
'include' => implode(",", $combination),
|
642 |
+
'orderby' => 'parent',
|
643 |
+
));
|
644 |
+
|
645 |
+
foreach($combination_terms as $term) {
|
646 |
+
$term_ids[] = $term->term_id;
|
647 |
+
$term_slugs[] = $term->slug;
|
648 |
+
$term_names[] = $term->name;
|
649 |
+
}
|
650 |
+
|
651 |
+
$product_values['post_title'] .= " (".implode(", ", $term_names).")";
|
652 |
+
$product_values['post_name'] = sanitize_title($product_values['post_title']);
|
653 |
+
|
654 |
+
$selected_post = get_posts(array(
|
655 |
+
'name' => $product_values['post_name'],
|
656 |
+
'post_parent' => $product_id,
|
657 |
+
'post_type' => "wpsc-product",
|
658 |
+
'post_status' => 'all',
|
659 |
+
'suppress_filters' => true
|
660 |
+
));
|
661 |
+
$selected_post = array_shift($selected_post);
|
662 |
+
$child_product_id = wpsc_get_child_object_in_terms($product_id, $term_ids, 'wpsc-variation');
|
663 |
+
$already_a_variation = true;
|
664 |
+
if($child_product_id == false) {
|
665 |
+
$already_a_variation = false;
|
666 |
+
if($selected_post != null) {
|
667 |
+
$child_product_id = $selected_post->ID;
|
668 |
+
} else {
|
669 |
+
$child_product_id = wp_insert_post($product_values);
|
670 |
+
}
|
671 |
+
} else {
|
672 |
+
// sometimes there have been problems saving the variations, this gets the correct product ID
|
673 |
+
if(($selected_post != null) && ($selected_post->ID != $child_product_id)) {
|
674 |
+
$child_product_id = $selected_post->ID;
|
675 |
+
}
|
676 |
+
}
|
677 |
+
$product_children[] = $child_product_id;
|
678 |
+
if($child_product_id > 0) {
|
679 |
+
wp_set_object_terms($child_product_id, $term_slugs, 'wpsc-variation');
|
680 |
+
}
|
681 |
+
//JS - 7.9 - Adding loop to include meta data in child product.
|
682 |
+
if(!$already_a_variation){
|
683 |
+
$this_child_product_meta = apply_filters( 'insert_child_product_meta', $child_product_meta, $product_id, $combination_terms );
|
684 |
+
foreach ($this_child_product_meta as $meta_key => $meta_value ) :
|
685 |
+
if ($meta_key == "_wpsc_product_metadata") {
|
686 |
+
update_post_meta($child_product_id, $meta_key, unserialize($meta_value[0]));
|
687 |
+
} else {
|
688 |
+
update_post_meta($child_product_id, $meta_key, $meta_value[0]);
|
689 |
+
}
|
690 |
+
|
691 |
+
endforeach;
|
692 |
+
|
693 |
+
if ( is_array( $term_ids ) && $price = wpsc_determine_variation_price( $child_product_id, $term_ids ) )
|
694 |
+
update_product_meta( $child_product_id, 'price', $price );
|
695 |
+
}
|
696 |
+
}
|
697 |
+
|
698 |
+
//For reasons unknown, this code did not previously deal with variation deletions.
|
699 |
+
//Basically, we'll just check if any existing term associations are missing from the posted variables, delete if they are.
|
700 |
+
//Get posted terms (multi-dimensional array, first level = parent var, second level = child var)
|
701 |
+
$posted_term = $variations;
|
702 |
+
//Get currently associated terms
|
703 |
+
$currently_associated_var = $product_terms;
|
704 |
+
|
705 |
+
$currently_associated_vars = array();
|
706 |
+
foreach ($currently_associated_var as $current) {
|
707 |
+
$currently_associated_vars[] = $current->term_id;
|
708 |
+
}
|
709 |
+
|
710 |
+
$posted_terms = array();
|
711 |
+
|
712 |
+
foreach ($posted_term as $term=>$val) {
|
713 |
+
$posted_terms[] = $term;
|
714 |
+
if(is_array($val)) {
|
715 |
+
foreach($val as $term2=>$val2) {
|
716 |
+
$posted_terms[] = $term2;
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
if(!empty($currently_associated_vars)){
|
722 |
+
$term_ids_to_delete = array();
|
723 |
+
$term_ids_to_delete = array_diff($currently_associated_vars, $posted_terms);
|
724 |
+
}
|
725 |
+
|
726 |
+
if(isset($_REQUEST["post_ID"])) {
|
727 |
+
$post_id = $_REQUEST["post_ID"];
|
728 |
+
} elseif(isset($_REQUEST["product_id"])) {
|
729 |
+
$post_id = $_REQUEST["product_id"];
|
730 |
+
} else {
|
731 |
+
return;
|
732 |
+
}
|
733 |
+
|
734 |
+
if(!empty($term_ids_to_delete) && (isset($_REQUEST["product_id"]) || isset($post_id))) {
|
735 |
+
$post_ids_to_delete = array();
|
736 |
+
|
737 |
+
// Whatever remains, find child products of current product with that term, in the variation taxonomy, and delete
|
738 |
+
$post_ids_to_delete = wpsc_get_child_object_in_terms_var($_REQUEST["product_id"], $term_ids_to_delete, 'wpsc-variation');
|
739 |
+
|
740 |
+
if(is_array($post_ids_to_delete) && !empty($post_ids_to_delete)) {
|
741 |
+
foreach($post_ids_to_delete as $object_ids) {
|
742 |
+
foreach($object_ids as $object_id) {
|
743 |
+
wp_delete_post($object_id);
|
744 |
+
}
|
745 |
+
}
|
746 |
+
}
|
747 |
+
}
|
748 |
+
$current_children = get_posts(array(
|
749 |
+
'post_parent' => $post_id,
|
750 |
+
'post_type' => 'wpsc-product',
|
751 |
+
'post_status' => 'all',
|
752 |
+
'numberposts' => -1
|
753 |
+
));
|
754 |
+
|
755 |
+
$children = array();
|
756 |
+
foreach((array)$current_children as $child_prod){
|
757 |
+
$children[] = $child_prod->ID;
|
758 |
+
}
|
759 |
+
if(!empty($children)){
|
760 |
+
$old_ids_to_delete = array_diff($children, $product_children);
|
761 |
+
$old_ids_to_delete = apply_filters('wpsc_edit_product_variations_deletion', $old_ids_to_delete);
|
762 |
+
if(is_array($old_ids_to_delete) && !empty($old_ids_to_delete)) {
|
763 |
+
foreach($old_ids_to_delete as $object_ids) {
|
764 |
+
wp_delete_post($object_ids);
|
765 |
+
}
|
766 |
+
}
|
767 |
+
}
|
768 |
+
_wpsc_refresh_parent_product_terms( $parent_id );
|
769 |
+
|
770 |
+
}
|
771 |
+
|
772 |
+
function wpsc_update_alt_product_currency($product_id, $newCurrency, $newPrice){
|
773 |
+
global $wpdb;
|
774 |
+
|
775 |
+
$old_curr = get_product_meta($product_id, 'currency',true);
|
776 |
+
$sql = $wpdb->prepare( "SELECT `isocode` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`= %d", $newCurrency );
|
777 |
+
$isocode = $wpdb->get_var($sql);
|
778 |
+
|
779 |
+
$newCurrency = 'currency';
|
780 |
+
$old_curr[$isocode] = $newPrice;
|
781 |
+
if(($newPrice != '') && ($newPrice > 0.00)){
|
782 |
+
update_product_meta($product_id, $newCurrency, $old_curr);
|
783 |
+
} else {
|
784 |
+
if((empty($old_curr[$isocode]) || 0.00 == $old_curr[$isocode]) && is_array($old_curr))
|
785 |
+
unset($old_curr[$isocode]);
|
786 |
+
update_product_meta($product_id, $newCurrency, $old_curr);
|
787 |
+
|
788 |
+
}
|
789 |
+
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* wpsc_update_product_meta function
|
794 |
+
*
|
795 |
+
* @param integer product ID
|
796 |
+
* @param string comma separated tags
|
797 |
+
*/
|
798 |
+
function wpsc_update_product_meta($product_id, $product_meta) {
|
799 |
+
if($product_meta != null) {
|
800 |
+
foreach((array)$product_meta as $key => $value) {
|
801 |
+
update_post_meta($product_id, $key, $value);
|
802 |
+
}
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
/**
|
807 |
+
* Called from javascript within product page to toggle publish status - AJAX
|
808 |
+
* @return bool publish status
|
809 |
+
*/
|
810 |
+
function wpsc_ajax_toggle_publish() {
|
811 |
+
/**
|
812 |
+
* @todo - Check Admin Referer
|
813 |
+
* @todo - Check Permissions
|
814 |
+
*/
|
815 |
+
$status = (wpsc_toggle_publish_status($_REQUEST['productid'])) ? ('true') : ('false');
|
816 |
+
exit( $status );
|
817 |
+
}
|
818 |
+
/*
|
819 |
+
/* END - Publish /No Publish functions
|
820 |
+
*/
|
821 |
+
|
822 |
+
function wpsc_update_custom_meta($product_id, $post_data) {
|
823 |
+
|
824 |
+
if ( isset( $post_data['new_custom_meta'] ) && $post_data['new_custom_meta'] != null ) {
|
825 |
+
foreach((array)$post_data['new_custom_meta']['name'] as $key => $name) {
|
826 |
+
$value = $post_data['new_custom_meta']['value'][(int)$key];
|
827 |
+
if(($name != '') && ($value != '')) {
|
828 |
+
add_post_meta($product_id, $name, $value);
|
829 |
+
}
|
830 |
+
}
|
831 |
+
}
|
832 |
+
|
833 |
+
if (!isset($post_data['custom_meta'])) $post_data['custom_meta'] = '';
|
834 |
+
if($post_data['custom_meta'] != null) {
|
835 |
+
foreach((array)$post_data['custom_meta'] as $key => $values) {
|
836 |
+
if(($values['name'] != '') && ($values['value'] != '')) {
|
837 |
+
update_post_meta($product_id, $values['name'], $values['value']);
|
838 |
+
}
|
839 |
+
}
|
840 |
+
}
|
841 |
+
}
|
842 |
+
|
843 |
+
/**
|
844 |
+
* wpsc_item_process_file function
|
845 |
+
*
|
846 |
+
* @param integer product ID
|
847 |
+
* @param array the file array from $_FILES
|
848 |
+
* @param array the preview file array from $_FILES
|
849 |
+
*/
|
850 |
+
function wpsc_item_process_file( $product_id, $submitted_file, $preview_file = null ) {
|
851 |
+
|
852 |
+
add_filter( 'upload_dir', 'wpsc_modify_upload_directory' );
|
853 |
+
|
854 |
+
$time = current_time( 'mysql' );
|
855 |
+
|
856 |
+
if ( $post = get_post( $product_id ) ) {
|
857 |
+
if ( substr( $post->post_date, 0, 4 ) > 0 )
|
858 |
+
$time = $post->post_date;
|
859 |
+
}
|
860 |
+
|
861 |
+
$file = wp_handle_upload( $submitted_file, array( 'test_form' => false ), $time );
|
862 |
+
|
863 |
+
if ( isset( $file['error'] ) ) {
|
864 |
+
return new WP_Error( 'upload_error', $file['error'] );
|
865 |
+
}
|
866 |
+
|
867 |
+
$name_parts = pathinfo( $file['file'] );
|
868 |
+
|
869 |
+
// Construct the attachment array
|
870 |
+
$attachment = array(
|
871 |
+
'post_mime_type' => $file['type'],
|
872 |
+
'guid' => $file['url'],
|
873 |
+
'post_parent' => $product_id,
|
874 |
+
'post_title' => $name_parts['basename'],
|
875 |
+
'post_content' => '',
|
876 |
+
'post_type' => 'wpsc-product-file',
|
877 |
+
'post_status' => 'inherit'
|
878 |
+
);
|
879 |
+
|
880 |
+
// Save the data
|
881 |
+
wp_insert_post( $attachment );
|
882 |
+
|
883 |
+
remove_filter( 'upload_dir', 'wpsc_modify_upload_directory' );
|
884 |
+
}
|
885 |
+
|
886 |
+
function wpsc_modify_upload_directory($input) {
|
887 |
+
$previous_subdir = $input['subdir'];
|
888 |
+
$download_subdir = str_replace($input['basedir'], '', WPSC_FILE_DIR);
|
889 |
+
$input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
|
890 |
+
$input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
|
891 |
+
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
892 |
+
return $input;
|
893 |
+
}
|
894 |
+
|
895 |
+
function wpsc_modify_preview_directory($input) {
|
896 |
+
$previous_subdir = $input['subdir'];
|
897 |
+
$download_subdir = str_replace($input['basedir'], '', WPSC_PREVIEW_DIR);
|
898 |
+
|
899 |
+
$input['path'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['path']),'',-1);
|
900 |
+
$input['url'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['url']),'',-1);
|
901 |
+
$input['subdir'] = substr_replace(str_replace($previous_subdir, $download_subdir, $input['subdir']),'',-1);
|
902 |
+
|
903 |
+
return $input;
|
904 |
+
}
|
905 |
+
|
906 |
+
/**
|
907 |
+
* wpsc_item_reassign_file function
|
908 |
+
*
|
909 |
+
* @param integer product ID
|
910 |
+
* @param string the selected file name;
|
911 |
+
*/
|
912 |
+
function wpsc_item_reassign_file($product_id, $selected_files) {
|
913 |
+
global $wpdb;
|
914 |
+
$product_file_list = array();
|
915 |
+
// initialise $idhash to null to prevent issues with undefined variables and error logs
|
916 |
+
$idhash = null;
|
917 |
+
|
918 |
+
$args = array(
|
919 |
+
'post_type' => 'wpsc-product-file',
|
920 |
+
'post_parent' => $product_id,
|
921 |
+
'numberposts' => -1,
|
922 |
+
'post_status' => 'any'
|
923 |
+
);
|
924 |
+
|
925 |
+
$attached_files = (array) get_posts( $args );
|
926 |
+
$attached_files_by_file = array();
|
927 |
+
|
928 |
+
foreach($attached_files as $key => $attached_file) {
|
929 |
+
$attached_files_by_file[$attached_file->post_title] = $attached_files[$key];
|
930 |
+
}
|
931 |
+
|
932 |
+
/* if we are editing, grab the current file and ID hash */
|
933 |
+
if(!$selected_files) {
|
934 |
+
// unlikely that anyone will ever upload a file called .none., so its the value used to signify clearing the product association
|
935 |
+
return null;
|
936 |
+
}
|
937 |
+
|
938 |
+
foreach($selected_files as $selected_file) {
|
939 |
+
// if we already use this file, there is no point doing anything more.
|
940 |
+
$file_is_attached = false;
|
941 |
+
$selected_file_path = WPSC_FILE_DIR.basename($selected_file);
|
942 |
+
|
943 |
+
if(isset($attached_files_by_file[$selected_file])) {
|
944 |
+
$file_is_attached = true;
|
945 |
+
}
|
946 |
+
|
947 |
+
if($file_is_attached == false ) {
|
948 |
+
$type = wpsc_get_mimetype($selected_file_path);
|
949 |
+
$attachment = array(
|
950 |
+
'post_mime_type' => $type,
|
951 |
+
'post_parent' => $product_id,
|
952 |
+
'post_title' => $selected_file,
|
953 |
+
'post_content' => '',
|
954 |
+
'post_type' => "wpsc-product-file",
|
955 |
+
'post_status' => 'inherit'
|
956 |
+
);
|
957 |
+
wp_insert_post($attachment);
|
958 |
+
} else {
|
959 |
+
$product_post_values = array(
|
960 |
+
'ID' => $attached_files_by_file[$selected_file]->ID,
|
961 |
+
'post_status' => 'inherit'
|
962 |
+
);
|
963 |
+
wp_update_post($product_post_values);
|
964 |
+
}
|
965 |
+
}
|
966 |
+
|
967 |
+
|
968 |
+
foreach($attached_files as $attached_file) {
|
969 |
+
if(!in_array($attached_file->post_title, $selected_files)) {
|
970 |
+
$product_post_values = array(
|
971 |
+
'ID' => $attached_file->ID,
|
972 |
+
'post_status' => 'draft'
|
973 |
+
);
|
974 |
+
wp_update_post($product_post_values);
|
975 |
+
}
|
976 |
+
}
|
977 |
+
|
978 |
+
return true;
|
979 |
+
}
|
980 |
+
|
981 |
+
/**
|
982 |
+
* wpsc_delete_preview_file
|
983 |
+
*
|
984 |
+
* @param integer product ID
|
985 |
+
*/
|
986 |
+
|
987 |
+
function wpsc_delete_preview_file($product_id) {
|
988 |
+
|
989 |
+
$args = array(
|
990 |
+
'post_type' => 'wpsc-preview-file',
|
991 |
+
'post_parent' => $product_id,
|
992 |
+
'numberposts' => -1,
|
993 |
+
'post_status' => 'all'
|
994 |
+
);
|
995 |
+
|
996 |
+
$preview_files = (array)get_posts( $args );
|
997 |
+
|
998 |
+
foreach( $preview_files as $preview ) {
|
999 |
+
$preview_id = $preview->ID;
|
1000 |
+
wp_delete_post($preview_id);
|
1001 |
+
}
|
1002 |
+
return true;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
/**
|
1006 |
+
* wpsc_item_add_preview_file function
|
1007 |
+
*
|
1008 |
+
* @param integer product ID
|
1009 |
+
* @param array the preview file array from $_FILES
|
1010 |
+
*/
|
1011 |
+
function wpsc_item_add_preview_file($product_id, $preview_file) {
|
1012 |
+
global $wpdb;
|
1013 |
+
|
1014 |
+
wpsc_delete_preview_file($product_id);
|
1015 |
+
|
1016 |
+
add_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1017 |
+
$overrides = array('test_form'=>false);
|
1018 |
+
|
1019 |
+
$time = current_time('mysql');
|
1020 |
+
if ( $post = get_post($product_id) ) {
|
1021 |
+
if ( substr( $post->post_date, 0, 4 ) > 0 )
|
1022 |
+
$time = $post->post_date;
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
$file = wp_handle_upload($preview_file, $overrides, $time);
|
1026 |
+
|
1027 |
+
if ( isset($file['error']) )
|
1028 |
+
return new WP_Error( 'upload_error', $file['error'] );
|
1029 |
+
|
1030 |
+
$name_parts = pathinfo($file['file']);
|
1031 |
+
$name = $name_parts['basename'];
|
1032 |
+
|
1033 |
+
$url = $file['url'];
|
1034 |
+
$type = $file['type'];
|
1035 |
+
$file = $file['file'];
|
1036 |
+
$title = $name;
|
1037 |
+
$content = '';
|
1038 |
+
|
1039 |
+
// Construct the attachment array
|
1040 |
+
$attachment = array(
|
1041 |
+
'post_mime_type' => $type,
|
1042 |
+
'guid' => $url,
|
1043 |
+
'post_parent' => $product_id,
|
1044 |
+
'post_title' => $title,
|
1045 |
+
'post_content' => $content,
|
1046 |
+
'post_type' => "wpsc-preview-file",
|
1047 |
+
'post_status' => 'inherit'
|
1048 |
+
);
|
1049 |
+
|
1050 |
+
// Save the data
|
1051 |
+
$id = wp_insert_post($attachment, $file, $product_id);
|
1052 |
+
remove_filter('upload_dir', 'wpsc_modify_preview_directory');
|
1053 |
+
return $id;
|
1054 |
+
|
1055 |
+
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
/**
|
1059 |
+
* wpsc_variation_combinator class.
|
1060 |
+
* Produces all combinations of variations selected for this product
|
1061 |
+
* this class is based off the example code from here:
|
1062 |
+
* http://www.php.net/manual/en/ref.array.php#94910
|
1063 |
+
* Thanks, phektus, you are awesome, whoever you are.
|
1064 |
+
*/
|
1065 |
+
class wpsc_variation_combinator {
|
1066 |
+
var $variation_sets = array();
|
1067 |
+
var $variation_values = array();
|
1068 |
+
var $reprocessed_array = array();
|
1069 |
+
var $combinations= array();
|
1070 |
+
|
1071 |
+
public function __construct($variation_sets) {
|
1072 |
+
if( $variation_sets ) {
|
1073 |
+
foreach($variation_sets as $variation_set_id => $variation_set) {
|
1074 |
+
$this->variation_sets[] = absint($variation_set_id);
|
1075 |
+
$new_variation_set = array();
|
1076 |
+
if( $variation_set ) {
|
1077 |
+
foreach($variation_set as $variation => $active) {
|
1078 |
+
if($active == 1) {
|
1079 |
+
$new_variation_set[] = array(absint($variation));
|
1080 |
+
$this->variation_values[] = $variation;
|
1081 |
+
}
|
1082 |
+
}
|
1083 |
+
}
|
1084 |
+
$this->reprocessed_array[] = $new_variation_set;
|
1085 |
+
}
|
1086 |
+
$this->get_combinations(array(), $this->reprocessed_array, 0);
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
|
1091 |
+
function get_combinations($batch, $elements, $i) {
|
1092 |
+
if ($i >= count($elements)) {
|
1093 |
+
$this->combinations[] = $batch;
|
1094 |
+
} else {
|
1095 |
+
foreach ($elements[$i] as $element) {
|
1096 |
+
$this->get_combinations(array_merge($batch, $element), $elements, $i + 1);
|
1097 |
+
}
|
1098 |
+
}
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
function return_variation_sets() {
|
1102 |
+
return $this->variation_sets;
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
function return_variation_values() {
|
1106 |
+
return $this->variation_values;
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
function return_combinations() {
|
1110 |
+
return $this->combinations;
|
1111 |
+
|
1112 |
+
}
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
function wpsc_variations_stock_remaining($product_id){
|
1116 |
+
global $wpdb;
|
1117 |
+
return $wpdb->get_var( $wpdb->prepare( '
|
1118 |
+
SELECT
|
1119 |
+
sum(`pm`.`meta_value`)
|
1120 |
+
FROM
|
1121 |
+
`' . $wpdb->postmeta . '` `pm`
|
1122 |
+
JOIN
|
1123 |
+
`' . $wpdb->posts . '` `p`
|
1124 |
+
ON
|
1125 |
+
`pm`.`post_id` = `p`.`id`
|
1126 |
+
WHERE
|
1127 |
+
`p`.`post_type`= "wpsc-product"
|
1128 |
+
AND
|
1129 |
+
`p`.`post_parent` = %d
|
1130 |
+
AND
|
1131 |
+
`pm`.`meta_key` = "_wpsc_stock"
|
1132 |
+
', $product_id ) );
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
function flat_price( $price ) {
|
1136 |
+
if ( ! empty( $price ) && strchr( $price, '-' ) === false && strchr( $price, '+' ) === false && strchr( $price, '%' ) === false )
|
1137 |
+
return true;
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
function percentile_price( $price ) {
|
1141 |
+
if ( ! empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) )
|
1142 |
+
return true;
|
1143 |
+
}
|
1144 |
+
|
1145 |
+
function differential_price( $price ) {
|
1146 |
+
if ( ! empty( $price ) && ( strchr( $price, '-' ) || strchr( $price, '+' ) ) && strchr( $price, '%' ) === false )
|
1147 |
+
return true;
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
/**
|
1151 |
+
* Refresh variation terms assigned to parent product based on the variations it has.
|
1152 |
+
*
|
1153 |
+
* @since 3.8.9
|
1154 |
+
* @access private
|
1155 |
+
* @param int $parent_id Parent product ID
|
1156 |
+
*/
|
1157 |
+
function _wpsc_refresh_parent_product_terms( $parent_id ) {
|
1158 |
+
$children = get_children( array(
|
1159 |
+
'post_parent' => $parent_id,
|
1160 |
+
'post_status' => array( 'publish', 'inherit' ),
|
1161 |
+
) );
|
1162 |
+
|
1163 |
+
$children_ids = wp_list_pluck( $children, 'ID' );
|
1164 |
+
|
1165 |
+
$children_terms = wp_get_object_terms( $children_ids, 'wpsc-variation' );
|
1166 |
+
$new_terms = array();
|
1167 |
+
foreach ( $children_terms as $term ) {
|
1168 |
+
if ( $term->parent )
|
1169 |
+
$new_terms[] = $term->parent;
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
$children_term_ids = wp_list_pluck( $children_terms, 'term_id' );
|
1173 |
+
$new_terms = array_merge( $new_terms, $children_term_ids );
|
1174 |
+
$new_terms = array_unique( $new_terms );
|
1175 |
+
$new_terms = array_map( 'absint', $new_terms );
|
1176 |
+
wp_set_object_terms( $parent_id, $new_terms, 'wpsc-variation' );
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
/**
|
1180 |
+
* Make sure parent product's assigned terms are refreshed when its variations are deleted or trashed
|
1181 |
+
*
|
1182 |
+
* @since 3.8.9
|
1183 |
+
* @access private
|
1184 |
+
* @param int $post_id Parent product ID
|
1185 |
+
*/
|
1186 |
+
function _wpsc_action_refresh_variation_parent_terms( $post_id ) {
|
1187 |
+
$post = get_post( $post_id );
|
1188 |
+
if ( $post->post_type != 'wpsc-product' || ! $post->post_parent || in_array( $post->post_status, array( 'publish', 'inherit' ) ) )
|
1189 |
+
return;
|
1190 |
+
|
1191 |
+
_wpsc_refresh_parent_product_terms( $post->post_parent );
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
/**
|
1195 |
+
* Make sure parent product's assigned terms are refresh when its variations' statuses are changed
|
1196 |
+
*
|
1197 |
+
* @since 3.8.9
|
1198 |
+
* @access private
|
1199 |
+
* @param string $new_status New status
|
1200 |
+
* @param string $old_status Old status
|
1201 |
+
* @param object $post Variation object
|
1202 |
+
*/
|
1203 |
+
function _wpsc_action_transition_post_status( $new_status, $old_status, $post ) {
|
1204 |
+
if ( $post->post_type != 'wpsc-product' || ! $post->post_parent )
|
1205 |
+
return;
|
1206 |
+
|
1207 |
+
_wpsc_refresh_parent_product_terms( $post->post_parent );
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
/**
|
1211 |
+
* Prevent parent terms from being refreshed when its variations are updated. This is useful when
|
1212 |
+
* the variations are being mass updated.
|
1213 |
+
*
|
1214 |
+
* @since 3.8.9
|
1215 |
+
* @access private
|
1216 |
+
*/
|
1217 |
+
function _wpsc_remove_refresh_variation_parent_term_hooks() {
|
1218 |
+
remove_action( 'transition_post_status', '_wpsc_action_transition_post_status', 10, 3 );
|
1219 |
+
remove_action( 'deleted_post', '_wpsc_action_refresh_variation_parent_terms', 10, 1 );
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
/**
|
1223 |
+
* Add hooks so that parent product's assigned terms are refreshed when its variations are updated.
|
1224 |
+
*
|
1225 |
+
* @since 3.8.9
|
1226 |
+
* @access private
|
1227 |
+
*/
|
1228 |
+
function _wpsc_add_refresh_variation_parent_term_hooks() {
|
1229 |
+
add_action( 'transition_post_status', '_wpsc_action_transition_post_status', 10, 3 );
|
1230 |
+
add_action( 'deleted_post', '_wpsc_action_refresh_variation_parent_terms', 10, 1 );
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
_wpsc_add_refresh_variation_parent_term_hooks();
|
trunk/wpsc-admin/includes/product-variation-list-table.class.php
ADDED
@@ -0,0 +1,678 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
4 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Product Variation List Table class
|
8 |
+
*
|
9 |
+
* @package wp-e-commerce
|
10 |
+
*/
|
11 |
+
class WPSC_Product_Variation_List_Table extends WP_List_Table {
|
12 |
+
private $product_id;
|
13 |
+
private $object_terms_cache = array();
|
14 |
+
private $args = array();
|
15 |
+
private $is_trash = false;
|
16 |
+
private $is_draft = false;
|
17 |
+
private $is_publish = false;
|
18 |
+
private $is_all = true;
|
19 |
+
private $is_bulk_edit = false;
|
20 |
+
private $bulk_edited_items = array();
|
21 |
+
private $bulk_edited_item_ids = array();
|
22 |
+
|
23 |
+
public function __construct( $product_id ) {
|
24 |
+
WP_List_Table::__construct( array(
|
25 |
+
'plural' => 'variations',
|
26 |
+
) );
|
27 |
+
|
28 |
+
$this->product_id = $product_id;
|
29 |
+
if ( isset( $_REQUEST['post_status'] ) ) {
|
30 |
+
$this->is_trash = $_REQUEST['post_status'] == 'trash';
|
31 |
+
$this->is_draft = $_REQUEST['post_status'] == 'draft';
|
32 |
+
$this->is_publish = $_REQUEST['post_status'] == 'publish';
|
33 |
+
$this->is_all = $_REQUEST['post_status'] == 'all';
|
34 |
+
} else {
|
35 |
+
$this->is_all = true;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
public function prepare_items() {
|
40 |
+
if ( ! empty( $this->items ) )
|
41 |
+
return;
|
42 |
+
|
43 |
+
$per_page = $this->get_items_per_page( 'edit_wpsc-product-variations_per_page' );
|
44 |
+
$per_page = apply_filters( 'edit_wpsc_product_variations_per_page', $per_page );
|
45 |
+
$this->args = array(
|
46 |
+
'post_type' => 'wpsc-product',
|
47 |
+
'orderby' => 'menu_order title',
|
48 |
+
'post_parent' => $this->product_id,
|
49 |
+
'post_status' => 'publish, inherit',
|
50 |
+
'numberposts' => -1,
|
51 |
+
'order' => "ASC",
|
52 |
+
'posts_per_page' => $per_page,
|
53 |
+
);
|
54 |
+
|
55 |
+
if ( isset( $_REQUEST['post_status'] ) )
|
56 |
+
$this->args['post_status'] = $_REQUEST['post_status'];
|
57 |
+
|
58 |
+
if ( isset( $_REQUEST['s'] ) )
|
59 |
+
$this->args['s'] = $_REQUEST['s'];
|
60 |
+
|
61 |
+
if ( isset( $_REQUEST['paged'] ) )
|
62 |
+
$this->args['paged'] = $_REQUEST['paged'];
|
63 |
+
|
64 |
+
$query = new WP_Query( $this->args );
|
65 |
+
|
66 |
+
$this->items = $query->posts;
|
67 |
+
$total_items = $query->found_posts;
|
68 |
+
$total_pages = $query->max_num_pages;
|
69 |
+
|
70 |
+
$this->set_pagination_args( array(
|
71 |
+
'total_items' => $total_items,
|
72 |
+
'total_pages' => $total_pages,
|
73 |
+
'per_page' => $per_page
|
74 |
+
) );
|
75 |
+
|
76 |
+
if ( empty( $this->items ) )
|
77 |
+
return;
|
78 |
+
|
79 |
+
$ids = wp_list_pluck( $this->items, 'ID' );
|
80 |
+
$object_terms = wp_get_object_terms( $ids, 'wpsc-variation', array( 'fields' => 'all_with_object_id' ) );
|
81 |
+
|
82 |
+
foreach ( $object_terms as $term ) {
|
83 |
+
if ( ! array_key_exists( $term->object_id, $this->object_terms_cache ) )
|
84 |
+
$this->object_terms_cache[$term->object_id] = array();
|
85 |
+
|
86 |
+
$this->object_terms_cache[$term->object_id][$term->parent] = $term->name;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
public function get_hidden_columns() {
|
91 |
+
return array();
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get a list of all, hidden and sortable columns, with filter applied
|
96 |
+
*
|
97 |
+
* @since 3.1.0
|
98 |
+
* @access protected
|
99 |
+
*
|
100 |
+
* @return array
|
101 |
+
*/
|
102 |
+
public function get_column_info() {
|
103 |
+
if ( isset( $this->_column_headers ) )
|
104 |
+
return $this->_column_headers;
|
105 |
+
|
106 |
+
$screen = get_current_screen();
|
107 |
+
|
108 |
+
$columns = $this->get_columns();
|
109 |
+
$hidden = $this->get_hidden_columns();
|
110 |
+
$_sortable = $this->get_sortable_columns();
|
111 |
+
|
112 |
+
$sortable = array();
|
113 |
+
foreach ( $_sortable as $id => $data ) {
|
114 |
+
if ( empty( $data ) )
|
115 |
+
continue;
|
116 |
+
|
117 |
+
$data = (array) $data;
|
118 |
+
if ( !isset( $data[1] ) )
|
119 |
+
$data[1] = false;
|
120 |
+
|
121 |
+
$sortable[$id] = $data;
|
122 |
+
}
|
123 |
+
|
124 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
125 |
+
|
126 |
+
return $this->_column_headers;
|
127 |
+
}
|
128 |
+
|
129 |
+
public function get_columns() {
|
130 |
+
$columns = array(
|
131 |
+
'cb' => '<input type="checkbox" />',
|
132 |
+
'title' => __( 'Title' , 'wp-e-commerce' ),
|
133 |
+
'sku' => __( 'SKU' , 'wp-e-commerce' ),
|
134 |
+
'price' => __( 'Price' , 'wp-e-commerce' ),
|
135 |
+
'sale_price' => __( 'Sale Price', 'wp-e-commerce' ),
|
136 |
+
'stock' => __( 'Stock' , 'wp-e-commerce' ),
|
137 |
+
);
|
138 |
+
|
139 |
+
if ( get_option( 'wpec_taxes_enabled' ) ) {
|
140 |
+
$columns['tax'] = __( 'Taxable Amount', 'wp-e-commerce' );
|
141 |
+
}
|
142 |
+
|
143 |
+
return apply_filters( 'wpsc_variation_column_headers', $columns );
|
144 |
+
}
|
145 |
+
|
146 |
+
public function get_sortable_columns() {
|
147 |
+
return array();
|
148 |
+
}
|
149 |
+
|
150 |
+
public function column_cb( $item ) {
|
151 |
+
$checked = isset( $_REQUEST['variations'] ) ? checked( in_array( $item->ID, $_REQUEST['variations'] ), true, false ) : '';
|
152 |
+
return sprintf(
|
153 |
+
'<input type="checkbox" %1$s name="%2$s[]" value="%3$s" />',
|
154 |
+
/*$1%s*/ $checked,
|
155 |
+
/*$2%s*/ 'post',
|
156 |
+
/*$3%s*/ $item->ID
|
157 |
+
);
|
158 |
+
}
|
159 |
+
|
160 |
+
private function get_row_actions( $item ) {
|
161 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
162 |
+
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $item->ID );
|
163 |
+
|
164 |
+
$actions = array();
|
165 |
+
|
166 |
+
if ( apply_filters( 'wpsc_show_product_variations_edit_action', true, $item ) && $can_edit_post && 'trash' != $item->post_status ) {
|
167 |
+
$actions['edit'] = '<a target="_blank" href="' . get_edit_post_link( $item->ID, true ) . '" title="' . esc_attr__( 'Edit this item', 'wp-e-commerce' ) . '">' . __( 'Edit', 'wp-e-commerce' ) . '</a>';
|
168 |
+
}
|
169 |
+
|
170 |
+
$actions['stock hide-if-no-js'] = '<a class="wpsc-variation-stock-editor-link" href="#" title="' . __( 'Show shipping editor', 'wp-e-commerce' ) . '">' . __( 'Edit Shipping', 'wp-e-commerce' ) . '</a>';
|
171 |
+
|
172 |
+
if ( $item->post_status == 'draft' ) {
|
173 |
+
$show_url = add_query_arg( array(
|
174 |
+
'bulk_action' => 'show',
|
175 |
+
'post' => $item->ID,
|
176 |
+
'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
|
177 |
+
) );
|
178 |
+
$actions['show'] = '<a class="wpsc-variation-show-link" href="' . esc_url( $show_url ) . '" title="' . __( 'Show this variation on the front-end', 'wp-e-commerce' ) . '">' . __( 'Publish', 'wp-e-commerce' ) . '</a>';
|
179 |
+
} elseif ( in_array( $item->post_status, array( 'publish', 'inherit' ) ) ) {
|
180 |
+
$hide_url = add_query_arg( array(
|
181 |
+
'bulk_action' => 'hide',
|
182 |
+
'post' => $item->ID,
|
183 |
+
'bulk_action_nonce' => wp_create_nonce( 'wpsc_product_variations_bulk_action' ),
|
184 |
+
) );
|
185 |
+
$actions['hide'] = '<a class="wpsc-variation-hide-link" href="' . esc_url( $hide_url ) . '" title="' . __( 'Mark this variation as draft to hide it from the front-end.', 'wp-e-commerce' ) . '">' . __( 'Mark as Draft', 'wp-e-commerce' ) . '</a>';
|
186 |
+
}
|
187 |
+
|
188 |
+
if ( current_user_can( $post_type_object->cap->delete_post, $item->ID ) ) {
|
189 |
+
$force_delete = 'trash' == $item->post_status || ! EMPTY_TRASH_DAYS;
|
190 |
+
$redirect_url = urlencode( _wpsc_get_product_variation_form_url( $this->product_id ) );
|
191 |
+
$delete_link = add_query_arg( '_wp_http_referer', $redirect_url, get_delete_post_link( $item->ID, '', $force_delete ) );
|
192 |
+
|
193 |
+
if ( 'trash' == $item->post_status ) {
|
194 |
+
$restore_url = admin_url( sprintf( $post_type_object->_edit_link, $item->ID ) );
|
195 |
+
$restore_url = add_query_arg(
|
196 |
+
array(
|
197 |
+
'action' => 'untrash',
|
198 |
+
'_wp_http_referer' => $redirect_url,
|
199 |
+
),
|
200 |
+
$restore_url
|
201 |
+
);
|
202 |
+
$restore_url = wp_nonce_url( $restore_url, 'untrash-post_' . $item->ID );
|
203 |
+
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'wp-e-commerce' ) . "' href='" . esc_url( $restore_url ) . "'>" . __( 'Restore', 'wp-e-commerce' ) . "</a>";
|
204 |
+
} elseif ( EMPTY_TRASH_DAYS ) {
|
205 |
+
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'wp-e-commerce' ) . "' href='" . esc_url( $delete_link ) . "'>" . __( 'Trash', 'wp-e-commerce' ) . "</a>";
|
206 |
+
}
|
207 |
+
|
208 |
+
if ( $force_delete )
|
209 |
+
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'wp-e-commerce' ) . "' href='" . esc_url( $delete_link ) . "'>" . __( 'Delete Permanently', 'wp-e-commerce' ) . "</a>";
|
210 |
+
}
|
211 |
+
|
212 |
+
return $actions;
|
213 |
+
}
|
214 |
+
|
215 |
+
public function column_title( $item ) {
|
216 |
+
$title = implode( ', ', $this->object_terms_cache[$item->ID] );
|
217 |
+
$thumbnail = wpsc_the_product_thumbnail( false, false, $item->ID, 'manage-products' );
|
218 |
+
$show_edit_link = apply_filters( 'wpsc_show_product_variations_edit_action', true, $item );
|
219 |
+
|
220 |
+
$nonce = wp_create_nonce( "wpsc_ajax_get_variation_gallery_{$item->ID}" );
|
221 |
+
$save_gallery_nonce = wp_create_nonce( "wpsc_ajax_update_gallery_{$item->ID}" );
|
222 |
+
$get_gallery_nonce = wp_create_nonce( "wpsc_ajax_get_gallery_{$item->ID}" );
|
223 |
+
|
224 |
+
if ( ! $thumbnail )
|
225 |
+
$thumbnail = WPSC_CORE_IMAGES_URL . '/no-image-uploaded.gif';
|
226 |
+
?>
|
227 |
+
<div class="wpsc-product-variation-thumbnail">
|
228 |
+
<a
|
229 |
+
target="_blank"
|
230 |
+
data-featured-nonce="<?php echo esc_attr( wp_create_nonce( "update-post_{$item->ID}" ) ); ?>"
|
231 |
+
data-nonce="<?php echo esc_attr( $nonce ); ?>"
|
232 |
+
data-save-gallery-nonce="<?php echo esc_attr( $save_gallery_nonce ); ?>"
|
233 |
+
data-get-gallery-nonce="<?php echo esc_attr( $get_gallery_nonce ); ?>"
|
234 |
+
data-image-id="<?php echo get_post_thumbnail_id( $item->ID ); ?>"
|
235 |
+
data-id="<?php echo $item->ID; ?>"
|
236 |
+
data-title="<?php echo esc_attr( $title ); ?>"
|
237 |
+
href="<?php echo esc_url( admin_url( 'media-upload.php?post_id=' . $item->ID . '&width=640&height=566&product_variation=1' ) ) ?>"
|
238 |
+
>
|
239 |
+
<img id="wpsc-variation-thumbnail-<?php echo $item->ID; ?>" src="<?php echo esc_url( $thumbnail ); ?>" alt="" />
|
240 |
+
</a>
|
241 |
+
</div>
|
242 |
+
<div class="wpsc-product-variation-title">
|
243 |
+
<strong class="row-title">
|
244 |
+
<?php if ( $show_edit_link ): ?>
|
245 |
+
<a target="_blank" href="<?php echo esc_url( get_edit_post_link( $item->ID, true ) ); ?>" title="<?php esc_attr_e( 'Edit this item', 'wp-e-commerce' ); ?>">
|
246 |
+
<?php endif; ?>
|
247 |
+
<?php echo esc_html( apply_filters( 'wpsc_variation_name', $title, $item ) ); ?>
|
248 |
+
<?php if ( $show_edit_link ): ?>
|
249 |
+
</a>
|
250 |
+
<?php endif; ?>
|
251 |
+
</strong>
|
252 |
+
<?php echo $this->row_actions( $this->get_row_actions( $item ) ); ?>
|
253 |
+
</div>
|
254 |
+
<?php
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Stock Column
|
259 |
+
*
|
260 |
+
* @uses get_product_meta Get product meta data.
|
261 |
+
*
|
262 |
+
* @param object $item Product
|
263 |
+
*/
|
264 |
+
public function column_stock( $item ) {
|
265 |
+
$stock = get_product_meta( $item->ID, 'stock', true );
|
266 |
+
if ( is_numeric( $stock ) )
|
267 |
+
$stock = absint( $stock );
|
268 |
+
?>
|
269 |
+
<input type="text" name="wpsc_variations[<?php echo $item->ID; ?>][stock]" value="<?php echo esc_attr( $stock ); ?>" />
|
270 |
+
<?php
|
271 |
+
}
|
272 |
+
|
273 |
+
public function column_price( $item ) {
|
274 |
+
$price = get_product_meta( $item->ID, 'price', true );
|
275 |
+
$price = wpsc_format_number( $price );
|
276 |
+
?>
|
277 |
+
<input type="text" name="wpsc_variations[<?php echo $item->ID; ?>][price]" value="<?php echo esc_attr( $price ); ?>" />
|
278 |
+
<?php
|
279 |
+
}
|
280 |
+
|
281 |
+
public function column_sale_price( $item ) {
|
282 |
+
$sale_price = get_product_meta( $item->ID, 'special_price', true );
|
283 |
+
if ( is_numeric( $sale_price ) )
|
284 |
+
$sale_price = wpsc_format_number( $sale_price );
|
285 |
+
?>
|
286 |
+
<input type="text" name="wpsc_variations[<?php echo $item->ID; ?>][sale_price]" value="<?php echo esc_attr( $sale_price ); ?>">
|
287 |
+
<?php
|
288 |
+
}
|
289 |
+
|
290 |
+
public function column_sku( $item ) {
|
291 |
+
$sku = get_product_meta( $item->ID, 'sku', true );
|
292 |
+
?>
|
293 |
+
<input type="text" name="wpsc_variations[<?php echo $item->ID; ?>][sku]" value="<?php echo esc_attr( $sku ); ?>" />
|
294 |
+
<?php
|
295 |
+
}
|
296 |
+
|
297 |
+
public function column_tax( $item ) {
|
298 |
+
$meta = get_post_meta( $item->ID, '_wpsc_product_metadata', true );
|
299 |
+
if ( ! $meta || ! isset( $meta['wpec_taxes_taxable_amount'] ) )
|
300 |
+
$tax = '';
|
301 |
+
else
|
302 |
+
$tax = wpsc_format_number( $meta['wpec_taxes_taxable_amount'] );
|
303 |
+
?>
|
304 |
+
<input type="text" name="wpsc_variations[<?php echo $item->ID; ?>][product_metadata][wpec_taxes_taxable_amount]" value="<?php echo esc_attr( $tax ); ?>" />
|
305 |
+
<?php
|
306 |
+
}
|
307 |
+
|
308 |
+
public function column_default( $item, $column_name ) {
|
309 |
+
$output = apply_filters( 'wpsc_manage_product_variations_custom_column', '', $column_name, $item );
|
310 |
+
return $output;
|
311 |
+
}
|
312 |
+
|
313 |
+
private function shipping_editor( $item = false ) {
|
314 |
+
static $alternate = '';
|
315 |
+
|
316 |
+
if ( ! $item )
|
317 |
+
$alternate = '';
|
318 |
+
else
|
319 |
+
$alternate = ( $alternate == '' ) ? ' alternate' : '';
|
320 |
+
|
321 |
+
$row_class = $alternate;
|
322 |
+
|
323 |
+
$style = '';
|
324 |
+
$bulk = false;
|
325 |
+
if ( ! $item ) {
|
326 |
+
$item = get_post( $this->product_id );
|
327 |
+
$field_name = "wpsc_bulk_edit[product_metadata]";
|
328 |
+
$row_class .= " wpsc_bulk_edit_shipping";
|
329 |
+
if ( $this->is_bulk_edit )
|
330 |
+
$style = ' style="display:table-row;"';
|
331 |
+
else
|
332 |
+
$style = ' style="display:none;"';
|
333 |
+
$bulk = true;
|
334 |
+
} else {
|
335 |
+
$field_name = "wpsc_variations[{$item->ID}][product_metadata]";
|
336 |
+
}
|
337 |
+
$colspan = count( $this->get_columns() ) - 1;
|
338 |
+
?>
|
339 |
+
<tr class="wpsc-stock-editor-row inline-edit-row<?php echo $row_class; ?>"<?php echo $style; ?> id="wpsc-stock-editor-row-<?php echo $item->ID; ?>">
|
340 |
+
<td></td>
|
341 |
+
<td colspan="<?php echo $colspan; ?>" class="colspanchange">
|
342 |
+
<h4><?php esc_html_e( 'Variation Shipping Editor', 'wp-e-commerce' ); ?></h4>
|
343 |
+
<?php wpsc_product_shipping_forms( $item, $field_name, $bulk ); ?>
|
344 |
+
</td>
|
345 |
+
</tr>
|
346 |
+
<?php
|
347 |
+
}
|
348 |
+
|
349 |
+
public function single_row( $item ) {
|
350 |
+
static $count = 0;
|
351 |
+
$count ++;
|
352 |
+
$item->index = $count;
|
353 |
+
parent::single_row( $item );
|
354 |
+
$this->shipping_editor( $item );
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Generate the table navigation above or below the table
|
359 |
+
*
|
360 |
+
* @since 3.1.0
|
361 |
+
* @access protected
|
362 |
+
*/
|
363 |
+
public function display_tablenav( $which ) {
|
364 |
+
?>
|
365 |
+
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
366 |
+
<div class="alignleft actions">
|
367 |
+
<?php $this->bulk_actions( $which ); ?>
|
368 |
+
</div>
|
369 |
+
<?php
|
370 |
+
$this->extra_tablenav( $which );
|
371 |
+
$this->pagination( $which );
|
372 |
+
?>
|
373 |
+
<br class="clear" />
|
374 |
+
</div>
|
375 |
+
<?php
|
376 |
+
}
|
377 |
+
|
378 |
+
public function display_rows() {
|
379 |
+
$this->display_bulk_edit_row();
|
380 |
+
if ( ! $this->is_bulk_edit )
|
381 |
+
parent::display_rows();
|
382 |
+
}
|
383 |
+
|
384 |
+
public function display_messages() {
|
385 |
+
if ( isset($_REQUEST['locked']) || isset($_REQUEST['skipped']) || isset($_REQUEST['updated']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) )
|
386 |
+
$messages = array();
|
387 |
+
else
|
388 |
+
return;
|
389 |
+
|
390 |
+
if ( isset($_REQUEST['updated']) && (int) $_REQUEST['updated'] ) {
|
391 |
+
$messages[] = sprintf( _n( '%s post updated.', '%s posts updated.', $_REQUEST['updated'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['updated'] ) );
|
392 |
+
unset($_REQUEST['updated']);
|
393 |
+
}
|
394 |
+
|
395 |
+
if ( isset($_REQUEST['skipped']) && (int) $_REQUEST['skipped'] )
|
396 |
+
unset($_REQUEST['skipped']);
|
397 |
+
|
398 |
+
if ( isset($_REQUEST['locked']) && (int) $_REQUEST['locked'] ) {
|
399 |
+
$messages[] = sprintf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_REQUEST['locked'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['locked'] ) );
|
400 |
+
unset($_REQUEST['locked']);
|
401 |
+
}
|
402 |
+
|
403 |
+
if ( isset($_REQUEST['deleted']) && (int) $_REQUEST['deleted'] ) {
|
404 |
+
$messages[] = sprintf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_REQUEST['deleted'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['deleted'] ) );
|
405 |
+
unset($_REQUEST['deleted']);
|
406 |
+
}
|
407 |
+
|
408 |
+
if ( isset($_REQUEST['trashed']) && (int) $_REQUEST['trashed'] ) {
|
409 |
+
$messages[] = sprintf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $_REQUEST['trashed'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['trashed'] ) );
|
410 |
+
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
|
411 |
+
$undo_url = wp_nonce_url( add_query_arg( array( 'doaction' => 'undo', 'action' => 'untrash', 'ids' => $ids ) ), 'bulk-posts' );
|
412 |
+
$messages[] = '<a href="' . esc_url( $undo_url ) . '">' . __( 'Undo', 'wp-e-commerce' ) . '</a>';
|
413 |
+
unset($_REQUEST['trashed']);
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( isset($_REQUEST['untrashed']) && (int) $_REQUEST['untrashed'] ) {
|
417 |
+
$messages[] = sprintf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_REQUEST['untrashed'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['untrashed'] ) );
|
418 |
+
unset($_REQUEST['undeleted']);
|
419 |
+
}
|
420 |
+
?>
|
421 |
+
<div id="message" class="updated"><p>
|
422 |
+
<?php
|
423 |
+
echo join( ' ', $messages ); unset( $messages );
|
424 |
+
$_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ) );
|
425 |
+
echo '</p></div>';
|
426 |
+
}
|
427 |
+
|
428 |
+
public function get_bulk_actions() {
|
429 |
+
$actions = array();
|
430 |
+
|
431 |
+
if ( $this->is_trash )
|
432 |
+
$actions['untrash'] = __( 'Restore', 'wp-e-commerce' );
|
433 |
+
|
434 |
+
if ( $this->is_draft )
|
435 |
+
$actions['show'] = __( 'Publish', 'wp-e-commerce' );
|
436 |
+
elseif ( $this->is_all || $this->is_publish )
|
437 |
+
$actions['hide'] = __( 'Mark as Draft', 'wp-e-commerce' );
|
438 |
+
|
439 |
+
$actions['edit'] = __( 'Edit', 'wp-e-commerce' );
|
440 |
+
|
441 |
+
if ( $this->is_trash || !EMPTY_TRASH_DAYS )
|
442 |
+
$actions['delete'] = __( 'Delete Permanently', 'wp-e-commerce' );
|
443 |
+
else
|
444 |
+
$actions['trash'] = __( 'Move to Trash', 'wp-e-commerce' );
|
445 |
+
|
446 |
+
return $actions;
|
447 |
+
}
|
448 |
+
|
449 |
+
public function bulk_actions( $which = '' ) {
|
450 |
+
$screen = get_current_screen();
|
451 |
+
|
452 |
+
if ( is_null( $this->_actions ) ) {
|
453 |
+
$no_new_actions = $this->_actions = $this->get_bulk_actions();
|
454 |
+
// This filter can currently only be used to remove actions.
|
455 |
+
$this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
|
456 |
+
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
|
457 |
+
$two = '';
|
458 |
+
} else {
|
459 |
+
$two = '2';
|
460 |
+
}
|
461 |
+
|
462 |
+
if ( empty( $this->_actions ) )
|
463 |
+
return;
|
464 |
+
|
465 |
+
echo '<input type="hidden" name="bulk_action_nonce" value="' . wp_create_nonce( 'wpsc_product_variations_bulk_action' ) .'" />';
|
466 |
+
echo "<select name='bulk_action$two'>\n";
|
467 |
+
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions', 'wp-e-commerce' ) . "</option>\n";
|
468 |
+
|
469 |
+
foreach ( $this->_actions as $name => $title ) {
|
470 |
+
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
471 |
+
|
472 |
+
echo "\t<option value='$name'$class>$title</option>\n";
|
473 |
+
}
|
474 |
+
|
475 |
+
echo "</select>\n";
|
476 |
+
|
477 |
+
submit_button( __( 'Apply', 'wp-e-commerce' ), 'action', false, false, array( 'id' => "doaction$two" ) );
|
478 |
+
echo "\n";
|
479 |
+
}
|
480 |
+
|
481 |
+
public function current_action() {
|
482 |
+
if ( isset( $_REQUEST['bulk_action'] ) && -1 != $_REQUEST['bulk_action'] )
|
483 |
+
return $_REQUEST['bulk_action'];
|
484 |
+
|
485 |
+
if ( isset( $_REQUEST['bulk_action2'] ) && -1 != $_REQUEST['bulk_action2'] )
|
486 |
+
return $_REQUEST['bulk_action2'];
|
487 |
+
|
488 |
+
return false;
|
489 |
+
}
|
490 |
+
|
491 |
+
private function count_variations() {
|
492 |
+
global $wpdb;
|
493 |
+
$query = $wpdb->prepare( "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = 'wpsc-product' AND post_parent = %d GROUP BY post_status", $this->product_id );
|
494 |
+
$results = $wpdb->get_results( $query );
|
495 |
+
|
496 |
+
$return = array();
|
497 |
+
foreach ( get_post_stati() as $state )
|
498 |
+
$stats[$state] = 0;
|
499 |
+
|
500 |
+
foreach ( $results as $row ) {
|
501 |
+
$return[$row->post_status] = $row->num_posts;
|
502 |
+
}
|
503 |
+
|
504 |
+
return (object) $return;
|
505 |
+
}
|
506 |
+
|
507 |
+
public function get_views() {
|
508 |
+
global $locked_post_status;
|
509 |
+
$parent = get_post( $this->product_id );
|
510 |
+
$avail_post_stati = get_available_post_statuses( 'wpsc-product' );
|
511 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
512 |
+
$post_type = $post_type_object->name;
|
513 |
+
$url_base = add_query_arg( array(
|
514 |
+
'action' => 'wpsc_product_variations_table',
|
515 |
+
'product_id' => $_REQUEST['product_id'],
|
516 |
+
'_wpnonce' => wp_create_nonce( 'wpsc_product_variations_table' ),
|
517 |
+
), admin_url( 'admin-ajax.php' ) );
|
518 |
+
|
519 |
+
if ( !empty($locked_post_status) )
|
520 |
+
return array();
|
521 |
+
|
522 |
+
$status_links = array();
|
523 |
+
$num_posts = $this->count_variations();
|
524 |
+
$class = '';
|
525 |
+
|
526 |
+
$current_user_id = get_current_user_id();
|
527 |
+
|
528 |
+
if ( isset( $num_posts->inherit ) ) {
|
529 |
+
$key = $parent->post_status;
|
530 |
+
if ( ! isset( $num_posts->$key ) )
|
531 |
+
$num_posts->$key = 0;
|
532 |
+
|
533 |
+
$num_posts->$key += $num_posts->inherit;
|
534 |
+
unset( $num_posts->inherit );
|
535 |
+
}
|
536 |
+
|
537 |
+
$total_posts = array_sum( (array) $num_posts );
|
538 |
+
|
539 |
+
// Subtract post types that are not included in the admin all list.
|
540 |
+
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) {
|
541 |
+
if ( isset( $num_posts->$state ) )
|
542 |
+
$total_posts -= $num_posts->$state;
|
543 |
+
}
|
544 |
+
|
545 |
+
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
|
546 |
+
$status_links['all'] = "<a href='{$url_base}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'wp-e-commerce' ), number_format_i18n( $total_posts ) ) . '</a>';
|
547 |
+
|
548 |
+
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
|
549 |
+
$class = '';
|
550 |
+
|
551 |
+
$status_name = $status->name;
|
552 |
+
|
553 |
+
if ( $status_name == 'publish' )
|
554 |
+
continue;
|
555 |
+
|
556 |
+
if ( !in_array( $status_name, $avail_post_stati ) )
|
557 |
+
continue;
|
558 |
+
|
559 |
+
if ( empty( $num_posts->$status_name ) ) {
|
560 |
+
if ( isset( $_REQUEST['post_status'] ) && $status_name == $_REQUEST['post_status'] )
|
561 |
+
$num_posts->$_REQUEST['post_status'] = 0;
|
562 |
+
else
|
563 |
+
continue;
|
564 |
+
}
|
565 |
+
|
566 |
+
if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
|
567 |
+
$class = ' class="current"';
|
568 |
+
|
569 |
+
$status_links[$status_name] = "<a href='" . esc_url( add_query_arg( 'post_status', $status_name, $url_base ) ) ."'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
|
570 |
+
}
|
571 |
+
|
572 |
+
return $status_links;
|
573 |
+
}
|
574 |
+
|
575 |
+
public function set_bulk_edited_items( $item_ids ) {
|
576 |
+
$this->prepare_items();
|
577 |
+
$this->is_bulk_edit = true;
|
578 |
+
foreach ( $this->items as $key => $item ) {
|
579 |
+
if ( in_array( $item->ID, $item_ids ) ) {
|
580 |
+
$this->bulk_edited_items[] = $item;
|
581 |
+
unset( $this->items[$key] );
|
582 |
+
}
|
583 |
+
}
|
584 |
+
$this->bulk_edited_item_ids = $item_ids;
|
585 |
+
}
|
586 |
+
|
587 |
+
private function display_bulk_edit_row() {
|
588 |
+
$style = $this->is_bulk_edit ? '' : ' style="display:none";';
|
589 |
+
$classes = 'wpsc-bulk-edit';
|
590 |
+
if ( $this->is_bulk_edit )
|
591 |
+
$classes .= ' active';
|
592 |
+
echo "<tr{$style} class='{$classes}'>";
|
593 |
+
list( $columns, $hidden ) = $this->get_column_info();
|
594 |
+
foreach ( $columns as $column_name => $column_display_name ) {
|
595 |
+
$class = "class='$column_name column-$column_name inline-edit-row'";
|
596 |
+
$style = '';
|
597 |
+
|
598 |
+
if ( in_array( $column_name, $hidden ) )
|
599 |
+
$style = ' style="display:none;"';
|
600 |
+
|
601 |
+
$attributes = "$class$style";
|
602 |
+
|
603 |
+
if ( $column_name == 'cb' )
|
604 |
+
echo '<td></td>';
|
605 |
+
elseif ( method_exists( $this, 'bulk_edit_column_' . $column_name ) ) {
|
606 |
+
echo "<td $attributes>";
|
607 |
+
echo call_user_func( array( &$this, 'bulk_edit_column_' . $column_name ) );
|
608 |
+
echo "</td>";
|
609 |
+
}
|
610 |
+
}
|
611 |
+
echo '</tr>';
|
612 |
+
$this->shipping_editor();
|
613 |
+
}
|
614 |
+
|
615 |
+
public function bulk_edit_column_title() {
|
616 |
+
?>
|
617 |
+
<div class="wpsc-bulk-edit-items">
|
618 |
+
<?php foreach ( $this->bulk_edited_items as $item ):
|
619 |
+
$title = implode( ', ', $this->object_terms_cache[$item->ID] );
|
620 |
+
?>
|
621 |
+
<div class="wpsc-bulk-edit-item">
|
622 |
+
<span>
|
623 |
+
<input type="checkbox" name="wpsc_bulk_edit[post][]" checked="checked" value="<?php echo $item->ID; ?>" />
|
624 |
+
</span>
|
625 |
+
<strong>
|
626 |
+
<a class="row-title" href="<?php echo get_edit_post_link( $item->ID ); ?>" title="<?php esc_attr_e( 'Edit this variation', 'wp-e-commerce' ) ?>"><?php echo esc_html( $title ); ?></a>
|
627 |
+
</strong>
|
628 |
+
</div>
|
629 |
+
<?php endforeach; ?>
|
630 |
+
</div>
|
631 |
+
<?php
|
632 |
+
}
|
633 |
+
|
634 |
+
public function bulk_edit_column_stock() {
|
635 |
+
?>
|
636 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][stock]" value="1" />
|
637 |
+
<input tabindex="101" type="text" name="wpsc_bulk_edit[stock]" value="" />
|
638 |
+
<?php
|
639 |
+
}
|
640 |
+
|
641 |
+
public function bulk_edit_column_price() {
|
642 |
+
?>
|
643 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][price]" value="1" />
|
644 |
+
<input tabindex="103" type="text" name="wpsc_bulk_edit[price]" value="" />
|
645 |
+
<?php
|
646 |
+
}
|
647 |
+
|
648 |
+
public function bulk_edit_column_tax() {
|
649 |
+
?>
|
650 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][wpec_taxes_taxable_amount]" value="1" />
|
651 |
+
<input tabindex="102" type="text" name="wpsc_bulk_edit[product_metadata][wpec_taxes_taxable_amount]" value="" />
|
652 |
+
<?php
|
653 |
+
}
|
654 |
+
|
655 |
+
public function bulk_edit_column_sku() {
|
656 |
+
?>
|
657 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][sku]" value="1" />
|
658 |
+
<input tabindex="105" type="text" name="wpsc_bulk_edit[sku]" value="" />
|
659 |
+
<?php
|
660 |
+
}
|
661 |
+
|
662 |
+
public function bulk_edit_column_sale_price() {
|
663 |
+
$sale_price = get_product_meta( $this->product_id, 'special_price', true );
|
664 |
+
?>
|
665 |
+
<input class="wpsc-bulk-edit-fields" type="checkbox" name="wpsc_bulk_edit[fields][sale_price]" value="1" />
|
666 |
+
<input tabindex="104" type="text" name="wpsc_bulk_edit[sale_price]" value="">
|
667 |
+
<?php
|
668 |
+
}
|
669 |
+
|
670 |
+
public function extra_tablenav( $which ) {
|
671 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
672 |
+
?><div class="alignleft actions"><?php
|
673 |
+
if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
|
674 |
+
submit_button( __( 'Empty Trash', 'wp-e-commerce' ), 'button-secondary apply', 'delete_all', false );
|
675 |
+
}
|
676 |
+
?></div><?php
|
677 |
+
}
|
678 |
+
}
|
trunk/wpsc-admin/includes/product-variations-manage.page.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $this->list_table->display_messages(); ?>
|
2 |
+
<form action="" method="post">
|
3 |
+
<?php $this->list_table->views(); ?>
|
4 |
+
<div class="alignright actions wpsc-save-product-variations top">
|
5 |
+
<?php submit_button( __( 'Save Variations', 'wp-e-commerce' ) ); ?>
|
6 |
+
</div>
|
7 |
+
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
|
8 |
+
<?php wp_nonce_field( 'wpsc_save_variations_meta', '_wpsc_save_meta_nonce' ); ?>
|
9 |
+
<?php $this->list_table->display(); ?>
|
10 |
+
<div class="alignright actions wpsc-save-product-variations bottom">
|
11 |
+
<?php submit_button( __( 'Save Variations', 'wp-e-commerce' ) ); ?>
|
12 |
+
</div>
|
13 |
+
</form>
|
trunk/wpsc-admin/includes/product-variations-page.class.php
ADDED
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Product Variations page class in the WordPress admin
|
5 |
+
*
|
6 |
+
* @package wp-e-commerce
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WPSC_Product_Variations_Page {
|
10 |
+
private $list_table;
|
11 |
+
private $parent_id;
|
12 |
+
private $current_tab;
|
13 |
+
private $post;
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/product-variation-list-table.class.php' );
|
17 |
+
$GLOBALS['hook_suffix'] = 'wpsc-product-variations-iframe';
|
18 |
+
$this->parent_id = absint( $_REQUEST['product_id'] );
|
19 |
+
set_current_screen();
|
20 |
+
|
21 |
+
if ( ! empty( $_REQUEST['tab'] ) ) {
|
22 |
+
$this->current_tab = $_REQUEST['tab'];
|
23 |
+
} else {
|
24 |
+
$args = array(
|
25 |
+
'post_parent' => $this->parent_id,
|
26 |
+
'post_type' => 'wpsc-product',
|
27 |
+
'post_status' => 'any');
|
28 |
+
|
29 |
+
$number_of_variations = count(get_children($args));
|
30 |
+
|
31 |
+
$this->current_tab = ($number_of_variations > 0) ? 'manage' : 'setup';
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
private function merge_meta_deep( $original, $updated ) {
|
36 |
+
$keys = array_merge( array_keys( $original ), array_keys( $updated ) );
|
37 |
+
|
38 |
+
foreach ( $keys as $key ) {
|
39 |
+
if ( ! isset( $updated[$key] ) )
|
40 |
+
continue;
|
41 |
+
|
42 |
+
if ( isset( $original[$key] ) && is_array( $original[$key] ) ) {
|
43 |
+
$original[$key] = $this->merge_meta_deep( $original[$key] , $updated[$key] );
|
44 |
+
} else {
|
45 |
+
$original[$key] = $updated[$key];
|
46 |
+
if ( in_array( $key, array( 'weight', 'wpec_taxes_taxable_amount', 'height', 'width', 'length' ) ) )
|
47 |
+
$original[$key] = (float) $original[$key];
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
return $original;
|
53 |
+
}
|
54 |
+
|
55 |
+
/* */
|
56 |
+
private function save_variation_meta( $id, $data ) {
|
57 |
+
|
58 |
+
$product_meta = get_product_meta( $id, 'product_metadata', true );
|
59 |
+
|
60 |
+
if ( ! is_array( $product_meta ) ) {
|
61 |
+
$product_meta = array();
|
62 |
+
}
|
63 |
+
|
64 |
+
$product_meta = $this->merge_meta_deep( $product_meta, $data['product_metadata'] );
|
65 |
+
|
66 |
+
// convert to pound to maintain backward compat with shipping modules
|
67 |
+
if ( isset( $data['product_metadata']['weight'] ) || isset( $data['product_metadata']['weight_unit'] ) ) {
|
68 |
+
$product_meta['weight'] = wpsc_convert_weight( $product_meta['weight'], $product_meta['weight_unit'], 'pound', true );
|
69 |
+
}
|
70 |
+
|
71 |
+
update_product_meta( $id, 'product_metadata', $product_meta );
|
72 |
+
|
73 |
+
if ( isset( $data['price'] ) ) {
|
74 |
+
update_product_meta( $id, 'price', wpsc_string_to_float( $data['price'] ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( isset( $data['sale_price'] ) ) {
|
78 |
+
|
79 |
+
$sale_price = wpsc_string_to_float( $data['sale_price'] );
|
80 |
+
|
81 |
+
if ( is_numeric( $sale_price ) ) {
|
82 |
+
update_product_meta( $id, 'special_price', wpsc_string_to_float( $data['sale_price'] ) );
|
83 |
+
} else {
|
84 |
+
update_product_meta( $id, 'special_price', '' );
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
if ( isset( $data['sku'] ) ) {
|
89 |
+
update_product_meta( $id, 'sku', sanitize_text_field( $data['sku'] ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( isset( $data['stock'] ) ) {
|
93 |
+
if ( is_numeric( $data['stock'] ) ) {
|
94 |
+
update_product_meta( $id, 'stock', (int) $data['stock'] );
|
95 |
+
$parent_id = wpsc_product_is_variation( $id );
|
96 |
+
|
97 |
+
if( $parent_id ) {
|
98 |
+
// If product is a variatio get the notification threshold from parent product
|
99 |
+
$parent_meta = get_product_meta( $parent_id, 'product_metadata', true );
|
100 |
+
$notify_limit = $parent_meta['stock_limit_notify'];
|
101 |
+
if ( (int) $data['stock'] > $notify_limit ) {
|
102 |
+
// Check if notification has been sent
|
103 |
+
$notify_sent = get_product_meta( $id, 'stock_limit_notify_sent', true );
|
104 |
+
if( ! empty( $notify_sent ) ) {
|
105 |
+
delete_product_meta( $id, 'stock_limit_notify_sent' );
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
} else {
|
110 |
+
update_product_meta( $id, 'stock', '' );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
private function save_variations_meta(){
|
116 |
+
if ( empty( $_REQUEST['wpsc_variations'] ) )
|
117 |
+
return;
|
118 |
+
|
119 |
+
check_admin_referer( 'wpsc_save_variations_meta', '_wpsc_save_meta_nonce' );
|
120 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
121 |
+
if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
|
122 |
+
wp_die( __( 'Cheatin’ uh?', 'wp-e-commerce' ) );
|
123 |
+
|
124 |
+
/* Long-term, we should have a better saving routine here. Can't unset these currently. *
|
125 |
+
/* That said, the only thing that fails hard if we can't unset it is the checkbox. */
|
126 |
+
foreach ( $_REQUEST['wpsc_variations'] as $id => $data ) {
|
127 |
+
if ( ! isset( $data['product_metadata']['no_shipping'] ) ) {
|
128 |
+
$data['product_metadata']['no_shipping'] = '';
|
129 |
+
}
|
130 |
+
$this->save_variation_meta( $id, $data );
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
public function display() {
|
135 |
+
global $title, $hook_suffix, $wp_locale, $pagenow, $wp_version, $is_iphone,
|
136 |
+
$current_site, $update_title, $total_update_count, $parent_file;
|
137 |
+
|
138 |
+
$current_screen = get_current_screen();
|
139 |
+
$admin_body_class = $hook_suffix;
|
140 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
141 |
+
|
142 |
+
wp_enqueue_style( 'global' );
|
143 |
+
wp_enqueue_style( 'wp-admin' );
|
144 |
+
wp_enqueue_style( 'buttons' );
|
145 |
+
wp_enqueue_style( 'colors' );
|
146 |
+
wp_enqueue_style( 'ie' );
|
147 |
+
wp_enqueue_script( 'common' );
|
148 |
+
wp_enqueue_script( 'jquery-color' );
|
149 |
+
wp_enqueue_script( 'utils' );
|
150 |
+
wp_enqueue_script( 'jquery-query' );
|
151 |
+
wp_enqueue_media( array( 'post' => absint( $_REQUEST['product_id'] ) ) );
|
152 |
+
|
153 |
+
|
154 |
+
$callback = "callback_tab_{$this->current_tab}";
|
155 |
+
if ( ! is_callable( array( $this, "callback_tab_{$this->current_tab}" ) ) )
|
156 |
+
$callback = "callback_tab_manage";
|
157 |
+
|
158 |
+
$this->$callback();
|
159 |
+
|
160 |
+
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
161 |
+
require_once( WPSC_FILE_PATH . "/wpsc-admin/includes/product-variations.page.php" );
|
162 |
+
}
|
163 |
+
|
164 |
+
private function display_tabs() {
|
165 |
+
$tabs = array(
|
166 |
+
'manage' => _x( 'Manage', 'manage product variations', 'wp-e-commerce' ),
|
167 |
+
'setup' => __( 'Setup', 'wp-e-commerce' ),
|
168 |
+
);
|
169 |
+
|
170 |
+
echo '<ul id="wpsc-product-variations-tabs" class="category-tabs">';
|
171 |
+
foreach ( $tabs as $tab => $title ) {
|
172 |
+
$class = ( $tab == $this->current_tab ) ? ' class="tabs"' : '';
|
173 |
+
$item = '<li' . $class . '>';
|
174 |
+
$item .= '<a href="' . esc_url( add_query_arg( 'tab', $tab ) ) . '">' . esc_html( $title ) . '</a></li> ';
|
175 |
+
echo $item;
|
176 |
+
}
|
177 |
+
echo '</ul>';
|
178 |
+
}
|
179 |
+
|
180 |
+
private function callback_tab_manage() {
|
181 |
+
$this->list_table = new WPSC_Product_Variation_List_Table( $this->parent_id );
|
182 |
+
$this->save_variations_meta();
|
183 |
+
$this->process_bulk_action();
|
184 |
+
$this->list_table->prepare_items();
|
185 |
+
}
|
186 |
+
|
187 |
+
private function callback_tab_setup() {
|
188 |
+
global $post;
|
189 |
+
require_once( 'walker-variation-checklist.php' );
|
190 |
+
|
191 |
+
$this->generate_variations();
|
192 |
+
}
|
193 |
+
|
194 |
+
private function generate_variations() {
|
195 |
+
if ( ! isset( $_REQUEST['action2'] ) || $_REQUEST['action2'] != 'generate' )
|
196 |
+
return;
|
197 |
+
|
198 |
+
check_admin_referer( 'wpsc_generate_product_variations', '_wpsc_generate_product_variations_nonce' );
|
199 |
+
|
200 |
+
wpsc_update_variations();
|
201 |
+
|
202 |
+
$sendback = remove_query_arg( array(
|
203 |
+
'_wp_http_referer',
|
204 |
+
'updated',
|
205 |
+
) );
|
206 |
+
wp_redirect( esc_url_raw( add_query_arg( 'tab', 'manage', $sendback ) ) );
|
207 |
+
exit;
|
208 |
+
}
|
209 |
+
|
210 |
+
public function display_current_tab() {
|
211 |
+
require_once( WPSC_FILE_PATH . "/wpsc-admin/includes/product-variations-{$this->current_tab}.page.php" );
|
212 |
+
}
|
213 |
+
|
214 |
+
public function process_bulk_action_delete_all( $post_ids ) {
|
215 |
+
$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
|
216 |
+
if ( get_post_status_object( $post_status ) ) // Check the post status exists first
|
217 |
+
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='wpsc-product' AND post_status = %s", $post_type, $post_status ) );
|
218 |
+
|
219 |
+
return $this->process_bulk_action_delete( $post_ids );
|
220 |
+
}
|
221 |
+
|
222 |
+
public function process_bulk_action_trash( $post_ids ) {
|
223 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
224 |
+
$trashed = 0;
|
225 |
+
foreach( (array) $post_ids as $post_id ) {
|
226 |
+
if ( !current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
227 |
+
wp_die( __( 'You are not allowed to move this item to the Trash.', 'wp-e-commerce' ) );
|
228 |
+
|
229 |
+
if ( !wp_trash_post( $post_id ) )
|
230 |
+
wp_die( __( 'Error in moving to Trash.', 'wp-e-commerce' ) );
|
231 |
+
|
232 |
+
$trashed++;
|
233 |
+
}
|
234 |
+
return esc_url( add_query_arg( array( 'trashed' => $trashed, 'ids' => join( ',', $post_ids ) ) ) );
|
235 |
+
}
|
236 |
+
|
237 |
+
public function process_bulk_action_untrash( $post_ids ) {
|
238 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
239 |
+
$untrashed = 0;
|
240 |
+
foreach( (array) $post_ids as $post_id ) {
|
241 |
+
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
242 |
+
wp_die( __( 'You are not allowed to restore this item from the Trash.', 'wp-e-commerce' ) );
|
243 |
+
|
244 |
+
if ( !wp_untrash_post( $post_id ) )
|
245 |
+
wp_die( __( 'Error in restoring from Trash.', 'wp-e-commerce' ) );
|
246 |
+
|
247 |
+
$untrashed++;
|
248 |
+
}
|
249 |
+
return esc_url( add_query_arg( 'untrashed', $untrashed ) );
|
250 |
+
}
|
251 |
+
|
252 |
+
public function process_bulk_action_delete( $post_ids ) {
|
253 |
+
$deleted = 0;
|
254 |
+
$post_type_object = get_post_type_object( 'wpsc-product' );
|
255 |
+
foreach( (array) $post_ids as $post_id ) {
|
256 |
+
$post_del = & get_post( $post_id );
|
257 |
+
|
258 |
+
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
|
259 |
+
wp_die( __( 'You are not allowed to delete this item.', 'wp-e-commerce' ) );
|
260 |
+
|
261 |
+
if ( $post_del->post_type == 'attachment' ) {
|
262 |
+
if ( ! wp_delete_attachment( $post_id ) )
|
263 |
+
wp_die( __( 'Error in deleting...', 'wp-e-commerce' ) );
|
264 |
+
} else {
|
265 |
+
if ( ! wp_delete_post( $post_id ) )
|
266 |
+
wp_die( __( 'Error in deleting...', 'wp-e-commerce' ) );
|
267 |
+
}
|
268 |
+
$deleted++;
|
269 |
+
}
|
270 |
+
return esc_url( add_query_arg( 'deleted', $deleted ) );
|
271 |
+
}
|
272 |
+
|
273 |
+
public function process_bulk_action_hide( $post_ids ) {
|
274 |
+
$updated = 0;
|
275 |
+
foreach( $post_ids as $id ) {
|
276 |
+
wp_update_post( array(
|
277 |
+
'ID' => $id,
|
278 |
+
'post_status' => 'draft',
|
279 |
+
) );
|
280 |
+
$updated ++;
|
281 |
+
}
|
282 |
+
return esc_url( add_query_arg( 'updated', $updated ) );
|
283 |
+
}
|
284 |
+
|
285 |
+
public function process_bulk_action_show( $post_ids ) {
|
286 |
+
$updated = 0;
|
287 |
+
foreach ( $post_ids as $id ) {
|
288 |
+
wp_update_post( array(
|
289 |
+
'ID' => $id,
|
290 |
+
'post_status' => 'publish',
|
291 |
+
) );
|
292 |
+
$updated ++;
|
293 |
+
}
|
294 |
+
return esc_url( add_query_arg( 'updated', $updated ) );
|
295 |
+
}
|
296 |
+
|
297 |
+
private function save_bulk_edited_items() {
|
298 |
+
$ids = array_map( 'absint', $_REQUEST['wpsc_bulk_edit']['post'] );
|
299 |
+
$data = $_REQUEST['wpsc_bulk_edit'];
|
300 |
+
|
301 |
+
if ( empty( $_REQUEST['wpsc_bulk_edit']['fields'] ) )
|
302 |
+
return;
|
303 |
+
|
304 |
+
$fields = $_REQUEST['wpsc_bulk_edit']['fields'];
|
305 |
+
|
306 |
+
foreach ( array( 'stock', 'price', 'sale_price', 'sku' ) as $field ) {
|
307 |
+
if ( empty( $fields[$field] ) )
|
308 |
+
unset( $data[$field] );
|
309 |
+
}
|
310 |
+
|
311 |
+
if ( empty( $fields['shipping'] ) )
|
312 |
+
unset( $data['product_metadata']['shipping'] );
|
313 |
+
else {
|
314 |
+
foreach ( array( 'local', 'international' ) as $field ) {
|
315 |
+
if ( empty( $fields['shipping'][$field] ) )
|
316 |
+
unset( $data['product_metadata'][$field] );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
if ( empty( $fields['measurements'] ) ) {
|
321 |
+
unset( $data['product_metadata']['dimensions'] );
|
322 |
+
unset( $data['product_metadata']['weight'] );
|
323 |
+
unset( $data['product_metadata']['weight_unit'] );
|
324 |
+
} else {
|
325 |
+
if ( empty( $fields['measurements']['weight'] ) ) {
|
326 |
+
unset( $data['product_metadata']['weight'] );
|
327 |
+
unset( $data['product_metadata']['weight_unit'] );
|
328 |
+
}
|
329 |
+
|
330 |
+
if ( empty( $fields['measurements']['dimensions'] ) ) {
|
331 |
+
foreach ( array( 'height', 'width', 'length' ) as $field ) {
|
332 |
+
unset( $data['product_metadata']['dimensions'][$field] );
|
333 |
+
unset( $data['product_metadata']['dimensions'][$field . '_unit'] );
|
334 |
+
}
|
335 |
+
} else {
|
336 |
+
foreach ( array( 'height', 'width', 'length' ) as $field ) {
|
337 |
+
$data['product_metadata']['dimensions'][$field . '_unit'] = "cm";
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
unset( $data['product_metadata']['dimensions_unit'] );
|
342 |
+
}
|
343 |
+
|
344 |
+
unset( $data['post'] );
|
345 |
+
unset( $data['fields'] );
|
346 |
+
|
347 |
+
foreach ( $ids as $id ) {
|
348 |
+
$this->save_variation_meta( $id, $data );
|
349 |
+
}
|
350 |
+
|
351 |
+
$sendback = $_SERVER['REQUEST_URI'];
|
352 |
+
$sendback = remove_query_arg( array(
|
353 |
+
'_wp_http_referer',
|
354 |
+
'bulk_action',
|
355 |
+
'bulk_action2',
|
356 |
+
'bulk_action_nonce',
|
357 |
+
'confirm',
|
358 |
+
'post',
|
359 |
+
'last_paged'
|
360 |
+
), $sendback );
|
361 |
+
$sendback = add_query_arg( 'updated', count( $ids ), $sendback );
|
362 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
363 |
+
exit;
|
364 |
+
}
|
365 |
+
|
366 |
+
public function process_bulk_action_edit( $post_ids ) {
|
367 |
+
$this->list_table->set_bulk_edited_items( $post_ids );
|
368 |
+
}
|
369 |
+
|
370 |
+
public function process_bulk_action() {
|
371 |
+
if ( ! empty( $_REQUEST['wpsc_bulk_edit']['post'] ) ) {
|
372 |
+
$this->save_bulk_edited_items();
|
373 |
+
return;
|
374 |
+
}
|
375 |
+
|
376 |
+
$current_action = $this->list_table->current_action();
|
377 |
+
if ( empty( $current_action ) )
|
378 |
+
return;
|
379 |
+
|
380 |
+
_wpsc_remove_refresh_variation_parent_term_hooks();
|
381 |
+
|
382 |
+
check_admin_referer( 'wpsc_product_variations_bulk_action', 'bulk_action_nonce' );
|
383 |
+
$sendback = $_SERVER['REQUEST_URI'];
|
384 |
+
$callback = 'process_bulk_action_' . $current_action;
|
385 |
+
|
386 |
+
$post_ids = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : array();
|
387 |
+
if ( ! is_array( $post_ids ) )
|
388 |
+
$post_ids = explode( ',', $post_ids );
|
389 |
+
$post_ids = array_map('intval', $post_ids);
|
390 |
+
if ( ! empty( $post_ids ) && is_callable( array( $this, $callback ) ) )
|
391 |
+
$sendback = $this->$callback( $post_ids );
|
392 |
+
|
393 |
+
$sendback = remove_query_arg( array(
|
394 |
+
'_wp_http_referer',
|
395 |
+
'bulk_action',
|
396 |
+
'bulk_action2',
|
397 |
+
'bulk_action_nonce',
|
398 |
+
'confirm',
|
399 |
+
'post',
|
400 |
+
'last_paged'
|
401 |
+
), $sendback );
|
402 |
+
|
403 |
+
_wpsc_refresh_parent_product_terms( $this->parent_id );
|
404 |
+
_wpsc_add_refresh_variation_parent_term_hooks();
|
405 |
+
if ( $current_action != 'edit' ) {
|
406 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
407 |
+
exit;
|
408 |
+
}
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Wrapper for _wp_admin_html_begin(), which might not be available on older
|
414 |
+
* WordPress versions.
|
415 |
+
*
|
416 |
+
* @access private
|
417 |
+
* @since 3.8.9.4
|
418 |
+
*/
|
419 |
+
function _wpsc_admin_html_begin() {
|
420 |
+
if ( function_exists( '_wp_admin_html_begin' ) ) {
|
421 |
+
_wp_admin_html_begin();
|
422 |
+
return;
|
423 |
+
}
|
424 |
+
|
425 |
+
$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
|
426 |
+
?>
|
427 |
+
<!DOCTYPE html>
|
428 |
+
<!--[if IE 8]>
|
429 |
+
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
|
430 |
+
<![endif]-->
|
431 |
+
<!--[if !(IE 8) ]><!-->
|
432 |
+
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
|
433 |
+
<!--<![endif]-->
|
434 |
+
<head>
|
435 |
+
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
436 |
+
<?php
|
437 |
+
}
|
trunk/wpsc-admin/includes/product-variations-setup.page.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="product_variations">
|
2 |
+
<h4><a href="#wpsc_variation_metabox" class="add_variation_set_action"><?php esc_html_e( '+ Add New Variants', 'wp-e-commerce' ) ?></a></h4>
|
3 |
+
|
4 |
+
<div id="add-new-variation-set">
|
5 |
+
<p>
|
6 |
+
<label for="new-variation-set-name"><?php esc_html_e( "Enter variation set's name", 'wp-e-commerce' ); ?></label>
|
7 |
+
<input type="text" class="text-field" id="new-variation-set-name" /><br />
|
8 |
+
</p>
|
9 |
+
<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.", 'wp-e-commerce' ); ?></p>
|
10 |
+
<p>
|
11 |
+
<label for="new-variants"><?php esc_html_e( "Enter new variants", 'wp-e-commerce' ); ?></label>
|
12 |
+
<input type="text" class="text-field" id="new-variants" /><br />
|
13 |
+
</p>
|
14 |
+
<p class="howto"><?php esc_html_e( "Example: Red, Green, Blue. Separate variants with commas.", 'wp-e-commerce' ); ?></p>
|
15 |
+
<p>
|
16 |
+
<a class="button" href="#"><?php esc_html_e( 'Add New Variants', 'wp-e-commerce' ); ?></a>
|
17 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
18 |
+
</p>
|
19 |
+
</div>
|
20 |
+
|
21 |
+
<p><a name='variation_control'> </a><?php _e( 'Select the Variation sets and then the corresponding Variants you want to add to this product.', 'wp-e-commerce' ) ?></p>
|
22 |
+
|
23 |
+
<form action="" method="post">
|
24 |
+
<ul class="variation_checkboxes">
|
25 |
+
<?php
|
26 |
+
wp_terms_checklist( $this->parent_id, array(
|
27 |
+
'taxonomy' => 'wpsc-variation',
|
28 |
+
'walker' => new WPSC_Walker_Variation_Checklist(),
|
29 |
+
'checked_ontop' => false,
|
30 |
+
) );
|
31 |
+
?>
|
32 |
+
</ul>
|
33 |
+
<input type="hidden" name="action2" value="generate" />
|
34 |
+
<input type="hidden" name="product_id" value="<?php echo $this->parent_id; ?>" />
|
35 |
+
<?php wp_nonce_field( 'wpsc_generate_product_variations', '_wpsc_generate_product_variations_nonce' ); ?>
|
36 |
+
<?php submit_button( __( 'Generate Variations', 'wp-e-commerce' ) ); ?>
|
37 |
+
</form>
|
38 |
+
|
39 |
+
<div class="clear"></div>
|
40 |
+
</div>
|
trunk/wpsc-admin/includes/product-variations.page.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php _wpsc_admin_html_begin(); ?>
|
2 |
+
<title><?php esc_html_e( 'Manage Product Variations', 'wp-e-commerce' ); ?></title>
|
3 |
+
<script type="text/javascript">
|
4 |
+
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
5 |
+
var userSettings = {
|
6 |
+
'url': '<?php echo SITECOOKIEPATH; ?>',
|
7 |
+
'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
|
8 |
+
'time':'<?php echo time() ?>'
|
9 |
+
},
|
10 |
+
ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
|
11 |
+
pagenow = '<?php echo $current_screen->id; ?>',
|
12 |
+
typenow = '<?php echo $current_screen->post_type; ?>',
|
13 |
+
adminpage = '<?php echo $admin_body_class; ?>',
|
14 |
+
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
|
15 |
+
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
|
16 |
+
isRtl = <?php echo (int) is_rtl(); ?>;
|
17 |
+
</script>
|
18 |
+
<?php
|
19 |
+
do_action('admin_enqueue_scripts', $hook_suffix);
|
20 |
+
do_action("admin_print_styles-$hook_suffix");
|
21 |
+
do_action('admin_print_styles');
|
22 |
+
do_action("admin_print_scripts-$hook_suffix");
|
23 |
+
do_action('admin_print_scripts');
|
24 |
+
do_action("admin_head-$hook_suffix");
|
25 |
+
do_action('admin_head');
|
26 |
+
?>
|
27 |
+
<style type="text/css">
|
28 |
+
html {
|
29 |
+
background-color:transparent;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
+
</head>
|
33 |
+
<?php
|
34 |
+
|
35 |
+
$admin_body_class = ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
|
36 |
+
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
|
37 |
+
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
|
38 |
+
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
|
39 |
+
|
40 |
+
?>
|
41 |
+
<body class="no-js wp-admin wp-core-ui wpsc-product-variation-iframe<?php echo $admin_body_class; ?>">
|
42 |
+
<script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
|
43 |
+
|
44 |
+
<div id="post-body">
|
45 |
+
<div id="wpsc-product-variations-wrapper" class="categorydiv wpsc-categorydiv">
|
46 |
+
<?php $this->display_tabs(); ?>
|
47 |
+
<div class="wpsc-product-variations-tab-content tabs-panel">
|
48 |
+
<?php $this->display_current_tab(); ?>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php
|
54 |
+
do_action('admin_print_footer_scripts');
|
55 |
+
do_action("admin_footer-" . $GLOBALS['hook_suffix']);
|
56 |
+
?>
|
57 |
+
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
|
58 |
+
</body>
|
59 |
+
</html>
|
trunk/wpsc-admin/includes/products.php
ADDED
File without changes
|
trunk/wpsc-admin/includes/purchase-log-action-links.php
ADDED
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Purchase Log Action Links Class
|
5 |
+
*
|
6 |
+
* Manages and displays a links of action links when editing a puchase log.
|
7 |
+
*
|
8 |
+
* @package wp-e-commerce
|
9 |
+
* @since 3.9.0
|
10 |
+
*
|
11 |
+
* @link https://github.com/wp-e-commerce/WP-e-Commerce/pull/1562
|
12 |
+
*/
|
13 |
+
class WPSC_Purchase_Log_Action_Links {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Purchase Log ID.
|
17 |
+
*
|
18 |
+
* @since 3.9.0
|
19 |
+
* @access private
|
20 |
+
* @var int
|
21 |
+
*/
|
22 |
+
protected $log_id;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* An array of WPSC_Purchase_Log_Action_Link objects.
|
26 |
+
*
|
27 |
+
* @since 3.9.0
|
28 |
+
* @access private
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
protected $links;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Setup all action links.
|
35 |
+
*
|
36 |
+
* @since 3.9.0
|
37 |
+
*
|
38 |
+
* @param int $log_id Purchase log ID.
|
39 |
+
*/
|
40 |
+
public function __construct( $log_id ) {
|
41 |
+
|
42 |
+
$this->log_id = absint( $log_id );
|
43 |
+
|
44 |
+
// Create and validate links.
|
45 |
+
$this->_create_links();
|
46 |
+
$this->_validate_links();
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Create Action Links
|
52 |
+
*
|
53 |
+
* Packing slip and email receipt links are available by default.
|
54 |
+
* Action links are filterable via the 'wpsc_purchlogitem_links' filter which passes the purchase log ID.
|
55 |
+
* Delete and back links are always required and added after the filter.
|
56 |
+
*
|
57 |
+
* @since 3.9.0
|
58 |
+
* @access private
|
59 |
+
*/
|
60 |
+
private function _create_links() {
|
61 |
+
|
62 |
+
// Add default links.
|
63 |
+
if ( wpsc_purchlogs_have_downloads_locked() !== false ) {
|
64 |
+
$this->links[] = $this->get_downloads_lock_link();
|
65 |
+
}
|
66 |
+
$this->links[] = $this->get_packing_slip_link();
|
67 |
+
$this->links[] = $this->get_email_receipt_link();
|
68 |
+
|
69 |
+
// Filter action links.
|
70 |
+
$this->links = apply_filters( 'wpsc_purchlogitem_links', $this->links, $this->log_id );
|
71 |
+
|
72 |
+
// Add delete and back links.
|
73 |
+
$this->links[] = $this->_get_delete_link();
|
74 |
+
$this->links[] = $this->_get_back_link();
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Validate Links
|
80 |
+
*
|
81 |
+
* Validates all links are WPSC_Purchase_Log_Action_Link objects.
|
82 |
+
*
|
83 |
+
* @since 3.9.0
|
84 |
+
* @access private
|
85 |
+
*/
|
86 |
+
private function _validate_links() {
|
87 |
+
|
88 |
+
$this->links = array_map( array( $this, '_validate_link' ), $this->links );
|
89 |
+
$this->links = array_filter( $this->links );
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Validate Link
|
95 |
+
*
|
96 |
+
* Validates a WPSC_Purchase_Log_Action_Link object.
|
97 |
+
*
|
98 |
+
* @since 3.9.0
|
99 |
+
* @access private
|
100 |
+
*
|
101 |
+
* @todo Check that the WPSC_Purchase_Log_Action_Link ID is unique and reject if not - maybe not here.
|
102 |
+
*
|
103 |
+
* @param WPSC_Purchase_Log_Action_Link $action_link Action link object.
|
104 |
+
* @return WPSC_Purchase_Log_Action_Link|boolean If valid, the action link object, otherwise false.
|
105 |
+
*/
|
106 |
+
private function _validate_link( $action_link ) {
|
107 |
+
|
108 |
+
if ( is_a( $action_link, 'WPSC_Purchase_Log_Action_Link' ) ) {
|
109 |
+
return $action_link;
|
110 |
+
}
|
111 |
+
|
112 |
+
return false;
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Downloads Lock Action Link
|
118 |
+
*
|
119 |
+
* @since 3.9.0
|
120 |
+
* @access private
|
121 |
+
*
|
122 |
+
* @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
|
123 |
+
*/
|
124 |
+
private function get_downloads_lock_link() {
|
125 |
+
|
126 |
+
return new WPSC_Purchase_Log_Action_Link( 'downloads_lock', wpsc_purchlogs_have_downloads_locked(), $this->log_id, array(
|
127 |
+
'ajax' => true,
|
128 |
+
'dashicon' => 'dashicons-lock'
|
129 |
+
) );
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* View Packing Slip Action Link
|
135 |
+
*
|
136 |
+
* @since 3.9.0
|
137 |
+
* @access private
|
138 |
+
*
|
139 |
+
* @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
|
140 |
+
*/
|
141 |
+
private function get_packing_slip_link() {
|
142 |
+
|
143 |
+
return new WPSC_Purchase_Log_Action_Link( 'packing_slip', __( 'View Packing Slip', 'wp-e-commerce' ), $this->log_id, array(
|
144 |
+
'url' => esc_url( add_query_arg( array(
|
145 |
+
'c' => 'packing_slip',
|
146 |
+
'id' => $this->log_id
|
147 |
+
) ) ),
|
148 |
+
'dashicon' => 'dashicons-format-aside',
|
149 |
+
'attributes' => array(
|
150 |
+
'target' => 'wpsc_packing_slip'
|
151 |
+
)
|
152 |
+
) );
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Resend Email Receipt Action Link
|
158 |
+
*
|
159 |
+
* @since 3.9.0
|
160 |
+
* @access private
|
161 |
+
*
|
162 |
+
* @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
|
163 |
+
*/
|
164 |
+
private function get_email_receipt_link() {
|
165 |
+
|
166 |
+
return new WPSC_Purchase_Log_Action_Link( 'email_receipt', __( 'Resend Receipt to Buyer', 'wp-e-commerce' ), $this->log_id, array(
|
167 |
+
'ajax' => true,
|
168 |
+
'dashicon' => 'dashicons-migrate dashicons-email-alt'
|
169 |
+
) );
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Delete Action Link
|
175 |
+
*
|
176 |
+
* @since 3.9.0
|
177 |
+
* @access private
|
178 |
+
*
|
179 |
+
* @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
|
180 |
+
*/
|
181 |
+
private function _get_delete_link() {
|
182 |
+
|
183 |
+
return new WPSC_Purchase_Log_Action_Link( 'delete', _x( 'Remove this record', 'purchase log action link', 'wp-e-commerce' ), $this->log_id, array(
|
184 |
+
'dashicon' => 'dashicons-dismiss',
|
185 |
+
'attributes' => array(
|
186 |
+
'onclick' => "if ( confirm('" . esc_js( sprintf( __( "You are about to delete this log '%s'\n 'Cancel' to stop, 'OK' to delete.", 'wp-e-commerce' ), wpsc_purchaselog_details_date() ) ) . "') ) { return true; } return false;"
|
187 |
+
)
|
188 |
+
) );
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Back Action Link
|
194 |
+
*
|
195 |
+
* @since 3.9.0
|
196 |
+
* @access private
|
197 |
+
*
|
198 |
+
* @return WPSC_Purchase_Log_Action_Link Instance of an action link object.
|
199 |
+
*/
|
200 |
+
private function _get_back_link() {
|
201 |
+
|
202 |
+
return new WPSC_Purchase_Log_Action_Link( 'back', _x( 'Go Back', 'purchase log action link', 'wp-e-commerce' ), $this->log_id, array(
|
203 |
+
'url' => wp_get_referer(),
|
204 |
+
'dashicon' => 'dashicons-arrow-left-alt'
|
205 |
+
) );
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Display Link List Items
|
211 |
+
*
|
212 |
+
* @since 3.9.0
|
213 |
+
*
|
214 |
+
* Outputs action links as a series of list item tags to be included in an HTML list.
|
215 |
+
*/
|
216 |
+
public function display_link_list_items() {
|
217 |
+
|
218 |
+
foreach ( $this->links as $link ) {
|
219 |
+
echo '<li>' . $link->get_link_display() . '</li>';
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Purchase Log Action Link Class
|
228 |
+
*
|
229 |
+
* Creates, styles and handles a purchase log action link.
|
230 |
+
*
|
231 |
+
* @since 3.9.0
|
232 |
+
*/
|
233 |
+
class WPSC_Purchase_Log_Action_Link {
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Action Link ID.
|
237 |
+
*
|
238 |
+
* @since 3.9.0
|
239 |
+
* @access private
|
240 |
+
* @var string
|
241 |
+
*/
|
242 |
+
private $id;
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Action Link Title Text.
|
246 |
+
*
|
247 |
+
* @since 3.9.0
|
248 |
+
* @access private
|
249 |
+
* @var string
|
250 |
+
*/
|
251 |
+
private $title;
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Purchase Log ID.
|
255 |
+
*
|
256 |
+
* @since 3.9.0
|
257 |
+
* @access private
|
258 |
+
* @var int
|
259 |
+
*/
|
260 |
+
private $log_id;
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Action Link Settings.
|
264 |
+
*
|
265 |
+
* @since 3.9.0
|
266 |
+
* @access private
|
267 |
+
* @var array
|
268 |
+
*/
|
269 |
+
private $args;
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Define the action link.
|
273 |
+
*
|
274 |
+
* @since 3.9.0
|
275 |
+
*
|
276 |
+
* @param string $id Action link ID (will be sanitized).
|
277 |
+
* @param string $title Link text.
|
278 |
+
* @param array $args Action link settings.
|
279 |
+
*/
|
280 |
+
public function __construct( $id, $title, $log_id, $args = array() ) {
|
281 |
+
|
282 |
+
$this->id = sanitize_key( $id );
|
283 |
+
$this->title = $title;
|
284 |
+
$this->log_id = absint( $log_id );
|
285 |
+
$this->args = $this->_validate_settings( $args );
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Validate Settings
|
291 |
+
*
|
292 |
+
* Checks settings and adds defaults where required.
|
293 |
+
*
|
294 |
+
* The 'attributes' setting allows additional attributes to be added to the link tag if required.
|
295 |
+
* 'title' and 'href' attributes are removed as these are created via the 'url' and 'description' settings.
|
296 |
+
*
|
297 |
+
* Any class attributes are added to the 'wpsc-purchlog-action-{$id}' class we generate.
|
298 |
+
*
|
299 |
+
* @since 3.9.0
|
300 |
+
* @access private
|
301 |
+
*
|
302 |
+
* @param array $args Supplied settings.
|
303 |
+
* @return array Validated settings.
|
304 |
+
*/
|
305 |
+
private function _validate_settings( $args ) {
|
306 |
+
|
307 |
+
$args = wp_parse_args( $args, array(
|
308 |
+
'url' => '',
|
309 |
+
'description' => '',
|
310 |
+
'dashicon' => '',
|
311 |
+
'attributes' => array(),
|
312 |
+
'ajax' => false
|
313 |
+
) );
|
314 |
+
|
315 |
+
// Use title if no description.
|
316 |
+
if ( empty( $args['description'] ) ) {
|
317 |
+
$args['description'] = $this->title;
|
318 |
+
}
|
319 |
+
|
320 |
+
// Use default arrow dashicon if none specified.
|
321 |
+
if ( empty( $args['dashicon'] ) ) {
|
322 |
+
$args['dashicon'] = 'dashicons-arrow-right-alt';
|
323 |
+
}
|
324 |
+
|
325 |
+
// Remove href and title attributes.
|
326 |
+
if ( is_array( $args['attributes'] ) ) {
|
327 |
+
if ( array_key_exists( 'title', $args['attributes'] ) ) {
|
328 |
+
unset( $args['attributes']['title'] );
|
329 |
+
}
|
330 |
+
if ( array_key_exists( 'href', $args['attributes'] ) ) {
|
331 |
+
unset( $args['attributes']['href'] );
|
332 |
+
}
|
333 |
+
} else {
|
334 |
+
$args['attributes'] = array();
|
335 |
+
}
|
336 |
+
|
337 |
+
// Add class and append any extra classes.
|
338 |
+
if ( ! array_key_exists( 'class', $args['attributes'] ) ) {
|
339 |
+
$args['attributes']['class'] = '';
|
340 |
+
}
|
341 |
+
$args['attributes']['class'] = 'wpsc-purchlog-action-link ' . trim( $this->get_html_class() . ' ' . $args['attributes']['class'] );
|
342 |
+
|
343 |
+
// Add AJAX class
|
344 |
+
if ( $args['ajax'] ) {
|
345 |
+
$args['attributes']['class'] .= ' is-ajax';
|
346 |
+
}
|
347 |
+
|
348 |
+
return $args;
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Get HTML Class
|
354 |
+
*
|
355 |
+
* @since 3.9.0
|
356 |
+
*
|
357 |
+
* @return string Action link class.
|
358 |
+
*/
|
359 |
+
public function get_html_class() {
|
360 |
+
|
361 |
+
return 'wpsc-purchlog-action-link-' . sanitize_html_class( $this->id );
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Get Link Display
|
367 |
+
*
|
368 |
+
* @since 3.9.0
|
369 |
+
*
|
370 |
+
* @return string HTML action link.
|
371 |
+
*/
|
372 |
+
public function get_link_display() {
|
373 |
+
|
374 |
+
return sprintf( '<a href="%s" title="%s" %s>%s%s</a>',
|
375 |
+
esc_attr( $this->get_link_url() ),
|
376 |
+
esc_attr( $this->args['description'] ),
|
377 |
+
$this->_get_link_attributes_string(),
|
378 |
+
$this->_get_dashicon_display(),
|
379 |
+
esc_html( $this->title )
|
380 |
+
);
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Get Link URL
|
386 |
+
*
|
387 |
+
* Returns the custom URL if specified.
|
388 |
+
* Otherwise returns a callback URL.
|
389 |
+
*
|
390 |
+
* @since 3.9.0
|
391 |
+
*
|
392 |
+
* @return string URL.
|
393 |
+
*/
|
394 |
+
public function get_link_url() {
|
395 |
+
|
396 |
+
// Custom URL
|
397 |
+
if ( ! empty( $this->args['url'] ) ) {
|
398 |
+
return $this->args['url'];
|
399 |
+
}
|
400 |
+
|
401 |
+
// Callback URL
|
402 |
+
$url = add_query_arg( array( 'wpsc_purchase_log_action' => $this->id, 'id' => $this->log_id ) );
|
403 |
+
$url = wp_nonce_url( $url, 'wpsc_purchase_log_action_' . $this->id );
|
404 |
+
|
405 |
+
return esc_url( $url );
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Get Link Attributes String
|
411 |
+
*
|
412 |
+
* @since 3.9.0
|
413 |
+
* @access private
|
414 |
+
*
|
415 |
+
* @return string Link attributes HTML.
|
416 |
+
*/
|
417 |
+
private function _get_link_attributes_string() {
|
418 |
+
|
419 |
+
$atts = array();
|
420 |
+
foreach ( $this->args['attributes'] as $att => $val ) {
|
421 |
+
$att_key = sanitize_html_class( $att );
|
422 |
+
|
423 |
+
// Don't override attributes that we set elsewhere
|
424 |
+
if ( in_array( $att_key, array( 'href', 'title' ) ) ) {
|
425 |
+
continue;
|
426 |
+
}
|
427 |
+
|
428 |
+
$atts[] = $att_key . '="' . esc_attr( $val ) . '"';
|
429 |
+
}
|
430 |
+
|
431 |
+
// Data attributes for JS/AJAX
|
432 |
+
$atts[] = 'data-purchase-log-action="' . esc_attr( $this->id ) . '"';
|
433 |
+
$atts[] = 'data-nonce="' . esc_attr( wp_create_nonce( 'wpsc_purchase_log_action_ajax_' . $this->id ) ) . '"';
|
434 |
+
|
435 |
+
return implode( ' ', $atts );
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Get Dashicon Display
|
441 |
+
*
|
442 |
+
* @since 3.9.0
|
443 |
+
* @access private
|
444 |
+
*
|
445 |
+
* @return string Dashicon HTML element.
|
446 |
+
*/
|
447 |
+
private function _get_dashicon_display() {
|
448 |
+
|
449 |
+
return '<span class="dashicons ' . $this->_sanitize_html_classes( $this->args['dashicon'] ) . '"></span>';
|
450 |
+
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Sanitize HTML Classes
|
455 |
+
*
|
456 |
+
* Handles sanitizing multiple classes provided as a string.
|
457 |
+
*
|
458 |
+
* @since 3.9.0
|
459 |
+
* @access private
|
460 |
+
*
|
461 |
+
* @param string|array $classes Classes.
|
462 |
+
* @return string Santized classes.
|
463 |
+
*/
|
464 |
+
private function _sanitize_html_classes( $classes ) {
|
465 |
+
|
466 |
+
// Convert multiple classes string to an array.
|
467 |
+
if ( ! is_array( $classes ) && strpos( $classes, ' ' ) !== false ) {
|
468 |
+
$classes = explode( ' ', $classes );
|
469 |
+
}
|
470 |
+
|
471 |
+
// Sanitize and return multiple classes.
|
472 |
+
if ( is_array( $classes ) ) {
|
473 |
+
$classes = array_map( 'sanitize_html_class', $classes );
|
474 |
+
return implode( ' ', $classes );
|
475 |
+
}
|
476 |
+
|
477 |
+
// Sanitize single class.
|
478 |
+
return sanitize_html_class( $classes );
|
479 |
+
|
480 |
+
}
|
481 |
+
|
482 |
+
}
|
trunk/wpsc-admin/includes/purchase-log-list-table-class.php
ADDED
@@ -0,0 +1,872 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
private $search_box = true;
|
10 |
+
private $bulk_actions = true;
|
11 |
+
private $sortable = true;
|
12 |
+
private $month_filter = true;
|
13 |
+
private $views = true;
|
14 |
+
private $status = 'all';
|
15 |
+
private $per_page = 20;
|
16 |
+
private $total_amount = 0;
|
17 |
+
private $joins;
|
18 |
+
private $where;
|
19 |
+
private $where_no_filter;
|
20 |
+
|
21 |
+
public function __construct( $args = array() ) {
|
22 |
+
$args['plural'] = 'purchase-logs';
|
23 |
+
|
24 |
+
$this->set_per_page( $this->set_purchase_logs_per_page_by_user() );
|
25 |
+
|
26 |
+
parent::__construct( $args );
|
27 |
+
|
28 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|
29 |
+
$_SERVER['REQUEST_URI'] = wp_get_referer();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function disable_sortable() {
|
33 |
+
$this->sortable = false;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function disable_search_box() {
|
37 |
+
$this->search_box = false;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function disable_bulk_actions() {
|
41 |
+
$this->bulk_actions = false;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function disable_month_filter() {
|
45 |
+
$this->month_filter = false;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function disable_views() {
|
49 |
+
$this->views = false;
|
50 |
+
}
|
51 |
+
|
52 |
+
private function set_purchase_logs_per_page_by_user() {
|
53 |
+
|
54 |
+
$per_page = get_user_meta( get_current_user_id(), 'wpsc_purchases_per_page', true );
|
55 |
+
|
56 |
+
return empty( $per_page ) || $per_page < 1 ? 20 : $per_page;
|
57 |
+
}
|
58 |
+
|
59 |
+
// Override the default Purchase Logs Per Page
|
60 |
+
public function set_per_page( $per_page ) {
|
61 |
+
$this->per_page = (int) $per_page;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function prepare_items() {
|
65 |
+
global $wpdb;
|
66 |
+
|
67 |
+
$page = $this->get_pagenum();
|
68 |
+
$offset = ( $page - 1 ) * $this->per_page;
|
69 |
+
|
70 |
+
$checkout_fields_sql = "
|
71 |
+
SELECT id, unique_name FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE unique_name IN ('billingfirstname', 'billinglastname', 'billingemail') AND active='1' AND checkout_set='0'
|
72 |
+
";
|
73 |
+
$checkout_fields = $wpdb->get_results( $checkout_fields_sql );
|
74 |
+
|
75 |
+
$joins = array();
|
76 |
+
$where = array( '1 = 1' );
|
77 |
+
|
78 |
+
if ( isset( $_REQUEST['post'] ) ) {
|
79 |
+
$posts = array_map( 'absint', $_REQUEST['post'] );
|
80 |
+
$where[] = ' and (p.id IN (' . implode( ', ', $posts ) . '))';
|
81 |
+
}
|
82 |
+
|
83 |
+
$i = 1;
|
84 |
+
$selects = array( 'p.id', 'p.totalprice AS amount', 'p.processed AS status', 'p.track_id', 'p.date' );
|
85 |
+
$selects[] = '
|
86 |
+
(
|
87 |
+
SELECT SUM(quantity) FROM ' . WPSC_TABLE_CART_CONTENTS . ' AS c
|
88 |
+
WHERE c.purchaseid = p.id
|
89 |
+
) AS item_count';
|
90 |
+
|
91 |
+
$search_terms = empty( $_REQUEST['s'] ) ? array() : explode( ' ', $_REQUEST['s'] );
|
92 |
+
$search_sql = array();
|
93 |
+
|
94 |
+
foreach ( $checkout_fields as $field ) {
|
95 |
+
$table_as = 's' . $i;
|
96 |
+
$select_as = str_replace('billing', '', $field->unique_name );
|
97 |
+
$selects[] = $table_as . '.value AS ' . $select_as;
|
98 |
+
$joins[] = $wpdb->prepare( "LEFT OUTER JOIN " . WPSC_TABLE_SUBMITTED_FORM_DATA . " AS {$table_as} ON {$table_as}.log_id = p.id AND {$table_as}.form_id = %d", $field->id );
|
99 |
+
|
100 |
+
// build search term queries for first name, last name, email
|
101 |
+
foreach ( $search_terms as $term ) {
|
102 |
+
|
103 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.0', '>=' ) ) {
|
104 |
+
$escaped_term = esc_sql( like_escape( $term ) );
|
105 |
+
} else {
|
106 |
+
$escaped_term = esc_sql( $wpdb->esc_like( $term ) );
|
107 |
+
}
|
108 |
+
|
109 |
+
if ( ! array_key_exists( $term, $search_sql ) ) {
|
110 |
+
$search_sql[ $term ] = array();
|
111 |
+
}
|
112 |
+
|
113 |
+
$search_sql[ $term ][] = $table_as . ".value LIKE '%" . $escaped_term . "%'";
|
114 |
+
}
|
115 |
+
|
116 |
+
$i++;
|
117 |
+
}
|
118 |
+
|
119 |
+
// combine query phrases into a single query string
|
120 |
+
foreach ( $search_terms as $term ) {
|
121 |
+
$search_sql[ $term ][] = "p.track_id = '" . esc_sql( $term ) . "'";
|
122 |
+
if ( is_numeric( $term ) )
|
123 |
+
$search_sql[ $term ][] = 'p.id = ' . esc_sql( $term );
|
124 |
+
$search_sql[ $term ] = '(' . implode( ' OR ', $search_sql[ $term ] ) . ')';
|
125 |
+
}
|
126 |
+
$search_sql = implode( ' AND ', array_values( $search_sql ) );
|
127 |
+
|
128 |
+
if ( $search_sql ) {
|
129 |
+
$where[] = " AND ({$search_sql})";
|
130 |
+
}
|
131 |
+
|
132 |
+
// filter by status
|
133 |
+
if ( ! empty( $_REQUEST['status'] ) && $_REQUEST['status'] != 'all' ) {
|
134 |
+
$this->status = absint( $_REQUEST['status'] );
|
135 |
+
$where[] = ' AND (processed = ' . $this->status .')';
|
136 |
+
}
|
137 |
+
|
138 |
+
$this->where_no_filter = implode( ' ', $where );
|
139 |
+
|
140 |
+
// filter by month
|
141 |
+
if ( ! empty( $_REQUEST['m'] ) ) {
|
142 |
+
|
143 |
+
// so we can tell WP_Date_Query we're legit
|
144 |
+
add_filter( 'date_query_valid_columns', array( $this, 'set_date_column_to_date') );
|
145 |
+
|
146 |
+
if ( strlen( $_REQUEST['m'] ) < 4 ) {
|
147 |
+
$query_args = $this->assemble_predefined_periods_query( $_REQUEST['m'] );
|
148 |
+
} else {
|
149 |
+
$query_args = array(
|
150 |
+
'year' => (int) substr( $_REQUEST['m'], 0, 4),
|
151 |
+
'monthnum' => (int) substr( $_REQUEST['m'], -2 ),
|
152 |
+
);
|
153 |
+
}
|
154 |
+
|
155 |
+
$date_query = new WP_Date_Query( $query_args , $column = '__date__' );
|
156 |
+
/* this is a subtle hack since the FROM_UNIXTIME doesn't survive WP_Date_Query
|
157 |
+
* so we use __date__ as a proxy
|
158 |
+
*/
|
159 |
+
$where[] = str_replace( '__date__', 'FROM_UNIXTIME(p.date)', $date_query->get_sql() );
|
160 |
+
}
|
161 |
+
|
162 |
+
$selects = apply_filters( 'wpsc_manage_purchase_logs_selects', implode( ', ', $selects ) );
|
163 |
+
$this->joins = apply_filters( 'wpsc_manage_purchase_logs_joins' , implode( ' ', $joins ) );
|
164 |
+
$this->where = apply_filters( 'wpsc_manage_purchase_logs_where' , implode( ' ', $where ) );
|
165 |
+
|
166 |
+
$limit = ( $this->per_page !== 0 ) ? "LIMIT {$offset}, {$this->per_page}" : '';
|
167 |
+
|
168 |
+
$orderby = empty( $_REQUEST['orderby'] ) ? 'p.id' : 'p.' . $_REQUEST['orderby'];
|
169 |
+
$order = empty( $_REQUEST['order'] ) ? 'DESC' : $_REQUEST['order'];
|
170 |
+
|
171 |
+
$orderby = esc_sql( apply_filters( 'wpsc_manage_purchase_logs_orderby', $orderby ) );
|
172 |
+
$order = esc_sql( $order );
|
173 |
+
|
174 |
+
$purchase_log_sql = apply_filters( 'wpsc_manage_purchase_logs_sql', "
|
175 |
+
SELECT SQL_CALC_FOUND_ROWS {$selects}
|
176 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
|
177 |
+
{$this->joins}
|
178 |
+
WHERE {$this->where}
|
179 |
+
ORDER BY {$orderby} {$order}
|
180 |
+
{$limit}
|
181 |
+
" );
|
182 |
+
|
183 |
+
$this->items = apply_filters( 'wpsc_manage_purchase_logs_items', $wpdb->get_results( $purchase_log_sql ) );
|
184 |
+
if ( $this->per_page ) {
|
185 |
+
$total_items = $wpdb->get_var( "SELECT FOUND_ROWS()" );
|
186 |
+
|
187 |
+
$this->set_pagination_args( array(
|
188 |
+
'total_items' => $total_items,
|
189 |
+
'per_page' => $this->per_page,
|
190 |
+
) );
|
191 |
+
}
|
192 |
+
|
193 |
+
$total_where = apply_filters( 'wpsc_manage_purchase_logs_total_where', $this->where );
|
194 |
+
|
195 |
+
if ( $this->status == 'all' ) {
|
196 |
+
$total_where .= ' AND p.processed IN (3, 4, 5) ';
|
197 |
+
}
|
198 |
+
|
199 |
+
$total_sql = "
|
200 |
+
SELECT SUM(totalprice)
|
201 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
|
202 |
+
{$this->joins}
|
203 |
+
WHERE {$total_where}
|
204 |
+
";
|
205 |
+
|
206 |
+
$this->total_amount = $wpdb->get_var( $total_sql );
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Construct the date queries for pre-defined periods in the Sales Log.
|
211 |
+
*
|
212 |
+
* Supports pre-defined periods for the purchase log, including today, yesterday, this week,
|
213 |
+
* last week, this month, last month, last two months + month to date (this quarter),
|
214 |
+
* prior 3 months, this year, last year. You can insert your own custom periods by filtering
|
215 |
+
* either based on the $period_flag or just filter the final query setup.
|
216 |
+
*
|
217 |
+
* @since 4.0
|
218 |
+
*
|
219 |
+
* @param array $period_flag The period requested from $_REQUEST['m'].
|
220 |
+
*
|
221 |
+
* @return array formatted to pass to WP_Date_Query.
|
222 |
+
*/
|
223 |
+
|
224 |
+
private function assemble_predefined_periods_query( $period_flag ){
|
225 |
+
// warning: period flag is unsanitized user input directly from $_REQUEST - only compare against actual values
|
226 |
+
|
227 |
+
/**
|
228 |
+
* date functions
|
229 |
+
*/
|
230 |
+
$now_string = current_time( 'mysql' );
|
231 |
+
$week_start_end = get_weekstartend( $now_string ); // returns array with start/end
|
232 |
+
$blog_time_zone = get_option( 'timezone_string' );
|
233 |
+
|
234 |
+
if ( empty( $blog_time_zone ) ) {
|
235 |
+
$blog_time_zone = date_default_timezone_get();
|
236 |
+
}
|
237 |
+
|
238 |
+
$timezone = new DateTimeZone( $blog_time_zone );
|
239 |
+
$now = new DateTime( 'now', $timezone );
|
240 |
+
|
241 |
+
// Based on $_REQUEST['m']
|
242 |
+
switch ( $period_flag ) {
|
243 |
+
// Today
|
244 |
+
case 1:
|
245 |
+
$date_query = array(
|
246 |
+
'year' => $now->format( 'Y' ),
|
247 |
+
'monthnum' => $now->format( 'n' ),
|
248 |
+
'day' => $now->format( 'd' )
|
249 |
+
);
|
250 |
+
break;
|
251 |
+
|
252 |
+
// Yesterday
|
253 |
+
case 2:
|
254 |
+
$yesterday = new DateTime( date( 'Y-m-d', strtotime( 'yesterday' ) ), $timezone );
|
255 |
+
$date_query = array(
|
256 |
+
'year' => $yesterday->format( 'Y' ),
|
257 |
+
'monthnum' => $yesterday->format( 'n' ),
|
258 |
+
'day' => $yesterday->format( 'd' )
|
259 |
+
);
|
260 |
+
break;
|
261 |
+
|
262 |
+
// This Week-to-date
|
263 |
+
case 3:
|
264 |
+
$start_of_this_week = new DateTime( date( 'Y-m-d 00:00:00', $week_start_end['start'] ), $timezone );
|
265 |
+
$date_query = array( 'date_query' => array(
|
266 |
+
'after' => $start_of_this_week->format('Y-m-d 00:00:00'),
|
267 |
+
'compare' => '>',
|
268 |
+
'inclusive' => true
|
269 |
+
));
|
270 |
+
break;
|
271 |
+
|
272 |
+
// Last Week
|
273 |
+
case 4:
|
274 |
+
$start_of_last_week = new DateTime( date('Y-m-d 00:00:00', $week_start_end['start'] - ( DAY_IN_SECONDS * 7 ) ), $timezone );
|
275 |
+
$start = $start_of_last_week->format( 'Y-m-d 00:00:00' );
|
276 |
+
$start_of_last_week->modify( '+7 days' );
|
277 |
+
$date_query = array( 'date_query' => array(
|
278 |
+
'after' => $start,
|
279 |
+
'before' => $start_of_last_week->format( 'Y-m-d 00:00:00' ),
|
280 |
+
'inclusive' => false,
|
281 |
+
));
|
282 |
+
break;
|
283 |
+
|
284 |
+
// This Month-to-Date (Same as choosing the explicit month on selector)
|
285 |
+
case 5:
|
286 |
+
$date_query = array(
|
287 |
+
'year' => $now->format('Y'),
|
288 |
+
'monthnum' => $now->format('n'),
|
289 |
+
);
|
290 |
+
break;
|
291 |
+
|
292 |
+
// Last Month (Same as choosing the explicit month on selector)
|
293 |
+
case 6:
|
294 |
+
$now->modify('-1 month');
|
295 |
+
$date_query = array(
|
296 |
+
'year' => $now->format('Y'),
|
297 |
+
'monthnum' => $now->format('n'),
|
298 |
+
);
|
299 |
+
break;
|
300 |
+
|
301 |
+
// This Quarter (last three months inclusive)
|
302 |
+
case 7:
|
303 |
+
$date_query = array('date_query' => array(
|
304 |
+
'after' => 'first day of -2 months' ),
|
305 |
+
'compare' => '>',
|
306 |
+
'inclusive' => true,
|
307 |
+
);
|
308 |
+
|
309 |
+
break;
|
310 |
+
|
311 |
+
// Prior Three Months
|
312 |
+
case 8:
|
313 |
+
$date_query = array( 'date_query' => array(
|
314 |
+
'after' => 'first day of -2 months',
|
315 |
+
'before' => 'last day of -1 month',
|
316 |
+
'inclusive' => true,
|
317 |
+
));
|
318 |
+
break;
|
319 |
+
|
320 |
+
// This Year
|
321 |
+
case 9:
|
322 |
+
$date_query = array( 'date_query' => array(
|
323 |
+
'after' => '1/1 this year',
|
324 |
+
'compare' => '>',
|
325 |
+
'inclusive' => true,
|
326 |
+
));
|
327 |
+
break;
|
328 |
+
|
329 |
+
// Last year
|
330 |
+
case 10:
|
331 |
+
$date_query = array( 'date_query' => array(
|
332 |
+
'after' => '1/1 last year',
|
333 |
+
'before' => '12/31 last year',
|
334 |
+
'inclusive' => true,
|
335 |
+
));
|
336 |
+
break;
|
337 |
+
|
338 |
+
// default - return empty where clause
|
339 |
+
default:
|
340 |
+
/**
|
341 |
+
* Return a custom date query for custom period_flag's.
|
342 |
+
*
|
343 |
+
* This filter extends the functionality allowing for custom periods if a new value
|
344 |
+
* is passed via $_REQUEST['m']. {@see 'purchase_log_special_periods'}.
|
345 |
+
*
|
346 |
+
* @since 4.1.0
|
347 |
+
*
|
348 |
+
* @param array Empty array to be filled with a valid query {@see WP_Date_Query}.
|
349 |
+
*/
|
350 |
+
$date_query = apply_filters( 'wpsc_purchase_log_predefined_periods_' . $period_flag, array() );
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Filter the parsed date query.
|
355 |
+
*
|
356 |
+
* This filter can be used to override the constructed date_query.
|
357 |
+
*
|
358 |
+
* @since 4.1.0
|
359 |
+
*
|
360 |
+
* @param array $date_query Empty array to be filled with a valid date query {@see WP_Date_Query}
|
361 |
+
* @param string $period_flag Value passed from $_REQUEST['m'].
|
362 |
+
*/
|
363 |
+
return apply_filters( 'wpsc_purchase_log_predefined_periods', $date_query, $period_flag );
|
364 |
+
}
|
365 |
+
|
366 |
+
public function set_date_column_to_date( $columns ){
|
367 |
+
|
368 |
+
$columns[] = '__date__';
|
369 |
+
return $columns;
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
public function is_pagination_enabled() {
|
374 |
+
return $this->per_page !== 0;
|
375 |
+
}
|
376 |
+
|
377 |
+
public function is_sortable() {
|
378 |
+
return $this->sortable;
|
379 |
+
}
|
380 |
+
|
381 |
+
public function is_views_enabled() {
|
382 |
+
return $this->views;
|
383 |
+
}
|
384 |
+
|
385 |
+
public function is_search_box_enabled() {
|
386 |
+
return $this->search_box;
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Define the columns in our list table. You can add/amend this list using
|
391 |
+
* WordPress core filter manage_{screen}_columns, specifically
|
392 |
+
* manage_dashboard_page_wpsc-purchase-logs_columns.
|
393 |
+
*
|
394 |
+
* @return array[string]string List of column headings
|
395 |
+
*/
|
396 |
+
public function get_columns() {
|
397 |
+
return array(
|
398 |
+
'cb' => '<input type="checkbox" />',
|
399 |
+
'id' => __( 'Order ID', 'wp-e-commerce' ),
|
400 |
+
'customer' => __( 'Customer', 'wp-e-commerce' ),
|
401 |
+
'amount' => __( 'Amount', 'wp-e-commerce' ),
|
402 |
+
'status' => _x( 'Status', 'sales log list table column', 'wp-e-commerce' ),
|
403 |
+
'date' => __( 'Date', 'wp-e-commerce' ),
|
404 |
+
'tracking' => _x( 'Tracking ID', 'purchase log', 'wp-e-commerce' ),
|
405 |
+
) ;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Define the columns in the table which are sortable. You can add/amend
|
410 |
+
* this list using the WordPress core filter manage_{screen}_sortable_columns
|
411 |
+
* Specifically: manage_dashboard_page_wpsc-purchase-logs_sortable_columns
|
412 |
+
*
|
413 |
+
* @return array[string]string List of sortable column IDs and corresponding db column of the item
|
414 |
+
*/
|
415 |
+
public function get_sortable_columns() {
|
416 |
+
if ( ! $this->sortable )
|
417 |
+
return array();
|
418 |
+
|
419 |
+
return array(
|
420 |
+
'date' => 'id',
|
421 |
+
'status' => 'processed',
|
422 |
+
'amount' => 'totalprice',
|
423 |
+
) ;
|
424 |
+
}
|
425 |
+
|
426 |
+
private function get_months() {
|
427 |
+
global $wpdb;
|
428 |
+
|
429 |
+
// "date" column is not indexed. Might be better to use transient just in case
|
430 |
+
// there are lots of logs
|
431 |
+
$today = getdate();
|
432 |
+
$transient_key = 'wpsc_purchase_logs_months_' . $today['year'] . $today['month'];
|
433 |
+
/* if ( $months = get_transient( $transient_key ) )
|
434 |
+
return $months; */
|
435 |
+
|
436 |
+
$sql = "
|
437 |
+
SELECT DISTINCT YEAR(FROM_UNIXTIME(date)) AS year, MONTH(FROM_UNIXTIME(date)) AS month
|
438 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . " AS p
|
439 |
+
{$this->joins}
|
440 |
+
WHERE {$this->where_no_filter}
|
441 |
+
ORDER BY date DESC
|
442 |
+
";
|
443 |
+
|
444 |
+
$months = $wpdb->get_results( $sql );
|
445 |
+
set_transient( $transient_key, $months, 60 * 24 * 7 );
|
446 |
+
return $months;
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Get an array of the untranslated, base view labels for the purchase log statuses.
|
451 |
+
*
|
452 |
+
* @return array The untranslated, base view label for each status.
|
453 |
+
*/
|
454 |
+
private function get_status_view_labels() {
|
455 |
+
|
456 |
+
global $wpsc_purchlog_statuses;
|
457 |
+
|
458 |
+
$view_labels = array();
|
459 |
+
foreach ( $wpsc_purchlog_statuses as $status ) {
|
460 |
+
if ( ! empty( $status['view_label'] ) ) {
|
461 |
+
// The status provides a view label i18n _nx_noop-able object.
|
462 |
+
$view_labels[$status['order']]['view_label'] = $status['view_label'];
|
463 |
+
} else {
|
464 |
+
// The status doesn't provide a view label i18n string. Use a generic one.
|
465 |
+
$view_labels[$status['order']]['view_label'] = _nx_noop(
|
466 |
+
'%s <span class="count">(%d)</span>',
|
467 |
+
'%s <span class="count">(%d)</span>',
|
468 |
+
'Purchase log view links for custom status with no explicit translation.',
|
469 |
+
'wp-e-commerce'
|
470 |
+
);
|
471 |
+
$view_labels[$status['order']]['label'] = $status['label'];
|
472 |
+
}
|
473 |
+
}
|
474 |
+
return $view_labels;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Returns a list of the purchase logs indexed on status number. Also includes a grand total
|
479 |
+
* indexed as 'all'.
|
480 |
+
*
|
481 |
+
* @return array An array indexed on status number giving the count of purchase logs in that status.
|
482 |
+
*/
|
483 |
+
private function get_per_status_counts() {
|
484 |
+
|
485 |
+
global $wpdb;
|
486 |
+
|
487 |
+
$sql = 'SELECT DISTINCT processed, COUNT(*) AS count FROM ' . WPSC_TABLE_PURCHASE_LOGS . ' GROUP BY processed ORDER BY processed';
|
488 |
+
$results = $wpdb->get_results( $sql );
|
489 |
+
$statuses = array(
|
490 |
+
'all' => 0,
|
491 |
+
);
|
492 |
+
|
493 |
+
if ( ! empty( $results ) ) {
|
494 |
+
foreach ( $results as $status ) {
|
495 |
+
$statuses[$status->processed] = $status->count;
|
496 |
+
$statuses['all'] += $status->count;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
return $statuses;
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Get the sub-views of the list table.
|
504 |
+
*
|
505 |
+
* Allows user to limit the list to orders in a particular status.
|
506 |
+
*
|
507 |
+
* @return array The available view links.
|
508 |
+
*/
|
509 |
+
public function get_views() {
|
510 |
+
|
511 |
+
$view_labels = $this->get_status_view_labels();
|
512 |
+
$statuses = $this->get_per_status_counts();
|
513 |
+
|
514 |
+
$all_text = sprintf(
|
515 |
+
_nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $statuses['all'], 'purchase logs', 'wp-e-commerce' ),
|
516 |
+
number_format_i18n( $statuses['all'] )
|
517 |
+
);
|
518 |
+
|
519 |
+
$all_href = remove_query_arg( array(
|
520 |
+
'status',
|
521 |
+
'paged',
|
522 |
+
'action',
|
523 |
+
'action2',
|
524 |
+
'm',
|
525 |
+
'deleted',
|
526 |
+
'updated',
|
527 |
+
'paged',
|
528 |
+
's',
|
529 |
+
) );
|
530 |
+
$all_class = ( $this->status == 'all' && empty( $_REQUEST['m'] ) && empty( $_REQUEST['s'] ) ) ? 'class="current"' : '';
|
531 |
+
$views = array(
|
532 |
+
'all' => sprintf(
|
533 |
+
'<a href="%s" %s>%s</a>',
|
534 |
+
esc_url( $all_href ),
|
535 |
+
$all_class,
|
536 |
+
$all_text
|
537 |
+
),
|
538 |
+
);
|
539 |
+
|
540 |
+
foreach ( $statuses as $status => $count ) {
|
541 |
+
if ( ! isset( $view_labels[$status] ) ) {
|
542 |
+
continue;
|
543 |
+
}
|
544 |
+
if ( empty( $view_labels[$status]['label'] ) ) {
|
545 |
+
// This translation needs only the quantity dropping in.
|
546 |
+
$text = sprintf(
|
547 |
+
translate_nooped_plural( $view_labels[$status]['view_label'], $count, 'wp-e-commerce' ),
|
548 |
+
number_format_i18n( $count )
|
549 |
+
);
|
550 |
+
} else {
|
551 |
+
// This translation needs the status label, and quantity dropping in.
|
552 |
+
$text = sprintf(
|
553 |
+
translate_nooped_plural( $view_labels[$status]['view_label'], $count, 'wp-e-commerce' ),
|
554 |
+
$view_labels[$status]['label'],
|
555 |
+
number_format_i18n( $count )
|
556 |
+
);
|
557 |
+
}
|
558 |
+
$href = add_query_arg( 'status', $status );
|
559 |
+
$href = remove_query_arg( array(
|
560 |
+
'deleted',
|
561 |
+
'updated',
|
562 |
+
'action',
|
563 |
+
'action2',
|
564 |
+
'm',
|
565 |
+
'paged',
|
566 |
+
's',
|
567 |
+
), $href );
|
568 |
+
$class = ( $this->status == $status ) ? 'class="current"' : '';
|
569 |
+
$views[$status] = sprintf(
|
570 |
+
'<a href="%s" %s>%s</a>',
|
571 |
+
esc_url( $href ),
|
572 |
+
$class,
|
573 |
+
$text
|
574 |
+
);
|
575 |
+
}
|
576 |
+
|
577 |
+
return $views;
|
578 |
+
}
|
579 |
+
|
580 |
+
public function months_dropdown( $post_type = '' ) {
|
581 |
+
global $wp_locale;
|
582 |
+
|
583 |
+
$m = isset( $_REQUEST['m'] ) ? $_REQUEST['m'] : 0;
|
584 |
+
|
585 |
+
if ( ! $this->month_filter ) {
|
586 |
+
if ( $m !== 0 )
|
587 |
+
echo '<input type="hidden" name="m" value="' . esc_attr( $m ) . '" />';
|
588 |
+
|
589 |
+
return false;
|
590 |
+
}
|
591 |
+
|
592 |
+
$months = $this->get_months();
|
593 |
+
if ( ! empty( $months ) ) {
|
594 |
+
?>
|
595 |
+
<select name="m">
|
596 |
+
<option <?php selected( 0, $m ); ?> value="0"><?php _e( 'Show all dates', 'wp-e-commerce' ); ?></option>
|
597 |
+
<?php
|
598 |
+
|
599 |
+
$this->special_periods( $m );
|
600 |
+
|
601 |
+
foreach ( $months as $arc_row ) {
|
602 |
+
$month = zeroise( $arc_row->month, 2 );
|
603 |
+
$year = $arc_row->year;
|
604 |
+
|
605 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
606 |
+
selected( $arc_row->year . $month, $m, false ),
|
607 |
+
esc_attr( $arc_row->year . $month ),
|
608 |
+
$wp_locale->get_month( $month ) . ' ' . $year
|
609 |
+
);
|
610 |
+
}
|
611 |
+
?>
|
612 |
+
</select>
|
613 |
+
<?php
|
614 |
+
submit_button( _x( 'Filter', 'extra navigation in purchase log page', 'wp-e-commerce' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
|
615 |
+
|
616 |
+
}
|
617 |
+
}
|
618 |
+
|
619 |
+
/**
|
620 |
+
* Outputs the pre-defined selectable periods.
|
621 |
+
*
|
622 |
+
* Inserts new predefined periods into the period filter select on sales log screen.
|
623 |
+
*
|
624 |
+
* @since 4.1.0
|
625 |
+
*
|
626 |
+
* @param string $selected The value of $_REQUEST['m'] - unsanitized.
|
627 |
+
*/
|
628 |
+
private function special_periods( $selected ){
|
629 |
+
|
630 |
+
/**
|
631 |
+
* Filter the available special periods on the purchase log listing screen.
|
632 |
+
*
|
633 |
+
* Can Used to remove periods or add new period definitions {@see wpsc_purchase_log_predefined_periods_}
|
634 |
+
*
|
635 |
+
* @since 4.1.0
|
636 |
+
*
|
637 |
+
* @param array array() The periods currently defined.
|
638 |
+
*/
|
639 |
+
$periods = apply_filters( 'wpsc_purchase_log_special_periods', array(
|
640 |
+
1 => _x('Today', 'time period for the current day', 'wp-e-commerce'),
|
641 |
+
2 => _x('Yesterday', 'time period for the previous day', 'wp-e-commerce'),
|
642 |
+
3 => _x('This Week', 'time period for the current week', 'wp-e-commerce'),
|
643 |
+
4 => _x('Last Week', 'time period for the prior week', 'wp-e-commerce'),
|
644 |
+
5 => _x('This Month', 'time period for the current month to date', 'wp-e-commerce'),
|
645 |
+
6 => _x('Last Month', 'time period for the prior month', 'wp-e-commerce'),
|
646 |
+
7 => _x('This Quarter', 'time period for the prior two months plus this month-to-date', 'wp-e-commerce'),
|
647 |
+
8 => _x('Prior 3 Months', 'time period for the three months prior to the current month', 'wp-e-commerce'),
|
648 |
+
9 => _x('This Year', 'time period for the current year to date', 'wp-e-commerce'),
|
649 |
+
10 => _x('Last Year', 'time period for the prior year', 'wp-e-commerce'),
|
650 |
+
) );
|
651 |
+
|
652 |
+
echo '<option disabled="disabled">---------</option>';
|
653 |
+
foreach( $periods as $value => $label ){
|
654 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
655 |
+
selected( $value, $selected, false ),
|
656 |
+
esc_attr( $value ),
|
657 |
+
esc_html( $label )
|
658 |
+
);
|
659 |
+
}
|
660 |
+
echo '<option disabled="disabled">---------</option>';
|
661 |
+
|
662 |
+
}
|
663 |
+
|
664 |
+
public function extra_tablenav( $which ) {
|
665 |
+
if ( 'top' == $which ) {
|
666 |
+
echo '<div class="alignleft actions">';
|
667 |
+
$this->months_dropdown();
|
668 |
+
do_action( 'wpsc_sales_log_extra_tablenav' );
|
669 |
+
echo '</div>';
|
670 |
+
}
|
671 |
+
}
|
672 |
+
|
673 |
+
public function pagination( $which ) {
|
674 |
+
ob_start();
|
675 |
+
parent::pagination( $which );
|
676 |
+
$output = ob_get_clean();
|
677 |
+
if ( $this->status == 'all' )
|
678 |
+
$string = _x( 'Total (excluding Incomplete and Declined): %s', 'sales log page total', 'wp-e-commerce' );
|
679 |
+
else
|
680 |
+
$string = _x( 'Total: %s', 'sales log page total', 'wp-e-commerce' );
|
681 |
+
$total_amount = ' - ' . sprintf( $string, wpsc_currency_display( $this->total_amount ) );
|
682 |
+
$total_amount = str_replace( '$', '\$', $total_amount );
|
683 |
+
$output = preg_replace( '/(<span class="displaying-num">)([^<]+)(<\/span>)/', '${1}${2}' . ' ' . $total_amount . '${3}', $output );
|
684 |
+
|
685 |
+
echo $output;
|
686 |
+
}
|
687 |
+
|
688 |
+
public function column_cb( $item ){
|
689 |
+
$checked = isset( $_REQUEST['post'] ) ? checked( in_array( $item->id, $_REQUEST['post'] ), true, false ) : '';
|
690 |
+
return sprintf(
|
691 |
+
'<input type="checkbox" ' . $checked . ' name="%1$s[]" value="%2$s" />',
|
692 |
+
/*$1%s*/ 'post',
|
693 |
+
/*$2%s*/ $item->id
|
694 |
+
);
|
695 |
+
}
|
696 |
+
|
697 |
+
private function item_url( $item ) {
|
698 |
+
$location = remove_query_arg( array(
|
699 |
+
'paged',
|
700 |
+
'order',
|
701 |
+
'orderby',
|
702 |
+
's',
|
703 |
+
'updated',
|
704 |
+
'deleted',
|
705 |
+
) );
|
706 |
+
$location = add_query_arg( array(
|
707 |
+
'c' => 'item_details',
|
708 |
+
'id' => $item->id,
|
709 |
+
), $location );
|
710 |
+
return $location;
|
711 |
+
}
|
712 |
+
|
713 |
+
public function column_customer( $item ) {
|
714 |
+
|
715 |
+
$name = '';
|
716 |
+
|
717 |
+
if ( isset( $item->firstname ) ) {
|
718 |
+
$name .= $item->firstname;
|
719 |
+
}
|
720 |
+
|
721 |
+
if ( isset( $item->lastname ) ) {
|
722 |
+
$name .= ' ' . $item->lastname;
|
723 |
+
}
|
724 |
+
|
725 |
+
$name = trim( $name );
|
726 |
+
|
727 |
+
if ( empty( $name ) ) {
|
728 |
+
$name = apply_filters( 'wpsc_purchase_log_list_no_name', __( 'No name provided', 'wp-e-commerce' ), $item );
|
729 |
+
}
|
730 |
+
|
731 |
+
|
732 |
+
?>
|
733 |
+
<strong>
|
734 |
+
<a class="row-title" href="<?php echo esc_url( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wp-e-commerce' ) ?>"><?php echo esc_html( $name ); ?></a>
|
735 |
+
</strong><br />
|
736 |
+
|
737 |
+
<?php if ( isset( $item->email ) ) : ?>
|
738 |
+
<small><?php echo make_clickable( $item->email ); ?></small>
|
739 |
+
<?php endif; ?>
|
740 |
+
<?php
|
741 |
+
}
|
742 |
+
|
743 |
+
private function delete_url( $item ) {
|
744 |
+
$nonce = wp_create_nonce( 'bulk-' . $this->_args['plural'] );
|
745 |
+
$location = add_query_arg( array(
|
746 |
+
'_wpnonce' => $nonce,
|
747 |
+
'_wp_http_referer' => urlencode( $_SERVER['REQUEST_URI'] ),
|
748 |
+
'action' => 'delete',
|
749 |
+
urlencode( 'post[]' ) => $item->id,
|
750 |
+
) );
|
751 |
+
$location = remove_query_arg( array(
|
752 |
+
'updated',
|
753 |
+
'deleted',
|
754 |
+
), $location );
|
755 |
+
return $location;
|
756 |
+
}
|
757 |
+
|
758 |
+
public function column_id( $item ) {
|
759 |
+
?>
|
760 |
+
<a href="<?php echo esc_url( $this->item_url( $item ) ); ?>" title="<?php esc_attr_e( 'View order details', 'wp-e-commerce' ) ?>"><?php echo esc_html( $item->id ); ?></a>
|
761 |
+
<?php if ( ! $this->current_action() == 'delete' ): ?>
|
762 |
+
<br />
|
763 |
+
<small><a class="delete" href="<?php echo esc_url( $this->delete_url( $item ) ); ?>"><?php echo esc_html_x( 'Delete', 'Sales log page', 'wp-e-commerce' ); ?></a></small>
|
764 |
+
<?php endif ?>
|
765 |
+
<?php
|
766 |
+
}
|
767 |
+
|
768 |
+
public function column_date( $item ) {
|
769 |
+
$format = _x( 'Y/m/d g:i:s A', 'default date format for purchase log columns', 'wp-e-commerce' );
|
770 |
+
$timestamp = (int) $item->date;
|
771 |
+
$full_time = date( $format, $timestamp );
|
772 |
+
$time_diff = time() - $timestamp;
|
773 |
+
if ( $time_diff > 0 && $time_diff < 24 * 60 * 60 )
|
774 |
+
$h_time = $h_time = sprintf( __( '%s ago', 'wp-e-commerce' ), human_time_diff( $timestamp ) );
|
775 |
+
else
|
776 |
+
$h_time = date( get_option( 'date_format', 'Y/m/d' ), $timestamp );
|
777 |
+
|
778 |
+
echo '<abbr title="' . esc_attr( $full_time ) . '">' . esc_html( $h_time ) . '</abbr>';
|
779 |
+
}
|
780 |
+
|
781 |
+
public function column_amount( $item ) {
|
782 |
+
echo '<a href="' . esc_attr( $this->item_url( $item ) ) . '" title="' . esc_attr__( 'View order details', 'wp-e-commerce' ) . '">';
|
783 |
+
echo wpsc_currency_display( $item->amount ) . "<br />";
|
784 |
+
echo '<small>' . sprintf( _n( '1 item', '%s items', $item->item_count, 'wp-e-commerce' ), number_format_i18n( $item->item_count ) ) . '</small>';
|
785 |
+
echo '</a>';
|
786 |
+
}
|
787 |
+
|
788 |
+
public function column_default( $item, $column_name ) {
|
789 |
+
$default = isset( $item->$column_name ) ? $item->$column_name : '';
|
790 |
+
$output = apply_filters( 'wpsc_manage_purchase_logs_custom_column', $default, $column_name, $item );
|
791 |
+
return $output;
|
792 |
+
}
|
793 |
+
|
794 |
+
public function column_status( $item ) {
|
795 |
+
global $wpsc_purchlog_statuses;
|
796 |
+
$dropdown_options = '';
|
797 |
+
$current_status = false;
|
798 |
+
foreach ( $wpsc_purchlog_statuses as $status ) {
|
799 |
+
$selected = '';
|
800 |
+
if ( $status['order'] == $item->status ) {
|
801 |
+
$current_status = esc_html( $status['label'] );
|
802 |
+
$selected = 'selected="selected"';
|
803 |
+
}
|
804 |
+
$dropdown_options .= '<option value="' . esc_attr( $status['order'] ) . '" ' . $selected . '>' . esc_html( $status['label'] ) . '</option>';
|
805 |
+
}
|
806 |
+
|
807 |
+
echo '<span>' . $current_status . '</span>';
|
808 |
+
echo '<select class="wpsc-purchase-log-status" data-log-id="' . $item->id . '">';
|
809 |
+
echo $dropdown_options;
|
810 |
+
echo '</select>';
|
811 |
+
echo '<img src="' . esc_url( wpsc_get_ajax_spinner() ) . '" class="ajax-feedback" title="" alt="" />';
|
812 |
+
}
|
813 |
+
|
814 |
+
public function column_tracking( $item ) {
|
815 |
+
$classes = array( 'wpsc-purchase-log-tracking-id' );
|
816 |
+
$empty = empty( $item->track_id );
|
817 |
+
?>
|
818 |
+
<div data-log-id="<?php echo esc_attr( $item->id ); ?>" <?php echo $empty ? ' class="empty"' : ''; ?>>
|
819 |
+
<a class="add" href="#"><?php echo esc_html_x( 'Add Tracking ID', 'add purchase log tracking id', 'wp-e-commerce' ); ?></a>
|
820 |
+
<input type="text" class="wpsc-purchase-log-tracking-id" value="<?php echo esc_attr( $item->track_id ); ?>" />
|
821 |
+
<a class="button save" href="#"><?php echo esc_html_x( 'Save', 'save sales log tracking id', 'wp-e-commerce' ); ?></a>
|
822 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" /><br class="clear" />
|
823 |
+
<small class="send-email"><a href="#"><?php echo esc_html_x( 'Send Email', 'sales log', 'wp-e-commerce' ); ?></a></small>
|
824 |
+
</div>
|
825 |
+
<?php
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Provide bulk actions for sales logs.
|
830 |
+
*
|
831 |
+
* Generates bulk actions for standard order statuses. Also generates a "delete" bulk action,
|
832 |
+
* and actions for any additional statuses that have been registered via the
|
833 |
+
* wpsc_set_purchlog_statuses filter.
|
834 |
+
*
|
835 |
+
* @return array Array of bulk actions available.
|
836 |
+
*/
|
837 |
+
public function get_bulk_actions() {
|
838 |
+
|
839 |
+
global $wpsc_purchlog_statuses;
|
840 |
+
|
841 |
+
if ( ! $this->bulk_actions ) {
|
842 |
+
return array();
|
843 |
+
}
|
844 |
+
|
845 |
+
// Standard actions.
|
846 |
+
$actions = array(
|
847 |
+
'delete' => _x( 'Delete', 'bulk action', 'wp-e-commerce' ),
|
848 |
+
);
|
849 |
+
|
850 |
+
// Loop through all statuses and register bulk actions for them.
|
851 |
+
foreach ( $wpsc_purchlog_statuses as $status ) {
|
852 |
+
$actions[$status['order']] = $status['label'];
|
853 |
+
}
|
854 |
+
|
855 |
+
/**
|
856 |
+
* Filter the available bulk actions on the purchase log listing screen.
|
857 |
+
*
|
858 |
+
* @since 4.0
|
859 |
+
*
|
860 |
+
* @param array $actions The bulk actions currently defined.
|
861 |
+
*/
|
862 |
+
return apply_filters( 'wpsc_manage_purchase_logs_bulk_actions', $actions );
|
863 |
+
}
|
864 |
+
|
865 |
+
public function search_box( $text, $input_id ) {
|
866 |
+
if ( ! $this->search_box ) {
|
867 |
+
return '';
|
868 |
+
}
|
869 |
+
|
870 |
+
parent::search_box( $text, $input_id );
|
871 |
+
}
|
872 |
+
}
|
trunk/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?', 'wp-e-commerce' ); ?><br />
|
3 |
+
</h3>
|
4 |
+
<div>
|
5 |
+
<a href="<?php echo esc_url( wp_get_referer() ); ?>" class="button"><?php esc_html_e( 'Go Back', 'wp-e-commerce' ); ?></a>
|
6 |
+
<input class="button-primary" type="submit" value="<?php esc_attr_e( 'Delete', 'wp-e-commerce' ); ?>" />
|
7 |
+
<input type="hidden" name="confirm" value="1" />
|
8 |
+
<input type="hidden" name="action" value="delete" />
|
9 |
+
</div>
|
trunk/wpsc-admin/includes/purchase-logs-page/item-details.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="poststuff">
|
2 |
+
<h2 class="log-details-title-area">
|
3 |
+
<span class="log-title-details">
|
4 |
+
<?php esc_html_e( 'Sales Log Details', 'wp-e-commerce' ); ?>
|
5 |
+
<span class="subtitle">#<?php echo $this->log_id; ?> – <?php echo wpsc_purchaselog_details_date_time(); ?></span>
|
6 |
+
</span>
|
7 |
+
<?php $this->purchase_logs_pagination() ?>
|
8 |
+
</h2>
|
9 |
+
<?php if ( $receipt_sent ): ?>
|
10 |
+
<div class="updated">
|
11 |
+
<p><?php esc_html_e( 'Receipt has been resent successfully.', 'wp-e-commerce' ); ?></p>
|
12 |
+
</div>
|
13 |
+
<?php elseif ( $receipt_not_sent ) : ?>
|
14 |
+
<div class="error">
|
15 |
+
<p><?php esc_html_e( 'Receipt could not be sent to buyer. Please contact your hosting service and make sure your server can send emails.', 'wp-e-commerce' ); ?></p>
|
16 |
+
</div>
|
17 |
+
<?php endif; ?>
|
18 |
+
|
19 |
+
<?php do_action( 'wpsc_purchlog_before_metaboxes', $this->log_id ); ?>
|
20 |
+
|
21 |
+
<div id="post-body">
|
22 |
+
<?php if ( wpsc_has_purchlog_shipping() ): ?>
|
23 |
+
<?php do_action( 'wpsc_shipping_details_top', $this->log_id ); ?>
|
24 |
+
<div id="wpsc_shipping_details_box" class="log-details-box">
|
25 |
+
<h3>
|
26 |
+
<?php esc_html_e( 'Shipping Address', 'wp-e-commerce' ); ?>
|
27 |
+
<?php if ( $this->can_edit ) : ?>
|
28 |
+
<a class="edit-log-details edit-shipping-details" href="#edit-shipping-address"><?php _e( 'Edit', 'wp-e-commerce' ); ?></a>
|
29 |
+
<?php endif; ?>
|
30 |
+
</h3>
|
31 |
+
<blockquote id="wpsc-shipping-details">
|
32 |
+
<?php self::shipping_address_output(); ?>
|
33 |
+
</blockquote>
|
34 |
+
|
35 |
+
<h4><?php esc_html_e( 'Shipping Details', 'wp-e-commerce' ); ?></h4>
|
36 |
+
<blockquote>
|
37 |
+
<strong><?php esc_html_e( 'Shipping Method:', 'wp-e-commerce' ); ?></strong> <?php echo wpsc_display_purchlog_shipping_method(); ?><br />
|
38 |
+
<strong><?php esc_html_e( 'Shipping Option:', 'wp-e-commerce' ); ?></strong> <?php echo wpsc_display_purchlog_shipping_option(); ?><br />
|
39 |
+
<?php $purchase_weight = wpsc_purchlogs_get_weight_text(); ?>
|
40 |
+
<?php if ( ! empty( $purchase_weight ) ) { ?>
|
41 |
+
<strong><?php esc_html_e( 'Purchase Weight:', 'wp-e-commerce' ); ?></strong> <?php echo $purchase_weight; ?><br />
|
42 |
+
<?php } ?>
|
43 |
+
<?php if ( wpsc_purchlogs_has_tracking() ) { ?>
|
44 |
+
<strong><?php echo esc_html_x( 'Tracking ID:', 'purchase log', 'wp-e-commerce' ); ?></strong> <?php echo wpsc_purchlogitem_trackid(); ?><br />
|
45 |
+
|
46 |
+
<?php $tracking_status = wpsc_purchlogitem_trackstatus(); ?>
|
47 |
+
<?php if ( ! empty ( $tracking_status ) ) { ?>
|
48 |
+
<strong><?php esc_html_e( 'Shipping Status:', 'wp-e-commerce' ); ?></strong> <?php echo $tracking_status ?><br />
|
49 |
+
<?php } ?>
|
50 |
+
|
51 |
+
<?php $tracking_history = wpsc_purchlogitem_trackhistory(); ?>
|
52 |
+
<?php if ( ! empty ( $tracking_history ) ) { ?>
|
53 |
+
<strong><?php esc_html_e( 'Track History:', 'wp-e-commerce' ); ?></strong> <?php echo $tracking_history; ?><br />
|
54 |
+
<?php } ?>
|
55 |
+
|
56 |
+
<?php } ?>
|
57 |
+
</blockquote>
|
58 |
+
<?php do_action( 'wpsc_shipping_details_bottom', $this->log_id ); ?>
|
59 |
+
</div>
|
60 |
+
<?php endif ?>
|
61 |
+
|
62 |
+
<div id="wpsc_billing_details_box" class="log-details-box">
|
63 |
+
<?php do_action( 'wpsc_billing_details_top', $this->log_id ); ?>
|
64 |
+
<h3>
|
65 |
+
<?php esc_html_e( 'Billing Details', 'wp-e-commerce' ); ?>
|
66 |
+
<?php if ( $this->can_edit ) : ?>
|
67 |
+
<a class="edit-log-details edit-billing-details" href="#edit-billing-address"><?php _e( 'Edit', 'wp-e-commerce' ); ?></a>
|
68 |
+
<?php endif; ?>
|
69 |
+
</h3>
|
70 |
+
<blockquote id="wpsc-billing-details">
|
71 |
+
<?php self::billing_address_output(); ?>
|
72 |
+
</blockquote>
|
73 |
+
<h4><?php esc_html_e( 'Payment Details', 'wp-e-commerce' ); ?></h4>
|
74 |
+
<blockquote id="wpsc-payment-details">
|
75 |
+
<?php self::payment_details_output(); ?>
|
76 |
+
</blockquote>
|
77 |
+
<?php do_action( 'wpsc_billing_details_bottom', $this->log_id ); ?>
|
78 |
+
</div>
|
79 |
+
|
80 |
+
<?php if ( $this->can_edit ) : ?>
|
81 |
+
<div class="wpsc-controller postbox" id="edit-shipping-billing" style="display:none;">
|
82 |
+
<?php $this->edit_contact_details_form(); ?>
|
83 |
+
</div>
|
84 |
+
<?php endif; ?>
|
85 |
+
|
86 |
+
<?php do_meta_boxes( get_current_screen()->id, 'normal', $this->log ); ?>
|
87 |
+
|
88 |
+
<?php do_meta_boxes( get_current_screen()->id, 'low', $this->log ); ?>
|
89 |
+
</div>
|
90 |
+
|
91 |
+
|
92 |
+
<div id="wpsc_purchlogitems_links">
|
93 |
+
<h3><?php esc_html_e( 'Actions', 'wp-e-commerce' ); ?></h3>
|
94 |
+
<?php do_action( 'wpsc_purchlogitem_links_start' ); ?>
|
95 |
+
<ul>
|
96 |
+
<?php
|
97 |
+
require_once( WPSC_FILE_PATH . '/wpsc-admin/includes/purchase-log-action-links.php' );
|
98 |
+
$action_links = new WPSC_Purchase_Log_Action_Links( $this->log_id );
|
99 |
+
$action_links->display_link_list_items();
|
100 |
+
?>
|
101 |
+
</ul>
|
102 |
+
</div>
|
103 |
+
|
104 |
+
</div>
|
105 |
+
|
106 |
+
<script type="text/html" id="tmpl-wpsc-found-products">
|
107 |
+
<table class="widefat"><thead><tr><th class="found-radio"><br /></th><th><?php esc_html_e( 'Title', 'wp-e-commerce' ); ?></th><th class="no-break"><?php esc_html_e( 'Date', 'wp-e-commerce' ); ?></th><th class="no-break"><?php esc_html_e( 'Status', 'wp-e-commerce' ); ?></th></tr></thead><tbody></tbody></table>
|
108 |
+
</script>
|
109 |
+
|
110 |
+
<script type="text/html" id="tmpl-wpsc-found-product-rows">
|
111 |
+
<# _.each( data.posts, function( post ) { #>
|
112 |
+
<tr class="found-posts {{ post.class }}">
|
113 |
+
<td class="found-radio"><input type="checkbox" id="found-{{ post.ID }}" name="found_post_id" value="{{ post.ID }}"></td>
|
114 |
+
<td><label for="found-{{ post.ID }}">{{ post.title }}</label></td><td class="no-break">{{ post.time }}</td><td class="no-break">{{ post.status }}</td>
|
115 |
+
</tr>
|
116 |
+
<#} ); #>
|
117 |
+
</script>
|
trunk/wpsc-admin/includes/purchase-logs-page/list-table.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<div id="icon-users" class="icon32"><br/></div>
|
3 |
+
<h2>
|
4 |
+
<?php esc_html_e( 'Sales Log', 'wp-e-commerce' ); ?>
|
5 |
+
|
6 |
+
<?php
|
7 |
+
if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
|
8 |
+
printf( '<span class="subtitle">' . __( 'Search results for “%s”', 'wp-e-commerce' ) . '</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'], 'wp-e-commerce' ), number_format_i18n( $_REQUEST['updated'] ) );
|
17 |
+
?>
|
18 |
+
<?php
|
19 |
+
if ( ! empty( $_REQUEST['deleted'] ) )
|
20 |
+
printf( _n( '%s item deleted.', '%s items deleted.', $_REQUEST['deleted'], 'wp-e-commerce' ), 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 eCommerce 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>', 'wp-e-commerce' ), esc_url( 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 eCommerce %s. Please <a href="%s">click here</a> to fix this problem.', 'wp-e-commerce' ), WPSC_VERSION, esc_url( 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', 'wp-e-commerce' ), '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 |
+
<p>
|
78 |
+
<a class='admin_download' href='<?php echo esc_url( add_query_arg( 'action', 'download_csv' ) ); ?>' >
|
79 |
+
<img class='wpsc_pushdown_img' src='<?php echo WPSC_CORE_IMAGES_URL; ?>/download.gif' alt='' title='' />
|
80 |
+
<span><?php _e( 'Download CSV', 'wp-e-commerce' ); ?></span>
|
81 |
+
</a>
|
82 |
+
</p>
|
83 |
+
</div>
|
trunk/wpsc-admin/includes/purchase-logs-page/packing-slip.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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', 'wp-e-commerce' ), $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', 'wp-e-commerce' ), $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', 'wp-e-commerce' ); ?></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', 'wp-e-commerce' ); ?></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', 'wp-e-commerce' ); ?></th>
|
104 |
+
<th><?php echo esc_html_x( 'Order ID', 'packing slip', 'wp-e-commerce' ); ?></th>
|
105 |
+
<th><?php echo esc_html_x( 'Shipping Method', 'packing slip', 'wp-e-commerce' ); ?></th>
|
106 |
+
<th><?php echo esc_html_x( 'Payment Method', 'packing slip', 'wp-e-commerce' ); ?></th>
|
107 |
+
<?php wpsc_purchaselog_order_summary_headers(); ?>
|
108 |
+
</tr>
|
109 |
+
</thead>
|
110 |
+
<tbody>
|
111 |
+
<tr>
|
112 |
+
<td><?php echo wpsc_purchaselog_details_date(); ?></td>
|
113 |
+
<td><?php echo wpsc_purchaselog_details_purchnumber(); ?></td>
|
114 |
+
<td><?php echo wpsc_display_purchlog_shipping_method(); ?></td>
|
115 |
+
<td><?php echo wpsc_display_purchlog_paymentmethod(); ?></td>
|
116 |
+
<?php wpsc_purchaselog_order_summary(); ?>
|
117 |
+
</tr>
|
118 |
+
</tbody>
|
119 |
+
</table>
|
120 |
+
<table id="cart-items" class="widefat" cellspacing="0">
|
121 |
+
<thead>
|
122 |
+
<tr>
|
123 |
+
<?php print_column_headers( 'wpsc_purchase_log_item_details' ); ?>
|
124 |
+
</tr>
|
125 |
+
</thead>
|
126 |
+
|
127 |
+
<tbody>
|
128 |
+
<?php $this->purchase_log_cart_items(); ?>
|
129 |
+
|
130 |
+
<tr class="wpsc_purchaselog_start_totals">
|
131 |
+
<td colspan="<?php echo $cols; ?>">
|
132 |
+
<?php if ( wpsc_purchlog_has_discount_data() ): ?>
|
133 |
+
<?php esc_html_e( 'Coupon Code', 'wp-e-commerce' ); ?>: <?php echo wpsc_display_purchlog_discount_data(); ?>
|
134 |
+
<?php endif; ?>
|
135 |
+
</td>
|
136 |
+
<th><?php esc_html_e( 'Discount', 'wp-e-commerce' ); ?> </th>
|
137 |
+
<td class="amount"><?php echo wpsc_display_purchlog_discount(); ?></td>
|
138 |
+
</tr>
|
139 |
+
|
140 |
+
<?php if( ! wpec_display_product_tax() ): ?>
|
141 |
+
<tr>
|
142 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
143 |
+
<th><?php esc_html_e( 'Taxes', 'wp-e-commerce' ); ?> </th>
|
144 |
+
<td class="amount"><?php echo wpsc_display_purchlog_taxes(); ?></td>
|
145 |
+
</tr>
|
146 |
+
<?php endif; ?>
|
147 |
+
|
148 |
+
<tr>
|
149 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
150 |
+
<th><?php esc_html_e( 'Shipping', 'wp-e-commerce' ); ?> </th>
|
151 |
+
<td class="amount"><?php echo wpsc_display_purchlog_shipping(); ?></td>
|
152 |
+
</tr>
|
153 |
+
<tr>
|
154 |
+
<td colspan='<?php echo $cols; ?>'></td>
|
155 |
+
<th><?php esc_html_e( 'Total', 'wp-e-commerce' ); ?> </th>
|
156 |
+
<td class="amount"><?php echo wpsc_display_purchlog_totalprice(); ?></td>
|
157 |
+
</tr>
|
158 |
+
</tbody>
|
159 |
+
</table>
|
160 |
+
</div>
|
161 |
+
</body>
|
162 |
+
</html>
|
trunk/wpsc-admin/includes/purchase-logs-page/upgrade.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class='wrap'>
|
2 |
+
|
3 |
+
<h2><?php esc_html_e( 'Sales Upgrade Fix', 'wp-e-commerce' ); ?> </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.' , 'wp-e-commerce' ), esc_url( remove_query_arg( 'c' ) ) ); ?></p>
|
8 |
+
</div>
|
9 |
+
<?php else: ?>
|
10 |
+
<p><?php _e( 'Upgrading to WP eCommerce 3.7 and later requires you to run this fix once. The following boxes correspond 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.', 'wp-e-commerce' ); ?> </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', 'wp-e-commerce' ); ?>' class='button-secondary action' />
|
42 |
+
</form>
|
43 |
+
</div>
|
44 |
+
<?php endif; ?>
|
45 |
+
</div>
|
trunk/wpsc-admin/includes/save-data.functions.php
ADDED
@@ -0,0 +1,577 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file used for adding fields to the products category taxonomy page and saving those values correctly :)
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
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 |
+
|
17 |
+
if ( empty( $value ) ) {
|
18 |
+
continue;
|
19 |
+
}
|
20 |
+
|
21 |
+
$value = preg_replace( '/[^0-9]/', '', $value );
|
22 |
+
|
23 |
+
if ( ! wpsc_update_meta( $value, 'sort_order', absint( $key ), 'wpsc_variation' ) ) {
|
24 |
+
$result = false;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* WP eCommerce edit and add product category page functions
|
31 |
+
*
|
32 |
+
* These are the main WPSC Admin functions
|
33 |
+
*
|
34 |
+
* @package wp-e-commerce
|
35 |
+
* @since 3.7
|
36 |
+
*/
|
37 |
+
|
38 |
+
function wpsc_ajax_set_category_order(){
|
39 |
+
global $wpdb;
|
40 |
+
$sort_order = $_POST['sort_order'];
|
41 |
+
$parent_id = $_POST['parent_id'];
|
42 |
+
|
43 |
+
$result = true;
|
44 |
+
foreach ( $sort_order as $key=>$value ){
|
45 |
+
if ( empty( $value ) )
|
46 |
+
continue;
|
47 |
+
|
48 |
+
$value = preg_replace( '/[^0-9]/', '', $value );
|
49 |
+
|
50 |
+
if ( ! wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_category' ) )
|
51 |
+
$result = false;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
add_filter( 'manage_edit-wpsc_product_category_columns', 'wpsc_custom_category_columns' );
|
56 |
+
add_filter( 'manage_wpsc_product_category_custom_column', 'wpsc_custom_category_column_data', 10, 3);
|
57 |
+
add_action( 'wpsc_product_category_add_form_fields', 'wpsc_admin_category_forms_add' ); // After left-col
|
58 |
+
add_action( 'wpsc_product_category_edit_form_fields', 'wpsc_admin_category_forms_edit' ); // After left-col
|
59 |
+
add_action( 'created_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After created
|
60 |
+
add_action( 'edited_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After saved
|
61 |
+
|
62 |
+
/**
|
63 |
+
* wpsc_custom_category_columns
|
64 |
+
* Adds images column to category column.
|
65 |
+
* @internal Don't feel handle column is necessary, but you would add it here if you wanted to
|
66 |
+
* @param (array) columns | Array of columns assigned to this taxonomy
|
67 |
+
* @return (array) columns | Modified array of columns
|
68 |
+
*/
|
69 |
+
|
70 |
+
function wpsc_custom_category_columns( $columns ) {
|
71 |
+
// Doing it this funny way to ensure that image stays in far left, even if other items are added via plugin.
|
72 |
+
unset( $columns["cb"] );
|
73 |
+
|
74 |
+
$custom_array = array(
|
75 |
+
'cb' => '<input type="checkbox" />',
|
76 |
+
'image' => __( 'Image', 'wp-e-commerce' )
|
77 |
+
);
|
78 |
+
|
79 |
+
$columns = array_merge( $custom_array, $columns );
|
80 |
+
|
81 |
+
return $columns;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Custom Category Column Data
|
86 |
+
*
|
87 |
+
* Adds images to the custom category column.
|
88 |
+
*
|
89 |
+
* @param string $string Column output.
|
90 |
+
* @param string $column_name Column name.
|
91 |
+
* @param string $term_id Term ID.
|
92 |
+
* @return string Updated column output.
|
93 |
+
*/
|
94 |
+
function wpsc_custom_category_column_data( $string, $column_name, $term_id ) {
|
95 |
+
if ( 'image' == $column_name ) {
|
96 |
+
$term = get_term_by( 'id', $term_id, 'wpsc_product_category' );
|
97 |
+
$image = wpsc_get_categorymeta( $term_id, 'image' );
|
98 |
+
$noimage = defined( 'WPSC_CORE_THEME_URL' ) ? WPSC_CORE_THEME_URL . '/wpsc-images/noimage.png' : WPSC_TE_V2_URL . '/theming/assets/images/noimage.png';
|
99 |
+
|
100 |
+
$format = '<img src="%s" title="%s" alt="%2$s" width="30" height="30" />';
|
101 |
+
if ( ! empty( $image ) ) {
|
102 |
+
$string = sprintf( $format, WPSC_CATEGORY_URL . $image, esc_attr( $term->name ) );
|
103 |
+
} else {
|
104 |
+
$string = sprintf( $format, $noimage, esc_attr( $term->name ) );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
return $string;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* wpsc_admin_get_category_array
|
112 |
+
* Recursively step through the categories and return it in a clean multi demensional array
|
113 |
+
* for use in other list functions
|
114 |
+
* @param int $parent_id
|
115 |
+
*/
|
116 |
+
function wpsc_admin_get_category_array( $parent_id = null ){
|
117 |
+
global $wpdb;
|
118 |
+
|
119 |
+
$orderedList = array();
|
120 |
+
|
121 |
+
if ( ! isset( $parent_id ) )
|
122 |
+
$parent_id = 0;
|
123 |
+
|
124 |
+
$category_list = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $parent_id );
|
125 |
+
|
126 |
+
if ( ! is_array( $category_list ) ) {
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
|
130 |
+
foreach ( $category_list as $category ) {
|
131 |
+
$category_order = wpsc_get_categorymeta( $category->term_id, 'order' );
|
132 |
+
$category_image = wpsc_get_categorymeta( $category->term_id, 'image' );
|
133 |
+
|
134 |
+
if ( ! isset( $category_order ) || $category_order == 0 )
|
135 |
+
$category_order = ( count( $orderedList ) + 1 );
|
136 |
+
print "<!-- setting category Order number to " . $category_order . "-->";
|
137 |
+
$orderedList[$category_order]['id'] = $category->term_id;
|
138 |
+
$orderedList[$category_order]['name'] = $category->name;
|
139 |
+
$orderedList[$category_order]['image'] = $category_image;
|
140 |
+
$orderedList[$category_order]['parent_id'] = $parent_id;
|
141 |
+
$orderedList[$category_order]['children'] = wpsc_admin_get_category_array( $category->term_id );
|
142 |
+
}
|
143 |
+
|
144 |
+
ksort( $orderedList );
|
145 |
+
return $orderedList;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* wpsc_admin_category_group_list, prints the left hand side of the add categories page
|
150 |
+
* nothing returned
|
151 |
+
*/
|
152 |
+
function wpsc_admin_category_forms_add() {
|
153 |
+
global $wpdb;
|
154 |
+
$category_value_count = 0;
|
155 |
+
$display_type = isset( $category['display_type'] ) ? $category['display_type'] : '';
|
156 |
+
?>
|
157 |
+
|
158 |
+
<h3><?php esc_html_e('Advanced Store Settings', 'wp-e-commerce'); ?></h3>
|
159 |
+
<h4><?php esc_html_e('Presentation Settings', 'wp-e-commerce'); ?></h4>
|
160 |
+
<p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings > Store > Presentation.', 'wp-e-commerce' ); ?></p>
|
161 |
+
<div style="margin: 15px 0 15px 0">
|
162 |
+
<label for='image'><?php esc_html_e( 'Category Image' , 'wp-e-commerce' ); ?></label>
|
163 |
+
<input type='file' name='image' value='' />
|
164 |
+
</div>
|
165 |
+
<div class="form-field">
|
166 |
+
<label for='display_type'><?php esc_html_e( 'Product Display', 'wp-e-commerce' ); ?></label>
|
167 |
+
<select name='display_type'>
|
168 |
+
<option value='default'<?php checked( $display_type, 'default' ); ?>><?php esc_html_e('Default View', 'wp-e-commerce'); ?></option>
|
169 |
+
<option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php checked( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wp-e-commerce'); ?></option>
|
170 |
+
<option value='grid'<?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php checked( $display_type, 'grid' ); ?>><?php esc_html_e('Grid View', 'wp-e-commerce'); ?></option>
|
171 |
+
</select>
|
172 |
+
</div>
|
173 |
+
<?php if ( function_exists( "getimagesize" ) ) : ?>
|
174 |
+
<div class="form-field">
|
175 |
+
<?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?>
|
176 |
+
<fieldset class="wpsc-width-height-fields">
|
177 |
+
<legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></span></legend>
|
178 |
+
<label for="image_width"><?php esc_html_e( 'Width', 'wp-e-commerce' ); ?></label>
|
179 |
+
<input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text" style="width: 70px">
|
180 |
+
<label for="large_size_h"><?php esc_html_e( 'Height', 'wp-e-commerce' ); ?></label>
|
181 |
+
<input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text" style="width: 70px">
|
182 |
+
</fieldset>
|
183 |
+
</div>
|
184 |
+
<?php endif;?>
|
185 |
+
|
186 |
+
<!-- START OF TARGET MARKET SELECTION -->
|
187 |
+
<?php
|
188 |
+
|
189 |
+
$category_id = '';
|
190 |
+
|
191 |
+
if ( isset( $_GET['tag_ID'] ) ) {
|
192 |
+
$category_id = absint( $_GET['tag_ID'] );
|
193 |
+
}
|
194 |
+
|
195 |
+
$countrylist = WPSC_Countries::get_countries_array( true, true );
|
196 |
+
$selectedCountries = wpsc_get_meta( $category_id, 'target_market', 'wpsc_category' );
|
197 |
+
?>
|
198 |
+
<h4><?php esc_html_e( 'Restrict to Target Markets', 'wp-e-commerce' )?></h4>
|
199 |
+
<div class='form-field'>
|
200 |
+
<?php if ( wpsc_is_suhosin_enabled() ) : ?>
|
201 |
+
<em><?php esc_html_e( "The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.", 'wp-e-commerce' ); ?></em>
|
202 |
+
<?php else: ?>
|
203 |
+
<div class='multiple-select-container'>
|
204 |
+
<span><?php esc_html_e( 'Select', 'wp-e-commerce' ); ?> <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wp-e-commerce' ); ?></a> <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></a></span><br />
|
205 |
+
<div id='resizeable' class='ui-widget-content multiple-select'>
|
206 |
+
<?php foreach( $countrylist as $country ): ?>
|
207 |
+
<?php if ( in_array( $country['id'], (array)$selectedCountries ) ): ?>
|
208 |
+
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' checked='<?php echo $country['visible']; ?>' />
|
209 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
210 |
+
<?php else: ?>
|
211 |
+
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' />
|
212 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
213 |
+
<?php endif; ?>
|
214 |
+
<?php endforeach; ?>
|
215 |
+
</div>
|
216 |
+
</div>
|
217 |
+
<span class='wpscsmall description'><?php esc_html_e( 'Select the markets you are selling this category to.', 'wp-e-commerce' ); ?><span>
|
218 |
+
<?php endif; ?>
|
219 |
+
</div>
|
220 |
+
|
221 |
+
<!-- Checkout settings -->
|
222 |
+
<h4><?php esc_html_e( 'Checkout Settings', 'wp-e-commerce' ); ?></h4>
|
223 |
+
|
224 |
+
<?php
|
225 |
+
if ( ! isset( $category['term_id'] ) ) $category['term_id'] = '';
|
226 |
+
$used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' );
|
227 |
+
?>
|
228 |
+
<div class='form-field'>
|
229 |
+
<label for="use_additional_form_set"><?php esc_html_e( 'Category requires additional checkout form fields', 'wp-e-commerce' ); ?></label>
|
230 |
+
<select name='use_additional_form_set'>
|
231 |
+
<option value=''><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></option>
|
232 |
+
<?php
|
233 |
+
$checkout_sets = get_option( 'wpsc_checkout_form_sets' );
|
234 |
+
unset( $checkout_sets[0] );
|
235 |
+
|
236 |
+
foreach ( (array)$checkout_sets as $key => $value ) {
|
237 |
+
$selected_state = "";
|
238 |
+
if ( $used_additonal_form_set == $key )
|
239 |
+
$selected_state = "selected='selected'";
|
240 |
+
?>
|
241 |
+
<option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo esc_html( $value ); ?></option>
|
242 |
+
<?php
|
243 |
+
}
|
244 |
+
?>
|
245 |
+
</select>
|
246 |
+
</div>
|
247 |
+
|
248 |
+
<?php $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); ?>
|
249 |
+
<div>
|
250 |
+
<label><?php esc_html_e( 'Address to calculate shipping with', 'wp-e-commerce' ); ?></label>
|
251 |
+
<label><input type="radio" value="0" name="uses_billing_address" <?php checked( $uses_billing_address, 0 ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wp-e-commerce' ); ?></label>
|
252 |
+
<label><input type="radio" value="1" name="uses_billing_address" <?php checked( $uses_billing_address, 1 ); ?> /> <?php esc_html_e( 'Billing Address', 'wp-e-commerce' ); ?></label>
|
253 |
+
<p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wp-e-commerce' ); ?></p>
|
254 |
+
</div>
|
255 |
+
|
256 |
+
<table class="category_forms">
|
257 |
+
<tr>
|
258 |
+
|
259 |
+
</tr>
|
260 |
+
</table>
|
261 |
+
<?php
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Check whether a display type (such as grid, list) is supported.
|
266 |
+
*
|
267 |
+
* @since 3.8.9
|
268 |
+
* @access private
|
269 |
+
* @param string $display_type Display type
|
270 |
+
* @return bool Return true if display type is supported.
|
271 |
+
*/
|
272 |
+
function _wpsc_is_display_type_supported( $display_type ) {
|
273 |
+
$callback = 'product_display_' . $display_type;
|
274 |
+
return function_exists( $callback );
|
275 |
+
}
|
276 |
+
|
277 |
+
function wpsc_admin_category_forms_edit() {
|
278 |
+
global $wpdb;
|
279 |
+
|
280 |
+
$category_value_count = 0;
|
281 |
+
$category_name = '';
|
282 |
+
$category = array();
|
283 |
+
|
284 |
+
$category_id = absint( $_REQUEST["tag_ID"] );
|
285 |
+
$category = get_term( $category_id, 'wpsc_product_category', ARRAY_A );
|
286 |
+
$category['nice-name'] = wpsc_get_categorymeta( $category['term_id'], 'nice-name' );
|
287 |
+
$category['description'] = wpsc_get_categorymeta( $category['term_id'], 'description' );
|
288 |
+
$category['image'] = wpsc_get_categorymeta( $category['term_id'], 'image' );
|
289 |
+
$category['fee'] = wpsc_get_categorymeta( $category['term_id'], 'fee' );
|
290 |
+
$category['active'] = wpsc_get_categorymeta( $category['term_id'], 'active' );
|
291 |
+
$category['order'] = wpsc_get_categorymeta( $category['term_id'], 'order' );
|
292 |
+
$category['display_type'] = wpsc_get_categorymeta( $category['term_id'], 'display_type' );
|
293 |
+
$category['image_height'] = wpsc_get_categorymeta( $category['term_id'], 'image_height' );
|
294 |
+
$category['image_width'] = wpsc_get_categorymeta( $category['term_id'], 'image_width' );
|
295 |
+
$category['use_additional_form_set'] = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' );
|
296 |
+
|
297 |
+
?>
|
298 |
+
|
299 |
+
<tr>
|
300 |
+
<td colspan="2">
|
301 |
+
<h3><?php esc_html_e( 'Advanced Store Settings', 'wp-e-commerce' ); ?></h3>
|
302 |
+
<h4><?php esc_html_e( 'Shortcodes and Template Tags', 'wp-e-commerce' ); ?></h4>
|
303 |
+
<p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings > Store > Presentation.', 'wp-e-commerce' ); ?></p>
|
304 |
+
</td>
|
305 |
+
</tr>
|
306 |
+
|
307 |
+
|
308 |
+
<tr class="form-field">
|
309 |
+
<th scope="row" valign="top">
|
310 |
+
<label for="display_type"><?php esc_html_e( 'Catalog View', 'wp-e-commerce' ); ?></label>
|
311 |
+
</th>
|
312 |
+
<td>
|
313 |
+
<?php
|
314 |
+
$display_type = isset( $category['display_type'] ) ? $category['display_type'] : '';
|
315 |
+
?>
|
316 |
+
<select name='display_type'>
|
317 |
+
<option value='default'<?php selected( $display_type, 'default' ); ?>><?php esc_html_e( 'Default View', 'wp-e-commerce' ); ?></option>
|
318 |
+
<option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php selected( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wp-e-commerce'); ?></option>
|
319 |
+
<option value='grid' <?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php selected( $display_type, 'grid' ); ?>><?php esc_html_e( 'Grid View', 'wp-e-commerce' ); ?></option>
|
320 |
+
</select><br />
|
321 |
+
</td>
|
322 |
+
</tr>
|
323 |
+
<tr class="form-field">
|
324 |
+
<th scope="row" valign="top">
|
325 |
+
<label for="image"><?php esc_html_e( 'Category Image', 'wp-e-commerce' ); ?></label>
|
326 |
+
</th>
|
327 |
+
<td>
|
328 |
+
<?php
|
329 |
+
$category_image = wpsc_category_image( $category['term_id'] );
|
330 |
+
if ( $category_image )
|
331 |
+
echo '<p><img src=' . esc_url( $category_image ) . ' alt="' . esc_attr( $category['name'] ) . '" title="' . esc_attr( $category['name'] ) . '" class="wpsc_category_image" /></p>';
|
332 |
+
?>
|
333 |
+
<input type='file' name='image' value='' /><br />
|
334 |
+
<label><input type='checkbox' name='deleteimage' class="wpsc_cat_box" value='1' /><?php esc_html_e( 'Delete Image', 'wp-e-commerce' ); ?></label><br/>
|
335 |
+
<span class="description"><?php esc_html_e( 'You can set an image for the category here. If one exists, check the box to delete.', 'wp-e-commerce' ); ?></span>
|
336 |
+
</td>
|
337 |
+
</tr>
|
338 |
+
<?php if ( function_exists( "getimagesize" ) ) : ?>
|
339 |
+
<tr class="form-field">
|
340 |
+
<th scope="row" valign="top">
|
341 |
+
<label for="image"><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></label>
|
342 |
+
</th>
|
343 |
+
<td>
|
344 |
+
<fieldset class="wpsc-width-height-fields">
|
345 |
+
<legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></span></legend>
|
346 |
+
<label for="image_width"><?php esc_html_e( 'Width', 'wp-e-commerce' ); ?></label>
|
347 |
+
<input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text">
|
348 |
+
<label for="large_size_h"><?php esc_html_e( 'Height', 'wp-e-commerce' ); ?></label>
|
349 |
+
<input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text">
|
350 |
+
</fieldset>
|
351 |
+
</td>
|
352 |
+
</tr>
|
353 |
+
<?php endif; // 'getimagesize' condition ?>
|
354 |
+
|
355 |
+
|
356 |
+
<tr>
|
357 |
+
<td colspan="2"><h4><?php esc_html_e( 'Shortcodes and Template Tags', 'wp-e-commerce' ); ?></h4></td>
|
358 |
+
</tr>
|
359 |
+
|
360 |
+
<tr class="form-field">
|
361 |
+
<th scope="row" valign="top">
|
362 |
+
<label for="image"><?php esc_html_e( 'Display Category Shortcode', 'wp-e-commerce' ); ?></label>
|
363 |
+
</th>
|
364 |
+
<td>
|
365 |
+
<code>[wpsc_products category_url_name='<?php echo $category["slug"]; ?>']</code><br />
|
366 |
+
<span class="description"><?php esc_html_e( 'Shortcodes are used to display a particular category or group within any WordPress page or post.', 'wp-e-commerce' ); ?></span>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
+
<tr class="form-field">
|
370 |
+
<th scope="row" valign="top">
|
371 |
+
<label for="image"><?php esc_html_e( 'Display Category Template Tag', 'wp-e-commerce' ); ?></label>
|
372 |
+
</th>
|
373 |
+
<td>
|
374 |
+
<code><?php echo wpsc_display_products_page( array( 'category_url_name' => '<?php echo $category["slug"]; ?>' ) ); ?></code><br />
|
375 |
+
<span class="description"><?php esc_html_e( 'Template tags are used to display a particular category or group within your theme / template.', 'wp-e-commerce' ); ?></span>
|
376 |
+
</td>
|
377 |
+
</tr>
|
378 |
+
|
379 |
+
<!-- START OF TARGET MARKET SELECTION -->
|
380 |
+
|
381 |
+
<tr>
|
382 |
+
<td colspan="2">
|
383 |
+
<h4><?php esc_html_e( 'Target Market Restrictions', 'wp-e-commerce' ); ?></h4>
|
384 |
+
</td>
|
385 |
+
</tr>
|
386 |
+
<?php
|
387 |
+
$countrylist = WPSC_Countries::get_countries_array( true, true );
|
388 |
+
$selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' );
|
389 |
+
?>
|
390 |
+
<tr>
|
391 |
+
<th scope="row" valign="top">
|
392 |
+
<label for="image"><?php esc_html_e( 'Target Markets', 'wp-e-commerce' ); ?></label>
|
393 |
+
</th>
|
394 |
+
<td>
|
395 |
+
<?php if ( wpsc_is_suhosin_enabled() ) : ?>
|
396 |
+
<em><?php esc_html_e( 'The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.','wp-e-commerce' ); ?></em>
|
397 |
+
<?php else : ?>
|
398 |
+
<span><?php esc_html_e( 'Select', 'wp-e-commerce' ); ?>: <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wp-e-commerce' ); ?></a> <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></a></span><br />
|
399 |
+
<div id='resizeable' class='ui-widget-content multiple-select'>
|
400 |
+
<?php foreach( $countrylist as $country ) {
|
401 |
+
if ( in_array( $country['id'], (array)$selectedCountries ) ) {
|
402 |
+
?>
|
403 |
+
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' checked='<?php echo $country['visible']; ?>' />
|
404 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
405 |
+
<?php
|
406 |
+
} else {
|
407 |
+
?>
|
408 |
+
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' />
|
409 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
410 |
+
<?php
|
411 |
+
}
|
412 |
+
} ?>
|
413 |
+
</div>
|
414 |
+
<?php endif; ?><br />
|
415 |
+
<span class="description"><?php esc_html_e( 'Select the markets you are selling this category to.', 'wp-e-commerce' ); ?></span>
|
416 |
+
</td>
|
417 |
+
</tr>
|
418 |
+
|
419 |
+
<!-- Checkout settings -->
|
420 |
+
|
421 |
+
<tr>
|
422 |
+
<td colspan="2">
|
423 |
+
<h4><?php esc_html_e( 'Checkout Settings', 'wp-e-commerce' ); ?></h4>
|
424 |
+
</td>
|
425 |
+
</tr>
|
426 |
+
<?php
|
427 |
+
if ( !isset( $category['term_id'] ) )
|
428 |
+
$category['term_id'] = '';
|
429 |
+
|
430 |
+
$used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' );
|
431 |
+
$checkout_sets = get_option('wpsc_checkout_form_sets');
|
432 |
+
unset($checkout_sets[0]);
|
433 |
+
$uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' );
|
434 |
+
?>
|
435 |
+
<tr class="form-field">
|
436 |
+
<th scope="row" valign="top">
|
437 |
+
<label for="image"><?php esc_html_e( 'Category requires additional checkout form fields', 'wp-e-commerce' ); ?></label>
|
438 |
+
</th>
|
439 |
+
<td>
|
440 |
+
<select name='use_additional_form_set'>
|
441 |
+
<option value=''><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></option>
|
442 |
+
<?php
|
443 |
+
foreach( (array) $checkout_sets as $key => $value ) {
|
444 |
+
$selected_state = "";
|
445 |
+
if ( $used_additonal_form_set == $key ) {
|
446 |
+
$selected_state = "selected='selected'";
|
447 |
+
} ?>
|
448 |
+
<option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo esc_html( $value ); ?></option>
|
449 |
+
<?php
|
450 |
+
}
|
451 |
+
?>
|
452 |
+
</select>
|
453 |
+
</td>
|
454 |
+
</tr>
|
455 |
+
|
456 |
+
<tr class="form-field">
|
457 |
+
<th scope="row" valign="top">
|
458 |
+
<label><?php esc_html_e( 'Address to calculate shipping with', 'wp-e-commerce' ); ?></label>
|
459 |
+
</th>
|
460 |
+
<td>
|
461 |
+
<label><input type="radio" class="wpsc_cat_box" value="0" name="uses_billing_address" <?php echo ( ( $uses_billing_address != true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wp-e-commerce' ); ?></label><br />
|
462 |
+
<label><input type="radio" class="wpsc_cat_box" value="1" name="uses_billing_address" <?php echo ( ( $uses_billing_address == true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Billing Address', 'wp-e-commerce' ); ?></label>
|
463 |
+
<p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wp-e-commerce' ); ?></p>
|
464 |
+
</td>
|
465 |
+
</tr>
|
466 |
+
|
467 |
+
<?php
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* wpsc_save_category_set, Saves the category set data
|
472 |
+
* @param nothing
|
473 |
+
* @return nothing
|
474 |
+
*/
|
475 |
+
function wpsc_save_category_set( $category_id, $tt_id ) {
|
476 |
+
global $wpdb;
|
477 |
+
|
478 |
+
if ( ! empty( $_POST ) ) {
|
479 |
+
/* Image Processing Code*/
|
480 |
+
if ( ! empty( $_FILES['image'] ) && preg_match( "/\.(gif|jp(e)*g|png){1}$/i", $_FILES['image']['name'] ) ) {
|
481 |
+
if ( function_exists( "getimagesize" ) ) {
|
482 |
+
if ( isset( $_POST['width'] ) && ( (int) $_POST['width'] > 10 && (int) $_POST['width'] < 512 ) && ( (int)$_POST['height'] > 10 && (int)$_POST['height'] < 512 ) ) {
|
483 |
+
$width = (int) $_POST['width'];
|
484 |
+
$height = (int) $_POST['height'];
|
485 |
+
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ), $width, $height, 'image' );
|
486 |
+
} else {
|
487 |
+
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ), null, null, 'image' );
|
488 |
+
}
|
489 |
+
$image = esc_sql( $_FILES['image']['name'] );
|
490 |
+
} else {
|
491 |
+
$new_image_path = ( WPSC_CATEGORY_DIR.basename($_FILES['image']['name'] ) );
|
492 |
+
move_uploaded_file( $_FILES['image']['tmp_name'], $new_image_path );
|
493 |
+
$stat = stat( dirname( $new_image_path ) );
|
494 |
+
$perms = $stat['mode'] & 0000666;
|
495 |
+
@ chmod( $new_image_path, $perms );
|
496 |
+
$image = esc_sql( $_FILES['image']['name'] );
|
497 |
+
}
|
498 |
+
} else {
|
499 |
+
$image = '';
|
500 |
+
}
|
501 |
+
//Good to here
|
502 |
+
if ( isset( $_POST['tag_ID'] ) ) {
|
503 |
+
//Editing
|
504 |
+
$category_id = (int) $_POST['tag_ID'];
|
505 |
+
$category = get_term_by( 'id', $category_id, 'wpsc_product_category' );
|
506 |
+
$url_name = $category->slug;
|
507 |
+
|
508 |
+
}
|
509 |
+
if ( isset( $_POST['deleteimage'] ) && $_POST['deleteimage'] == 1 ) {
|
510 |
+
wpsc_delete_categorymeta( $category_id, 'image' );
|
511 |
+
} else if ( $image != '' ) {
|
512 |
+
wpsc_update_categorymeta( $category_id, 'image', $image );
|
513 |
+
}
|
514 |
+
|
515 |
+
if ( ! empty( $_POST['height'] ) && is_numeric( $_POST['height'] ) && ! empty( $_POST['width'] ) && is_numeric( $_POST['width'] ) && $image == null ) {
|
516 |
+
$imagedata = wpsc_get_categorymeta( $category_id, 'image' );
|
517 |
+
if ( $imagedata != null ) {
|
518 |
+
$height = (int) $_POST['height'];
|
519 |
+
$width = (int) $_POST['width'];
|
520 |
+
$imagepath = WPSC_CATEGORY_DIR . $imagedata;
|
521 |
+
$image_output = WPSC_CATEGORY_DIR . $imagedata;
|
522 |
+
image_processing( $imagepath, $image_output, $width, $height );
|
523 |
+
}
|
524 |
+
}
|
525 |
+
|
526 |
+
wpsc_update_categorymeta( $category_id, 'fee', '0' );
|
527 |
+
wpsc_update_categorymeta( $category_id, 'active', '1' );
|
528 |
+
wpsc_update_categorymeta( $category_id, 'order', '0' );
|
529 |
+
|
530 |
+
if ( isset( $_POST['display_type'] ) ) {
|
531 |
+
wpsc_update_categorymeta( $category_id, 'display_type', esc_sql( stripslashes( $_POST['display_type'] ) ) );
|
532 |
+
}
|
533 |
+
|
534 |
+
if ( isset( $_POST['image_height'] ) ) {
|
535 |
+
wpsc_update_categorymeta( $category_id, 'image_height', (int) $_POST['image_height'] );
|
536 |
+
}
|
537 |
+
|
538 |
+
if ( isset( $_POST['image_width'] ) ) {
|
539 |
+
wpsc_update_categorymeta( $category_id, 'image_width', (int) $_POST['image_width'] );
|
540 |
+
}
|
541 |
+
|
542 |
+
if ( ! empty( $_POST['use_additional_form_set'] ) ) {
|
543 |
+
wpsc_update_categorymeta( $category_id, 'use_additional_form_set', absint( $_POST['use_additional_form_set'] ) );
|
544 |
+
} else {
|
545 |
+
wpsc_delete_categorymeta( $category_id, 'use_additional_form_set' );
|
546 |
+
}
|
547 |
+
|
548 |
+
if ( ! empty( $_POST['uses_billing_address'] ) ) {
|
549 |
+
wpsc_update_categorymeta( $category_id, 'uses_billing_address', 1 );
|
550 |
+
$uses_additional_forms = true;
|
551 |
+
} else {
|
552 |
+
wpsc_update_categorymeta( $category_id, 'uses_billing_address', 0 );
|
553 |
+
$uses_additional_forms = false;
|
554 |
+
}
|
555 |
+
|
556 |
+
if ( ! empty( $_POST['countrylist2'] ) && ( $category_id > 0 ) ) {
|
557 |
+
$AllSelected = false;
|
558 |
+
$countryList = $wpdb->get_col( "SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" );
|
559 |
+
|
560 |
+
if ( $AllSelected != true ){
|
561 |
+
$posted_countries = array_map( 'intval', $_POST['countrylist2'] );
|
562 |
+
$unselectedCountries = array_diff( $countryList, $posted_countries );
|
563 |
+
//find the countries that are selected
|
564 |
+
$selectedCountries = array_intersect( $countryList, $posted_countries );
|
565 |
+
wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries );
|
566 |
+
}
|
567 |
+
|
568 |
+
} elseif ( ! isset( $_POST['countrylist2'] ) ){
|
569 |
+
wpsc_update_categorymeta( $category_id, 'target_market', '' );
|
570 |
+
$AllSelected = true;
|
571 |
+
}
|
572 |
+
|
573 |
+
}
|
574 |
+
}
|
575 |
+
|
576 |
+
|
577 |
+
?>
|
trunk/wpsc-admin/includes/settings-tabs/admin.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The Admin Settings Tab class
|
5 |
+
*
|
6 |
+
* @package wp-e-commerce
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WPSC_Settings_Tab_Admin extends WPSC_Settings_Tab {
|
10 |
+
public function display() {
|
11 |
+
?>
|
12 |
+
<h3><?php esc_html_e( 'Admin Settings', 'wp-e-commerce' ); ?></h3>
|
13 |
+
<table class='wpsc_options form-table'>
|
14 |
+
<tr>
|
15 |
+
<th scope="row"><?php esc_html_e( 'Max downloads per file', 'wp-e-commerce' ); ?>: </th>
|
16 |
+
<td>
|
17 |
+
<input type="number" min="0" size="10" value="<?php echo esc_attr( get_option('max_downloads') ); ?>" name="wpsc_options[max_downloads]" />
|
18 |
+
</td>
|
19 |
+
</tr>
|
20 |
+
<?php
|
21 |
+
$wpsc_ip_lock_downloads1 = "";
|
22 |
+
$wpsc_ip_lock_downloads2 = "";
|
23 |
+
switch( esc_attr( get_option('wpsc_ip_lock_downloads') ) ) {
|
24 |
+
case 1:
|
25 |
+
$wpsc_ip_lock_downloads1 = "checked ='checked'";
|
26 |
+
break;
|
27 |
+
|
28 |
+
case 0:
|
29 |
+
default:
|
30 |
+
$wpsc_ip_lock_downloads2 = "checked ='checked'";
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
|
34 |
+
?>
|
35 |
+
<tr>
|
36 |
+
<th scope="row">
|
37 |
+
<?php esc_html_e( 'Lock downloads to IP address', 'wp-e-commerce' ); ?>:
|
38 |
+
</th>
|
39 |
+
<td>
|
40 |
+
<input type='radio' value='1' name='wpsc_options[wpsc_ip_lock_downloads]' id='wpsc_ip_lock_downloads2' <?php echo $wpsc_ip_lock_downloads1; ?> /> <label for='wpsc_ip_lock_downloads2'><?php _e('Yes', 'wp-e-commerce');?></label>
|
41 |
+
<input type='radio' value='0' name='wpsc_options[wpsc_ip_lock_downloads]' id='wpsc_ip_lock_downloads1' <?php echo $wpsc_ip_lock_downloads2; ?> /> <label for='wpsc_ip_lock_downloads1'><?php _e('No', 'wp-e-commerce');?></label><br />
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
|
45 |
+
|
46 |
+
<?php
|
47 |
+
$wpsc_check_mime_types1 = "";
|
48 |
+
$wpsc_check_mime_types2 = "";
|
49 |
+
switch( esc_attr( get_option('wpsc_check_mime_types') ) ) {
|
50 |
+
case 1:
|
51 |
+
$wpsc_check_mime_types2 = "checked ='checked'";
|
52 |
+
break;
|
53 |
+
|
54 |
+
case 0:
|
55 |
+
default:
|
56 |
+
$wpsc_check_mime_types1 = "checked ='checked'";
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
|
60 |
+
?>
|
61 |
+
<tr>
|
62 |
+
<th scope="row">
|
63 |
+
<?php esc_html_e( 'Check MIME types on file uploads', 'wp-e-commerce' ); ?>:
|
64 |
+
</th>
|
65 |
+
<td>
|
66 |
+
<input type='radio' value='0' name='wpsc_options[wpsc_check_mime_types]' id='wpsc_check_mime_types2' <?php echo $wpsc_check_mime_types1; ?> /> <label for='wpsc_check_mime_types2'><?php _e('Yes', 'wp-e-commerce');?></label>
|
67 |
+
<input type='radio' value='1' name='wpsc_options[wpsc_check_mime_types]' id='wpsc_check_mime_types1' <?php echo $wpsc_check_mime_types2; ?> /> <label for='wpsc_check_mime_types1'><?php _e('No', 'wp-e-commerce');?></label><br />
|
68 |
+
|
69 |
+
<span class="wpscsmall description">
|
70 |
+
<?php esc_html_e( 'Warning: Disabling this exposes your site to greater possibility of malicious files being uploaded, we recommend installing the Fileinfo extension for PHP rather than disabling this.', 'wp-e-commerce' ); ?>
|
71 |
+
</span>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
|
75 |
+
|
76 |
+
<tr>
|
77 |
+
<th scope="row">
|
78 |
+
<?php esc_html_e( 'Store Admin Email', 'wp-e-commerce' );?>:
|
79 |
+
</th>
|
80 |
+
<td>
|
81 |
+
<input class='text' name='wpsc_options[purch_log_email]' type='text' size='40' value='<?php echo esc_attr( get_option( 'purch_log_email' ) ); ?>' />
|
82 |
+
<p class="howto"><?php esc_html_e( 'Admin notifications will be sent here.', 'wp-e-commerce' ); ?></p>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
|
86 |
+
<tr>
|
87 |
+
<th scope="row">
|
88 |
+
<?php esc_html_e( 'Terms and Conditions', 'wp-e-commerce' );?>:
|
89 |
+
</th>
|
90 |
+
<td>
|
91 |
+
<textarea name='wpsc_options[terms_and_conditions]' cols='' rows='' style='width: 300px; height: 200px;'><?php echo esc_textarea( get_option( 'terms_and_conditions' ) ); ?></textarea>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
|
95 |
+
</table>
|
96 |
+
<h3 class="form_group"><?php esc_html_e( 'Customer Purchase Receipt', 'wp-e-commerce' );?>:</h3>
|
97 |
+
<table class='wpsc_options form-table'>
|
98 |
+
<tr>
|
99 |
+
<th colspan="2"><?php esc_html_e( 'Tags can be used', 'wp-e-commerce' );?>: <?php echo esc_html( '%purchase_id%, %shop_name%, %product_list%, %total_price%, %total_shipping%, %find_us%, %total_tax%' ); ?></th>
|
100 |
+
</tr>
|
101 |
+
<tr>
|
102 |
+
<td class='wpsc_td_note' colspan='2'>
|
103 |
+
<span class="wpscsmall description">
|
104 |
+
<?php esc_html_e( 'Note: The purchase receipt is the message e-mailed to users after purchasing products from your shop.' , 'wp-e-commerce' ); ?>
|
105 |
+
<br />
|
106 |
+
<?php esc_html_e( 'Note: You need to have the %product_list% in your purchase receipt in order for digital download links to be emailed to your buyers.' , 'wp-e-commerce' ); ?>
|
107 |
+
</span>
|
108 |
+
</td>
|
109 |
+
</tr>
|
110 |
+
<tr>
|
111 |
+
<th scope="row">
|
112 |
+
<?php echo esc_html_x( 'From Address', 'purchase receipt', 'wp-e-commerce' );?>:
|
113 |
+
</th>
|
114 |
+
<td>
|
115 |
+
<input class='text' name='wpsc_options[return_email]' type='text' size='40' value='<?php echo esc_attr( get_option( 'return_email' ) ); ?>' />
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
|
119 |
+
<tr>
|
120 |
+
<th scope="row">
|
121 |
+
<?php esc_html_e( 'Sender Name', 'wp-e-commerce' );?>:
|
122 |
+
</th>
|
123 |
+
<td>
|
124 |
+
<input class='text' name='wpsc_options[return_name]' type='text' size='40' value='<?php echo esc_attr( get_option( 'return_name' ) ); ?>' />
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<th><?php esc_html_e( 'Message Body', 'wp-e-commerce' ); ?></th>
|
129 |
+
<td><textarea name="wpsc_options[wpsc_email_receipt]" cols='' rows='' style='width: 300px; height: 200px;'><?php echo esc_textarea( get_option( 'wpsc_email_receipt' ) );?></textarea></td>
|
130 |
+
</tr>
|
131 |
+
</table>
|
132 |
+
|
133 |
+
<h3 class="form_group"><?php esc_html_e( 'Track and Trace settings', 'wp-e-commerce' ); ?>:</h3>
|
134 |
+
<table class='wpsc_options form-table'>
|
135 |
+
<tr>
|
136 |
+
<td class='wpsc_td_note' colspan='2'>
|
137 |
+
<span class="wpscsmall description">
|
138 |
+
<?php esc_html_e( 'Note: The Tracking Subject, is the subject for The Tracking Message email. The Tracking Message is the message e-mailed to users when you click \'Email buyer\' on the sales log. This option is only available for purchases with the status of \'Job Dispatched\'. Tags you can use in the email message section are %trackid% and %shop_name%' , 'wp-e-commerce' ); ?>
|
139 |
+
</span>
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<th><strong><?php esc_html_e( 'Tracking Email Subject', 'wp-e-commerce' );?></strong></th>
|
144 |
+
<td><input name="wpsc_options[wpsc_trackingid_subject]" type='text' value='<?php echo esc_attr( get_option( 'wpsc_trackingid_subject' ) );?>' /></td>
|
145 |
+
</tr>
|
146 |
+
<tr>
|
147 |
+
<th><strong><?php esc_html_e( 'Tracking Email Message', 'wp-e-commerce' );?></strong></th>
|
148 |
+
<td><textarea name="wpsc_options[wpsc_trackingid_message]" cols='' rows='' style='width: 300px; height: 200px;'><?php echo esc_textarea( get_option( 'wpsc_trackingid_message' ) );?></textarea></td>
|
149 |
+
</tr>
|
150 |
+
</table>
|
151 |
+
<?php
|
152 |
+
}
|
153 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/checkout.php
ADDED
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
private $form_fields;
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
global $wpdb;
|
16 |
+
|
17 |
+
$this->require_register = get_option( 'require_register', 0 );
|
18 |
+
$this->shipping_same_as_billing = get_option( 'shippingsameasbilling', 0 );
|
19 |
+
$this->force_ssl = get_option( 'wpsc_force_ssl', 0 );
|
20 |
+
$this->checkout_sets = get_option( 'wpsc_checkout_form_sets' );
|
21 |
+
$this->current_checkout_set = empty( $_GET['checkout_set'] ) ? 0 : (int) $_GET['checkout_set'];
|
22 |
+
$this->field_types = get_option( 'wpsc_checkout_form_fields' );
|
23 |
+
$this->user_field_types = array('text','textarea','heading','select','radio','checkbox');
|
24 |
+
|
25 |
+
if ( ! isset( $this->checkout_sets[$this->current_checkout_set] ) ) {
|
26 |
+
wp_redirect( esc_url_raw( remove_query_arg( 'checkout_set' ) ) );
|
27 |
+
exit;
|
28 |
+
}
|
29 |
+
|
30 |
+
$form_sql = $wpdb->prepare( "
|
31 |
+
SELECT *
|
32 |
+
FROM " . WPSC_TABLE_CHECKOUT_FORMS . "
|
33 |
+
WHERE checkout_set = %s
|
34 |
+
ORDER BY checkout_order
|
35 |
+
", $this->current_checkout_set );
|
36 |
+
|
37 |
+
$this->form_fields = $wpdb->get_results( $form_sql );
|
38 |
+
|
39 |
+
$columns = array(
|
40 |
+
'drag' => __( 'Drag', 'wp-e-commerce' ),
|
41 |
+
'name' => __( 'Title', 'wp-e-commerce' ),
|
42 |
+
'type' => __( 'Type', 'wp-e-commerce' ),
|
43 |
+
'unique_name' => ' ',
|
44 |
+
'display' => __( 'Display', 'wp-e-commerce' ),
|
45 |
+
'mandatory' => __( 'Mandatory', 'wp-e-commerce' ),
|
46 |
+
'actions' => ' ',
|
47 |
+
);
|
48 |
+
register_column_headers( 'display-checkout-list', $columns );
|
49 |
+
}
|
50 |
+
|
51 |
+
private function delete_form_set() {
|
52 |
+
global $wpdb;
|
53 |
+
|
54 |
+
$selected_checkout_set = $_REQUEST['checkout_set'];
|
55 |
+
|
56 |
+
if ( empty( $selected_checkout_set ) )
|
57 |
+
return;
|
58 |
+
|
59 |
+
$form_sets = get_option( 'wpsc_checkout_form_sets' );
|
60 |
+
unset( $form_sets[$selected_checkout_set] );
|
61 |
+
update_option( 'wpsc_checkout_form_sets', $form_sets );
|
62 |
+
|
63 |
+
$sql = $wpdb->prepare( 'DELETE FROM ' . WPSC_TABLE_CHECKOUT_FORMS . ' WHERE checkout_set = %s', $selected_checkout_set );
|
64 |
+
$wpdb->query( $sql );
|
65 |
+
}
|
66 |
+
|
67 |
+
public function callback_submit_options() {
|
68 |
+
global $wpdb;
|
69 |
+
|
70 |
+
if ( ! empty( $_POST['wpsc_checkout_set_delete'] ) ) {
|
71 |
+
$this->delete_form_set();
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
if ( ! empty( $_POST['new_form_set'] ) ) {
|
76 |
+
$checkout_sets = get_option( 'wpsc_checkout_form_sets' );
|
77 |
+
$checkout_sets[] = sanitize_text_field( $_POST['new_form_set'] );
|
78 |
+
update_option( 'wpsc_checkout_form_sets', $checkout_sets );
|
79 |
+
add_settings_error( 'wpsc-settings', 'wpsc_form_set_added', __( 'New form set successfully created.', 'wp-e-commerce' ), 'updated' );
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( isset( $_POST['checkout_set'] ) ) {
|
83 |
+
$_SERVER['REQUEST_URI'] = esc_url_raw( add_query_arg( 'checkout_set', $_POST['checkout_set'] ) );
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( ! isset( $_POST['form_name'] ) && ! isset( $_POST['new_field_name'] ) )
|
87 |
+
return;
|
88 |
+
|
89 |
+
$existing_orders = array();
|
90 |
+
$new_field_orders = array();
|
91 |
+
if ( ! empty( $_POST['sort_order'] ) ) {
|
92 |
+
foreach ( $_POST['sort_order'] as $order => $field_id ) {
|
93 |
+
$id = absint( preg_replace('/[^0-9]+/', '', $field_id) );
|
94 |
+
|
95 |
+
if ( strpos( $field_id, 'new-field' ) === 0 )
|
96 |
+
$new_field_orders[$id] = $order;
|
97 |
+
else
|
98 |
+
$existing_orders[$id] = $order;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
$sql = $wpdb->prepare( "SELECT id FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE checkout_set = %s", $this->current_checkout_set );
|
103 |
+
$ids = $wpdb->get_col( $sql );
|
104 |
+
|
105 |
+
if ( ! empty( $_POST['form_name'] ) ) {
|
106 |
+
foreach ( $_POST['form_name'] as $field_id => $name ) {
|
107 |
+
$data = array(
|
108 |
+
'name' => $name,
|
109 |
+
'active' => empty( $_POST['form_display'][$field_id] ) ? 0 : 1,
|
110 |
+
'mandatory' => empty( $_POST['form_mandatory'][$field_id] ) ? 0 : 1,
|
111 |
+
);
|
112 |
+
|
113 |
+
$data_format = array(
|
114 |
+
'%s', // name
|
115 |
+
'%s', // active
|
116 |
+
'%s', // mandatory
|
117 |
+
);
|
118 |
+
|
119 |
+
$where = array( 'id' => $field_id );
|
120 |
+
|
121 |
+
if ( isset( $_POST['form_type'][$field_id] ) ) {
|
122 |
+
$data['type'] = $_POST['form_type'][$field_id];
|
123 |
+
$data_format[] = '%s';
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( isset( $existing_orders[$field_id] ) ) {
|
127 |
+
$data['checkout_order'] = $existing_orders[$field_id];
|
128 |
+
$data_format[] = '%d';
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( isset( $_POST['form_options'][$field_id]['label'] ) ) {
|
132 |
+
$options = array();
|
133 |
+
foreach( $_POST['form_options'][$field_id]['label'] as $key => $label ) {
|
134 |
+
$value = $_POST['form_options'][$field_id]['value'][$key];
|
135 |
+
if ( $label === '' && $value === '')
|
136 |
+
continue;
|
137 |
+
$label = sanitize_text_field( $label );
|
138 |
+
$options[$label] = sanitize_text_field( $value );
|
139 |
+
}
|
140 |
+
$data['options'] = serialize( $options );
|
141 |
+
$data_format[] = '%s';
|
142 |
+
}
|
143 |
+
|
144 |
+
$index = array_search( $field_id, $ids );
|
145 |
+
if ( $index !== false ) {
|
146 |
+
unset( $ids[$index] );
|
147 |
+
}
|
148 |
+
|
149 |
+
$wpdb->update( WPSC_TABLE_CHECKOUT_FORMS, $data, $where, $data_format, '%d' );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
// delete all other fields that are not present in the submitted form
|
154 |
+
if ( ! empty( $ids ) ) {
|
155 |
+
$sql = "DELETE FROM " . WPSC_TABLE_CHECKOUT_FORMS . " WHERE id IN (" . implode( ', ', $ids ) . ")";
|
156 |
+
$wpdb->query( $sql );
|
157 |
+
}
|
158 |
+
|
159 |
+
foreach ( $_POST['new_field_name'] as $key => $name ) {
|
160 |
+
if ( $key === 0 || empty( $name ) )
|
161 |
+
continue;
|
162 |
+
|
163 |
+
$data = array(
|
164 |
+
'name' => $name,
|
165 |
+
'type' => $_POST['new_field_type'][$key],
|
166 |
+
'active' => empty( $_POST['new_field_display'][$key] ) ? 0 : 1,
|
167 |
+
'mandatory' => empty( $_POST['new_field_mandatory'][$key] ) ? 0 : 1,
|
168 |
+
'checkout_set' => $this->current_checkout_set,
|
169 |
+
'unique_name' => sanitize_title( $name ),
|
170 |
+
);
|
171 |
+
|
172 |
+
$data_format = array(
|
173 |
+
'%s', // name
|
174 |
+
'%s', // type
|
175 |
+
'%s', // active
|
176 |
+
'%s', // mandatory
|
177 |
+
'%s', // checkout set
|
178 |
+
'%s', // unique name
|
179 |
+
);
|
180 |
+
|
181 |
+
if ( isset( $new_field_orders[$key] ) ) {
|
182 |
+
$data['checkout_order'] = $new_field_orders[$key];
|
183 |
+
$data_format[] = '%d';
|
184 |
+
}
|
185 |
+
|
186 |
+
if ( isset( $_POST['new_field_options'][$key]['label'] ) ) {
|
187 |
+
$options = array();
|
188 |
+
foreach( $_POST['new_field_options'][$key]['label'] as $index => $label ) {
|
189 |
+
$value = $_POST['new_field_options'][$key]['value'][$index];
|
190 |
+
if ( $label === '' && $value === '')
|
191 |
+
continue;
|
192 |
+
$options[$label] = $value;
|
193 |
+
}
|
194 |
+
|
195 |
+
$data['options'] = serialize( $options );
|
196 |
+
$data_format[] = '%s';
|
197 |
+
}
|
198 |
+
|
199 |
+
$wpdb->insert( WPSC_TABLE_CHECKOUT_FORMS, $data, $data_format );
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Determine whether this field is default or not.
|
205 |
+
*
|
206 |
+
* We do not let default fields to be deleted from 3.8.8. However, if the user upgrades from
|
207 |
+
* 3.7.x, the "default" column of the checkout form table does not correctly specify
|
208 |
+
* whether the fields are default or not.
|
209 |
+
*
|
210 |
+
* Also, if in any case the user has deleted a default field in versions older than 3.8.8,
|
211 |
+
* the field's "active" column will be set to 0. We should let users delete those fields as well.
|
212 |
+
*
|
213 |
+
* As a result, to determine whether a field is default or not, we have to rely on the field's
|
214 |
+
* unique name and "active" status.
|
215 |
+
*
|
216 |
+
* @param object $field Field object
|
217 |
+
* @return boolean True if the field is default.
|
218 |
+
*/
|
219 |
+
private function is_field_default( $field ) {
|
220 |
+
global $wpdb;
|
221 |
+
|
222 |
+
if ( $field->default == 1 ) {
|
223 |
+
return true;
|
224 |
+
}
|
225 |
+
|
226 |
+
if ( empty( $field->unique_name) || $this->current_checkout_set !== 0 || empty( $field->active ) ) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
|
230 |
+
$default_fields = array(
|
231 |
+
'billingfirstname',
|
232 |
+
'billinglastname',
|
233 |
+
'billingaddress',
|
234 |
+
'billingcity',
|
235 |
+
'billingstate',
|
236 |
+
'billingcountry',
|
237 |
+
'billingpostcode',
|
238 |
+
'billingemail',
|
239 |
+
'billingphone',
|
240 |
+
'shippingfirstname',
|
241 |
+
'shippinglastname',
|
242 |
+
'shippingaddress',
|
243 |
+
'shippingcity',
|
244 |
+
'shippingstate',
|
245 |
+
'shippingcountry',
|
246 |
+
'shippingpostcode',
|
247 |
+
'shippingemail',
|
248 |
+
);
|
249 |
+
return in_array( $field->unique_name, $default_fields );
|
250 |
+
}
|
251 |
+
|
252 |
+
private function prototype_field( $mode = 'hidden' ) {
|
253 |
+
$row_id = 'field-prototype';
|
254 |
+
$row_class = 'new-field';
|
255 |
+
$data = '';
|
256 |
+
$new_field_id = 0;
|
257 |
+
$style = '';
|
258 |
+
|
259 |
+
if ( $mode == 'new' ) {
|
260 |
+
$new_field_id = 1;
|
261 |
+
$row_id = 'new-field-1';
|
262 |
+
$row_class .= ' checkout_form_field';
|
263 |
+
$data = 'data-new-field-id="1"';
|
264 |
+
$style = 'style="display:table-row;"';
|
265 |
+
}
|
266 |
+
?>
|
267 |
+
<tr id="<?php echo $row_id; ?>" class="<?php echo $row_class; ?>" <?php echo $data; ?> <?php echo $style; ?>>
|
268 |
+
<td class="drag">
|
269 |
+
<div class="cell-wrapper">
|
270 |
+
<a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wp-e-commerce' ); ?>">
|
271 |
+
<img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
|
272 |
+
</a>
|
273 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
274 |
+
</div>
|
275 |
+
</td>
|
276 |
+
<td class="namecol">
|
277 |
+
<div class="cell-wrapper">
|
278 |
+
<input type="text" name="new_field_name[<?php echo $new_field_id; ?>]" value="" /><br />
|
279 |
+
</div>
|
280 |
+
</td>
|
281 |
+
<td class="typecol">
|
282 |
+
<div class="cell-wrapper">
|
283 |
+
<select name="new_field_type[<?php echo $new_field_id; ?>]">
|
284 |
+
<?php foreach ( $this->field_types as $name => $type ): ?>
|
285 |
+
<?php if( in_array($type, $this->user_field_types) ): ?>
|
286 |
+
<option value="<?php echo esc_attr( $type ); ?>"><?php echo esc_html( $name ); ?></option>
|
287 |
+
<?php endif ?>
|
288 |
+
<?php endforeach ?>
|
289 |
+
</select>
|
290 |
+
</div>
|
291 |
+
</td>
|
292 |
+
<td class="uniquenamecol">
|
293 |
+
<a class="edit-options" href="#"><?php esc_html_e( 'Edit Options', 'wp-e-commerce' ); ?></a>
|
294 |
+
</td>
|
295 |
+
<td class="displaycol">
|
296 |
+
<div class="cell-wrapper">
|
297 |
+
<input checked="checked" type="checkbox" name="new_field_display[<?php echo $new_field_id; ?>]" value="1" />
|
298 |
+
</div>
|
299 |
+
</td>
|
300 |
+
<td class="mandatorycol">
|
301 |
+
<div class="cell-wrapper">
|
302 |
+
<input type="checkbox" name="new_field_mandatory[<?php echo $new_field_id; ?>]" value="1" />
|
303 |
+
</div>
|
304 |
+
</td>
|
305 |
+
<td class="actionscol">
|
306 |
+
<div class="cell-wrapper">
|
307 |
+
<a tabindex="-1" title="<?php _e( 'Delete Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></a>
|
308 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x( '+', 'add item', 'wp-e-commerce' ); ?></a>
|
309 |
+
</div>
|
310 |
+
</td>
|
311 |
+
</tr>
|
312 |
+
<tr id="field-options-prototype" class="form-field-options">
|
313 |
+
<td></td>
|
314 |
+
<td>
|
315 |
+
<div class="cell-wrapper">
|
316 |
+
<h4></h4>
|
317 |
+
<table class="wpsc-field-options-table">
|
318 |
+
<thead>
|
319 |
+
<th class="column-labels"><?php echo esc_html_x( 'Label', "checkout field's options", 'wp-e-commerce' ); ?></th>
|
320 |
+
<th class="column-values"><?php echo esc_html_x( 'Value', "checkout field's options", 'wp-e-commerce' ); ?></th>
|
321 |
+
<th class="column-actions"> </th>
|
322 |
+
</thead>
|
323 |
+
<tbody>
|
324 |
+
<tr class="new-option">
|
325 |
+
<td class="column-labels">
|
326 |
+
<div class="field-option-cell-wrapper">
|
327 |
+
<input type="text" name="form_options[<?php echo $new_field_id; ?>][labels][]" value="" />
|
328 |
+
</div>
|
329 |
+
</td>
|
330 |
+
<td class="column-values">
|
331 |
+
<div class="field-option-cell-wrapper">
|
332 |
+
<input type="text" name="form_options[<?php echo $new_field_id; ?>][values][]" value="" />
|
333 |
+
</div>
|
334 |
+
</td>
|
335 |
+
<td class="column-actions">
|
336 |
+
<div class="field-option-cell-wrapper">
|
337 |
+
<a tabindex="-1" title="<?php _e( 'Delete Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></a>
|
338 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x( '+', 'add item', 'wp-e-commerce' ); ?></a>
|
339 |
+
</div>
|
340 |
+
</td>
|
341 |
+
</tr>
|
342 |
+
</tbody>
|
343 |
+
</table>
|
344 |
+
</div>
|
345 |
+
</td>
|
346 |
+
<td colspan="5"></td>
|
347 |
+
</tr>
|
348 |
+
<?php
|
349 |
+
}
|
350 |
+
|
351 |
+
public function display() {
|
352 |
+
global $wpdb;
|
353 |
+
|
354 |
+
//not to sure if we still need these any more - $form_types, $unique_names
|
355 |
+
$form_types = get_option( 'wpsc_checkout_form_fields' );
|
356 |
+
$unique_names = get_option( 'wpsc_checkout_unique_names' );
|
357 |
+
|
358 |
+
do_action( 'wpsc_checkout_form_fields_page' );
|
359 |
+
?>
|
360 |
+
|
361 |
+
<input type='hidden' name='checkout_submits' value='true' />
|
362 |
+
<h3><?php esc_html_e( 'Checkout Settings' , 'wp-e-commerce' ); ?></h3>
|
363 |
+
<table class='form-table'>
|
364 |
+
<tr>
|
365 |
+
<th scope="row"><?php esc_html_e('Force User Registration', 'wp-e-commerce'); ?></th>
|
366 |
+
<td>
|
367 |
+
<input type='radio' value='0' name='wpsc_options[require_register]' id='require_register2' <?php checked( $this->require_register, 0 ); ?> />
|
368 |
+
<label for='require_register2'><?php _e( 'Users can checkout without a user account', 'wp-e-commerce' );?></label><br />
|
369 |
+
<input type='radio' value='1' name='wpsc_options[require_register]' id='require_register1' <?php checked( $this->require_register, 1 ); ?> />
|
370 |
+
<label for='require_register1'><?php _e( 'Users must register before checking out', 'wp-e-commerce' );?></label>
|
371 |
+
<p class='description'><?php esc_attr_e( 'Enabling this will also turn on "Membership: Anyone can register" from within WordPress Settings > General if it\'s not already enabled', 'wp-e-commerce' ); ?></p>
|
372 |
+
</td>
|
373 |
+
</tr>
|
374 |
+
|
375 |
+
<tr>
|
376 |
+
<th scope="row"><?php esc_html_e('Shipping Same as Billing', 'wp-e-commerce' ); ?></th>
|
377 |
+
<td>
|
378 |
+
<input type='radio' value='1' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling1' <?php checked( $this->shipping_same_as_billing, 1 ); ?> />
|
379 |
+
<label for='shippingsameasbilling1'><?php _e( 'Enable "Same as billing address" checkbox with Shipping Address fields', 'wp-e-commerce' );?></label><br />
|
380 |
+
<input type='radio' value='0' name='wpsc_options[shippingsameasbilling]' id='shippingsameasbilling2' <?php checked( $this->shipping_same_as_billing, 0 ); ?> />
|
381 |
+
<label for='shippingsameasbilling2'><?php _e( 'Users must re-enter Shipping Address', 'wp-e-commerce' );?></label>
|
382 |
+
</td>
|
383 |
+
</tr>
|
384 |
+
<tr>
|
385 |
+
<th scope="row"><?php _e('Security and Encryption', 'wp-e-commerce'); ?></th>
|
386 |
+
<td>
|
387 |
+
<input type='radio' value='1' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl1' <?php checked( $this->force_ssl, 1 ); ?> />
|
388 |
+
<label for='wpsc_force_ssl1'><?php _e( 'Force users to use SSL Encryption', 'wp-e-commerce' );?></label><br />
|
389 |
+
<input type='radio' value='0' name='wpsc_options[wpsc_force_ssl]' id='wpsc_force_ssl2' <?php checked( $this->force_ssl, 0 ); ?> />
|
390 |
+
<label for='wpsc_force_ssl2'><?php _e( 'Allow site to be used insecurely and unencrypted', 'wp-e-commerce' );?></label>
|
391 |
+
<p class='description'><?php esc_html_e( 'This can cause warnings for your users if you do not have a properly configured SSL certificate', 'wp-e-commerce' );?></p>
|
392 |
+
</td>
|
393 |
+
</tr>
|
394 |
+
</table>
|
395 |
+
|
396 |
+
|
397 |
+
<h3><?php esc_html_e( 'Checkout Form Fields', 'wp-e-commerce' ); ?></h3>
|
398 |
+
<p><?php esc_html_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 buyer\'s address, and name...', 'wp-e-commerce' );?></p>
|
399 |
+
|
400 |
+
<p>
|
401 |
+
<label for='wpsc_form_set'><?php esc_html_e( 'Select a Form Set' , 'wp-e-commerce' ); ?>:</label>
|
402 |
+
<select id='wpsc_form_set' name='checkout_set'>
|
403 |
+
<?php foreach ( $this->checkout_sets as $key => $value ): ?>
|
404 |
+
<option <?php selected( $this->current_checkout_set, $key ); ?> value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></option>
|
405 |
+
<?php endforeach; ?>
|
406 |
+
</select>
|
407 |
+
|
408 |
+
<input type='submit' value='<?php esc_attr_e( 'Filter', 'wp-e-commerce' ); ?>' name='wpsc_checkout_set_filter' class='button-secondary' />
|
409 |
+
<input <?php if (! $this->current_checkout_set) echo 'style="display:none;"'; ?> id="wpsc-delete-checkout-set" type='submit' value='<?php esc_attr_e( 'Delete', 'wp-e-commerce' ); ?>' name='wpsc_checkout_set_delete' class='button-secondary' />
|
410 |
+
</p>
|
411 |
+
|
412 |
+
<p><a class="add_new_form_set button-secondary" href='#'><?php esc_html_e("Add New Form Set", 'wp-e-commerce'); ?></a></p>
|
413 |
+
|
414 |
+
<p class='add_new_form_set_forms'>
|
415 |
+
<label><?php esc_html_e( "Add new Form Set", 'wp-e-commerce' ); ?>:
|
416 |
+
<input type="text" value="" name="new_form_set" /></label>
|
417 |
+
<input type="submit" value="<?php esc_attr_e( 'Add', 'wp-e-commerce' ); ?>" class="button-primary" id="formset-add-sumbit"/>
|
418 |
+
</p>
|
419 |
+
|
420 |
+
<input type="hidden" name="selected_form_set" value="<?php echo esc_attr( $this->current_checkout_set ); ?>" />
|
421 |
+
|
422 |
+
<table id="wpsc_checkout_list" class="widefat page fixed" cellspacing="0">
|
423 |
+
<thead>
|
424 |
+
<tr>
|
425 |
+
<?php print_column_headers( 'display-checkout-list' ); ?>
|
426 |
+
</tr>
|
427 |
+
</thead>
|
428 |
+
|
429 |
+
<tfoot>
|
430 |
+
<tr>
|
431 |
+
<?php print_column_headers( 'display-checkout-list', false ); ?>
|
432 |
+
</tr>
|
433 |
+
</tfoot>
|
434 |
+
|
435 |
+
<tbody id='wpsc_checkout_list_body'>
|
436 |
+
<?php if ( empty( $this->form_fields ) ): ?>
|
437 |
+
<?php $this->prototype_field( 'new' ); ?>
|
438 |
+
<?php else: ?>
|
439 |
+
<?php foreach ( $this->form_fields as $form_field ): ?>
|
440 |
+
|
441 |
+
<tr data-field-id="<?php echo esc_attr( $form_field->id ); ?>" data-field-type="<?php echo $form_field->type; ?>" id="checkout_<?php echo esc_attr( $form_field->id ); ?>" class="checkout_form_field field_type_<?php echo $form_field->type; ?>">
|
442 |
+
<td class="drag">
|
443 |
+
<div class="cell-wrapper">
|
444 |
+
<a title="<?php esc_attr_e( 'Click and Drag to Order Checkout Fields', 'wp-e-commerce' ); ?>">
|
445 |
+
<img src="<?php echo esc_url( WPSC_CORE_IMAGES_URL . '/drag.png' ); ?>" />
|
446 |
+
</a>
|
447 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
448 |
+
</div>
|
449 |
+
</td>
|
450 |
+
<td class="namecol">
|
451 |
+
<div class="cell-wrapper">
|
452 |
+
<input type="text" name="form_name[<?php echo esc_attr( $form_field->id ); ?>]" value="<?php echo esc_attr( $form_field->name ); ?>" />
|
453 |
+
</div>
|
454 |
+
</td>
|
455 |
+
<td class="typecol">
|
456 |
+
<div class="cell-wrapper">
|
457 |
+
<?php if ( $this->is_field_default( $form_field ) ): ?>
|
458 |
+
<strong><?php echo esc_html( $form_field->type ); ?></strong>
|
459 |
+
<?php else: ?>
|
460 |
+
<select name="form_type[<?php echo esc_attr( $form_field->id ); ?>]">
|
461 |
+
<?php foreach ($this->field_types as $label => $name): ?>
|
462 |
+
<option <?php selected( $form_field->type, $name ); ?> value="<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $label ); ?></option>
|
463 |
+
<?php endforeach ?>
|
464 |
+
</select>
|
465 |
+
<?php
|
466 |
+
$field_options = unserialize( $form_field->options );
|
467 |
+
if ( empty( $field_options ) )
|
468 |
+
$field_options = array();
|
469 |
+
|
470 |
+
$i = 0;
|
471 |
+
foreach ( $field_options as $label => $value ):
|
472 |
+
$i ++;
|
473 |
+
?>
|
474 |
+
<input type="hidden" name="form_options[<?php echo esc_attr( $form_field->id ); ?>][label][]" value="<?php echo esc_attr( $label ); ?>" />
|
475 |
+
<input type="hidden" name="form_options[<?php echo esc_attr( $form_field->id ); ?>][value][]" value="<?php echo esc_attr( $value ); ?>" />
|
476 |
+
<?php endforeach; ?>
|
477 |
+
<?php endif; ?>
|
478 |
+
</div>
|
479 |
+
</td>
|
480 |
+
|
481 |
+
<td class="uniquenamecol">
|
482 |
+
<div class="cell-wrapper">
|
483 |
+
<?php if ( $form_field->type != 'heading' && ! empty( $form_field->unique_name ) ): ?>
|
484 |
+
<small><?php echo esc_html( $form_field->unique_name ); ?></small>
|
485 |
+
<?php endif ?>
|
486 |
+
<?php
|
487 |
+
$style = '';
|
488 |
+
if ( in_array( $form_field->type, array( 'select', 'radio', 'checkbox' ) ) ) {
|
489 |
+
$style = 'style="display: inline;"';
|
490 |
+
}
|
491 |
+
?>
|
492 |
+
<a class="edit-options" href="#" <?php echo $style; ?> ><?php esc_html_e( 'Edit Options', 'wp-e-commerce' ); ?></a>
|
493 |
+
</div>
|
494 |
+
</td>
|
495 |
+
<td class="displaycol">
|
496 |
+
<div class="cell-wrapper">
|
497 |
+
<input <?php checked( $form_field->active, 1 ); ?> type="checkbox" name="form_display[<?php echo esc_attr( $form_field->id ); ?>]" value="1" />
|
498 |
+
</div>
|
499 |
+
</td>
|
500 |
+
<td class="mandatorycol">
|
501 |
+
<div class="cell-wrapper">
|
502 |
+
<?php if ( $form_field->type != 'heading' ): ?>
|
503 |
+
<input <?php checked( $form_field->mandatory, 1 ); ?> type="checkbox" name="form_mandatory[<?php echo esc_attr( $form_field->id ); ?>]" value="1" />
|
504 |
+
<?php endif ?>
|
505 |
+
</div>
|
506 |
+
</td>
|
507 |
+
<td class="actionscol">
|
508 |
+
<div class="cell-wrapper">
|
509 |
+
<?php if ( ! $this->is_field_default( $form_field ) ): ?>
|
510 |
+
<a tabindex="-1" title="<?php esc_attr_e( 'Delete Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus" href="#"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></a>
|
511 |
+
<?php else: ?>
|
512 |
+
<span title="<?php _e( 'Cannot Delete Default Fields', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-minus"><?php echo _x( '–', 'delete item', 'wp-e-commerce' ); ?></span>
|
513 |
+
<?php endif; ?>
|
514 |
+
<a tabindex="-1" title="<?php _e( 'Add Field', 'wp-e-commerce' ); ?>" class="button-secondary wpsc-button-round wpsc-button-plus" href="#"><?php echo _x( '+', 'add item', 'wp-e-commerce' ); ?></a>
|
515 |
+
</div>
|
516 |
+
</td>
|
517 |
+
</tr>
|
518 |
+
<?php endforeach; ?>
|
519 |
+
<?php endif; ?>
|
520 |
+
<?php $this->prototype_field(); ?>
|
521 |
+
</tbody>
|
522 |
+
</table>
|
523 |
+
<?php
|
524 |
+
}
|
525 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/gateway.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Gateway extends WPSC_Settings_Tab {
|
4 |
+
private $active_gateways;
|
5 |
+
private $gateway_names;
|
6 |
+
|
7 |
+
public function __construct() {
|
8 |
+
if ( isset( $_REQUEST['payment_gateway_id'] ) ) {
|
9 |
+
update_user_option( get_current_user_id(), 'wpsc_settings_selected_payment_gateway', sanitize_text_field( $_REQUEST['payment_gateway_id'] ) );
|
10 |
+
} else {
|
11 |
+
update_user_option( get_current_user_id(), 'wpsc_settings_selected_payment_gateway', '' );
|
12 |
+
}
|
13 |
+
|
14 |
+
$this->active_gateways = get_option( 'custom_gateway_options' );
|
15 |
+
$this->gateway_names = get_option( 'payment_gateway_names' );
|
16 |
+
|
17 |
+
$this->hide_submit_button();
|
18 |
+
}
|
19 |
+
|
20 |
+
private function get_gateway_form( $selected_gateway ) {
|
21 |
+
return apply_filters( 'wpsc_settings_gateway_form', array(), $selected_gateway );
|
22 |
+
}
|
23 |
+
|
24 |
+
private function get_gateway_settings_url( $gateway ) {
|
25 |
+
$location = isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'];
|
26 |
+
$gateway = ! empty( $gateway ) ? $gateway : '';
|
27 |
+
|
28 |
+
return esc_url( add_query_arg( array(
|
29 |
+
'tab' => 'gateway',
|
30 |
+
'page' => 'wpsc-settings',
|
31 |
+
'payment_gateway_id' => $gateway
|
32 |
+
), $location ) );
|
33 |
+
}
|
34 |
+
|
35 |
+
public function display_payment_gateway_settings_form( $selected_gateway = null ) {
|
36 |
+
if ( ! $selected_gateway ) {
|
37 |
+
$selected_gateway = (string) get_user_option( 'wpsc_settings_selected_payment_gateway', get_current_user_id() );
|
38 |
+
}
|
39 |
+
$payment_data = $this->get_gateway_form( $selected_gateway );
|
40 |
+
if ( ! $payment_data ) {
|
41 |
+
$payment_data = array(
|
42 |
+
'name' => __( 'Edit Gateway Settings', 'wp-e-commerce' ),
|
43 |
+
'form_fields' => __( 'Modify the settings of a payment gateway by clicking the "Edit" link on the left.', 'wp-e-commerce' ),
|
44 |
+
'has_submit_button' => 1,
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
49 |
+
<div id="gateway_settings_<?php echo esc_attr( $selected_gateway ); ?>_form" class='gateway_settings_form'>
|
50 |
+
<table class='form-table'>
|
51 |
+
<tbody>
|
52 |
+
<?php echo $payment_data['form_fields']; ?>
|
53 |
+
<tr><td colspan="2">
|
54 |
+
<?php // hidden because most gateways provide their own update button. ?>
|
55 |
+
<?php if ( $payment_data['has_submit_button'] !== 1 ) { ?>
|
56 |
+
<p class="submit inline-edit-save">
|
57 |
+
<a class="button edit-payment-module-cancel" title="<?php esc_attr_e( "Cancel editing this Payment Gateway's settings", 'wp-e-commerce' ) ?>"><?php esc_html_e( "Cancel", 'wp-e-commerce' ); ?></a>
|
58 |
+
<input type="submit" name="submit" class="button button-primary edit-payment-module-update" value='<?php _e( "Update »", 'wp-e-commerce' ); ?>'>
|
59 |
+
</p>
|
60 |
+
<?php } ?>
|
61 |
+
</td></tr>
|
62 |
+
</tbody>
|
63 |
+
</table>
|
64 |
+
</div>
|
65 |
+
<?php
|
66 |
+
}
|
67 |
+
|
68 |
+
public function display() {
|
69 |
+
global $wpdb, $nzshpcrt_gateways;
|
70 |
+
?>
|
71 |
+
|
72 |
+
<h3><?php _e( 'Select Payment Gateways', 'wp-e-commerce' ); ?></h3>
|
73 |
+
<p><?php _e( 'Activate the payment gateways that you want to make available to your customers by selecting them below.', 'wp-e-commerce' ); ?></p>
|
74 |
+
|
75 |
+
<table id='wpsc-payment-gateway-settings' class='wpsc-edit-module-options wp-list-table widefat plugins'>
|
76 |
+
<thead>
|
77 |
+
<tr>
|
78 |
+
<th scope="col" id="wpsc-gateway-active" class="manage-column"></th>
|
79 |
+
<th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wp-e-commerce' ); ?></th>
|
80 |
+
<th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wp-e-commerce' ); ?></th>
|
81 |
+
</tr>
|
82 |
+
</thead>
|
83 |
+
<tfoot>
|
84 |
+
<tr>
|
85 |
+
<th scope="col" id="wpsc-gateway-active" class="manage-column"></th>
|
86 |
+
<th scope="col" id="wpsc-gateway-name" class="manage-column column-name"><?php _e( 'Payment Gateway', 'wp-e-commerce' ); ?></th>
|
87 |
+
<th scope="col" id="wpsc-gateway-display-name" class="manage-column column-description"><?php _e( 'Display Name', 'wp-e-commerce' ); ?></th>
|
88 |
+
</tr>
|
89 |
+
</tfoot>
|
90 |
+
<tbody>
|
91 |
+
<?php $this->gateway_list(); ?>
|
92 |
+
</tbody>
|
93 |
+
</table>
|
94 |
+
<?php submit_button( __( 'Save Changes', 'wp-e-commerce' ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
private function gateway_list_item( $gateway, $force ) {
|
98 |
+
$checked = in_array( $gateway['id'], $this->active_gateways );
|
99 |
+
|
100 |
+
$active = $checked ? 'active' : 'inactive';
|
101 |
+
$hidden = $force ? '' : "style='display: none;'";
|
102 |
+
|
103 |
+
$edithidden = $hidden;
|
104 |
+
|
105 |
+
$payment_gateway_names = get_option( 'payment_gateway_names' );
|
106 |
+
$display_name = isset( $payment_gateway_names[ $gateway['id'] ] ) ? $payment_gateway_names[ $gateway['id'] ] : '' ;
|
107 |
+
$gateway_data = false;
|
108 |
+
?>
|
109 |
+
<tr class="wpsc-select-gateway <?php echo $active; ?>" data-gateway-id="<?php echo esc_attr( $gateway['id'] ); ?>" id="gateway_list_item_<?php echo $gateway['id'];?>">
|
110 |
+
<th scope="row" class="check-column">
|
111 |
+
<label class="screen-reader-text" for="<?php echo esc_attr( $gateway['id'] ); ?>_id"><?php _e( "Select", 'wp-e-commerce' ); ?> <?php echo esc_html( $gateway['name'] ); ?></label>
|
112 |
+
<input name='wpsc_options[custom_gateway_options][]' <?php checked( $checked ); ?> type='checkbox' value='<?php echo esc_attr( $gateway['id'] ); ?>' id='<?php echo esc_attr( $gateway['id'] ); ?>_id' />
|
113 |
+
</th>
|
114 |
+
<td class="plugin-title">
|
115 |
+
<label for='<?php echo esc_attr( $gateway['id'] ); ?>_id'><strong><?php echo esc_html( $gateway['name'] ); ?></strong></label>
|
116 |
+
<div class="row-actions-visible">
|
117 |
+
<span class="edit">
|
118 |
+
<a class='edit-payment-module' title="<?php esc_attr_e( "Edit this Payment Gateway's Settings", 'wp-e-commerce' ) ?>" href='<?php echo esc_url( $this->get_gateway_settings_url( $gateway['id'] ) ); ?>'><?php esc_html_e( 'Settings', 'wp-e-commerce' ); ?></a>
|
119 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
120 |
+
</span>
|
121 |
+
</div>
|
122 |
+
</td>
|
123 |
+
<td class="plugin-description">
|
124 |
+
<?php echo esc_html( $display_name ); ?>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
<tr id="wpsc_gateway_settings_<?php echo esc_attr( $gateway['id'] ); ?>" data-gateway-id="<?php echo esc_attr( $gateway['id'] ); ?>" class='gateway_settings <?php echo $active; ?>' <?php echo $hidden; ?> >
|
128 |
+
<td colspan="3" id="wpsc_gateway_settings_<?php echo esc_attr( $gateway['id'] ); ?>_container">
|
129 |
+
<?php if ( $force ) {
|
130 |
+
$this->display_payment_gateway_settings_form( $gateway['id'] );
|
131 |
+
} ?>
|
132 |
+
</td>
|
133 |
+
</tr>
|
134 |
+
|
135 |
+
<?php
|
136 |
+
}
|
137 |
+
|
138 |
+
private function gateway_list() {
|
139 |
+
|
140 |
+
$gateways = apply_filters( 'wpsc_settings_get_gateways', array() );
|
141 |
+
|
142 |
+
usort( $gateways, apply_filters( 'wpsc_settings_get_gateways_sort_callback', array( $this, 'gateway_usort_callback' ), $gateways, $this ) );
|
143 |
+
|
144 |
+
$selected_gateway = (string) get_user_option( 'wpsc_settings_selected_payment_gateway', get_current_user_id() );
|
145 |
+
|
146 |
+
foreach ( $gateways as $gateway ) {
|
147 |
+
$this->gateway_list_item( $gateway, $selected_gateway === $gateway['id'] );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Usort callback used to order gateways by their name.
|
153 |
+
*
|
154 |
+
* @param array $a A gateway array.
|
155 |
+
* @param array $b A different gateway array.
|
156 |
+
*
|
157 |
+
* @since 3.9.0
|
158 |
+
*
|
159 |
+
* @return bool True if $b should be ordered after $a based on its name.
|
160 |
+
*/
|
161 |
+
private function gateway_usort_callback( $a, $b ) {
|
162 |
+
return $a['name'] > $b['name'];
|
163 |
+
}
|
164 |
+
|
165 |
+
public function callback_submit_options() {
|
166 |
+
do_action( 'wpsc_submit_gateway_options' );
|
167 |
+
}
|
168 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/general.php
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPSC_Settings_Tab_General extends WPSC_Settings_Tab {
|
3 |
+
private $regions = array();
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
$this->get_regions();
|
7 |
+
add_action( 'admin_notices', array( $this, 'no_target_markets' ) );
|
8 |
+
}
|
9 |
+
|
10 |
+
public function no_target_markets() {
|
11 |
+
|
12 |
+
$countries = WPSC_Countries::get_countries();
|
13 |
+
|
14 |
+
if ( empty( $countries ) ) {
|
15 |
+
?>
|
16 |
+
<div class="notice error is-dismissible below-h2">
|
17 |
+
<p><?php _e( '<strong>You have not enabled any target markets.</strong> To sell tangible goods, you will need to set at least one target market.', 'wp-e-commerce' ); ?></p>
|
18 |
+
</div>
|
19 |
+
<?php
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
private function get_regions() {
|
24 |
+
global $wpdb;
|
25 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['country'] ) )
|
26 |
+
$base_country = $_POST['country'];
|
27 |
+
else
|
28 |
+
$base_country = get_option( 'base_country' );
|
29 |
+
$from = WPSC_TABLE_REGION_TAX . ' AS r';
|
30 |
+
$join = WPSC_TABLE_CURRENCY_LIST . ' AS c';
|
31 |
+
$sql = $wpdb->prepare( "
|
32 |
+
SELECT r.id, r.name
|
33 |
+
FROM {$from}
|
34 |
+
INNER JOIN {$join} ON r.country_id = c.id AND c.isocode = %s
|
35 |
+
", $base_country );
|
36 |
+
$this->regions = $wpdb->get_results( $sql );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function display_region_drop_down() {
|
40 |
+
$base_region = get_option( 'base_region' );
|
41 |
+
if ( ! empty( $this->regions ) ):
|
42 |
+
?>
|
43 |
+
<select name='wpsc_options[base_region]'>
|
44 |
+
<?php foreach ( $this->regions as $region ): ?>
|
45 |
+
<option value='<?php echo esc_attr( $region->id ); ?>' <?php selected( $region->id, $base_region ); ?>><?php echo esc_html( $region->name ); ?></option>
|
46 |
+
<?php endforeach ?>
|
47 |
+
</select>
|
48 |
+
<?php
|
49 |
+
endif;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function display() {
|
53 |
+
global $wpdb;
|
54 |
+
?>
|
55 |
+
<h3><?php echo esc_html_e( 'General Settings', 'wp-e-commerce' ); ?></h3>
|
56 |
+
<table class='wpsc_options form-table'>
|
57 |
+
<tr>
|
58 |
+
<th scope="row"><label for="wpsc-base-country-drop-down"><?php esc_html_e( 'Base Country/Region', 'wp-e-commerce' ); ?></label></th>
|
59 |
+
<td>
|
60 |
+
<?php
|
61 |
+
wpsc_country_dropdown( array(
|
62 |
+
'id' => 'wpsc-base-country-drop-down',
|
63 |
+
'name' => 'wpsc_options[base_country]',
|
64 |
+
'selected' => get_option( 'base_country' ),
|
65 |
+
'include_invisible' => true,
|
66 |
+
) );
|
67 |
+
?>
|
68 |
+
<span id='wpsc-base-region-drop-down'>
|
69 |
+
<?php $this->display_region_drop_down(); ?>
|
70 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
71 |
+
</span>
|
72 |
+
<p class='description'><?php esc_html_e( 'Select your primary business location.', 'wp-e-commerce' ); ?></p>
|
73 |
+
</td>
|
74 |
+
</tr>
|
75 |
+
|
76 |
+
<?php
|
77 |
+
/* START OF TARGET MARKET SELECTION */
|
78 |
+
$countrylist = WPSC_Countries::get_countries_array( true, true );
|
79 |
+
?>
|
80 |
+
<tr>
|
81 |
+
<th scope="row">
|
82 |
+
<?php esc_html_e( 'Target Markets', 'wp-e-commerce' ); ?>
|
83 |
+
</th>
|
84 |
+
<td>
|
85 |
+
<?php
|
86 |
+
// check for the suhosin module
|
87 |
+
if ( wpsc_is_suhosin_enabled() ) {
|
88 |
+
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.", 'wp-e-commerce' ) . "</em>";
|
89 |
+
} else {
|
90 |
+
?>
|
91 |
+
<span>
|
92 |
+
<?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>' , 'wp-e-commerce') , esc_url( add_query_arg( array( 'selected_all' => 'all' ) ) ), esc_url( add_query_arg( array( 'selected_all' => 'none' ) ) ) ); ?>
|
93 |
+
</span><br />
|
94 |
+
<div id='wpsc-target-markets' class='ui-widget-content multiple-select'>
|
95 |
+
<?php foreach ( (array)$countrylist as $country ) : ?>
|
96 |
+
<?php if ( $country['visible'] == 1 ) : ?>
|
97 |
+
<input type='checkbox' id="countrylist2-<?php echo $country['id']; ?>" name='countrylist2[]' value='<?php echo $country['id']; ?>' checked='checked' />
|
98 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
99 |
+
<?php else : ?>
|
100 |
+
<input type='checkbox' id="countrylist2-<?php echo $country['id']; ?>" name='countrylist2[]' value='<?php echo $country['id']; ?>' />
|
101 |
+
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br />
|
102 |
+
<?php endif; ?>
|
103 |
+
<?php endforeach; ?>
|
104 |
+
</div>
|
105 |
+
|
106 |
+
<p class='description'><?php esc_html_e( 'Select the markets you are selling products to.' , 'wp-e-commerce'); ?></p>
|
107 |
+
<?php
|
108 |
+
}
|
109 |
+
?>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
|
113 |
+
<?php
|
114 |
+
$stock_keeping_time = wpsc_get_stock_keeping_time();
|
115 |
+
$stock_keeping_interval = wpsc_get_stock_keeping_interval();
|
116 |
+
?>
|
117 |
+
<tr>
|
118 |
+
<th scope="row">
|
119 |
+
<label for="wpsc-stock-keeping-time"><?php esc_html_e( 'Keep stock in cart for', 'wp-e-commerce' ); ?></label>
|
120 |
+
</th>
|
121 |
+
<td>
|
122 |
+
<input type="text" name="wpsc_options[wpsc_stock_keeping_time]" id="wpsc-stock-keeping-time" size="2" value="<?php echo esc_attr( $stock_keeping_time ); ?>" />
|
123 |
+
<select name="wpsc_options[wpsc_stock_keeping_interval]">
|
124 |
+
<option value="hour" <?php selected( 'hour', $stock_keeping_interval ); ?>><?php echo _n( 'hour', 'hours', $stock_keeping_time, 'wp-e-commerce' ); ?></option>
|
125 |
+
<option value="day" <?php selected( 'day', $stock_keeping_interval ); ?>><?php echo _n( 'day', 'days', $stock_keeping_time, 'wp-e-commerce' ) ?></option>
|
126 |
+
<option value="week" <?php selected( 'week', $stock_keeping_interval ); ?>><?php echo _n( 'week', 'weeks', $stock_keeping_time, 'wp-e-commerce' ) ?></option>
|
127 |
+
</select>
|
128 |
+
<p class='description'><?php esc_html_e( "Set the amount of time items in a customer's cart are reserved. You can also specify decimal amounts such as '0.5 days' or '1.25 weeks'. Note that the minimum interval you can enter is 1 hour, i.e. you can't schedule it to run every 0.5 hour.", 'wp-e-commerce' ) ?></p>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
|
132 |
+
<?php
|
133 |
+
$hierarchical_category = get_option( 'product_category_hierarchical_url', 0 );
|
134 |
+
?>
|
135 |
+
<tr>
|
136 |
+
<th scope="row">
|
137 |
+
<?php _e( 'Use Hierarchical Product Category URL', 'wp-e-commerce' ); ?>
|
138 |
+
</th>
|
139 |
+
<td>
|
140 |
+
<label><input type="radio" <?php checked( $hierarchical_category, 1 ); ?> name="wpsc_options[product_category_hierarchical_url]" value="1" /> <?php _e( 'Yes', 'wp-e-commerce' ); ?></label>
|
141 |
+
<label><input type="radio" <?php checked( $hierarchical_category, 0 ); ?>name="wpsc_options[product_category_hierarchical_url]" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label><br />
|
142 |
+
<p class='description'><?php _e( 'When Hierarchical Product Category URL is enabled, parent product categories are also included in the product URL.<br />For example: <code>http://example.com/products-page/parent-cat/sub-cat/product-name</code>', 'wp-e-commerce' ); ?></p>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
</table>
|
146 |
+
|
147 |
+
<h3 class="form_group"><?php esc_html_e( 'Currency Settings', 'wp-e-commerce' ); ?></h3>
|
148 |
+
<table class='wpsc_options form-table'>
|
149 |
+
<?php
|
150 |
+
$currency_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
|
151 |
+
$currency_type = esc_attr( get_option( 'currency_type' ) );
|
152 |
+
?>
|
153 |
+
<tr>
|
154 |
+
<th scope="row"><label for="wpsc_options_currency_type"><?php esc_html_e( 'Currency Type', 'wp-e-commerce' ); ?></label></th>
|
155 |
+
<td>
|
156 |
+
<select id="wpsc_options_currency_type" name='wpsc_options[currency_type]' onchange='getcurrency(this.options[this.selectedIndex].value);'>
|
157 |
+
<?php foreach ( $currency_data as $currency ) : ?>
|
158 |
+
<option value='<?php echo $currency['id']; ?>' <?php selected( $currency['id'], $currency_type ); ?>><?php echo esc_html( $currency['country'] ); ?> (<?php echo $currency['currency']; ?>)</option>
|
159 |
+
<?php endforeach; ?>
|
160 |
+
</select>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
|
164 |
+
<?php
|
165 |
+
$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 );
|
166 |
+
|
167 |
+
if ( $currency_data['symbol'] != '' ) {
|
168 |
+
$currency_sign = esc_attr( $currency_data['symbol_html'] );
|
169 |
+
} else {
|
170 |
+
$currency_sign = esc_attr( $currency_data['code'] );
|
171 |
+
}
|
172 |
+
|
173 |
+
$currency_sign_location = esc_attr( get_option( 'currency_sign_location' ) );
|
174 |
+
$csl1 = "";
|
175 |
+
$csl2 = "";
|
176 |
+
$csl3 = "";
|
177 |
+
$csl4 = "";
|
178 |
+
switch ( $currency_sign_location ) {
|
179 |
+
case 1:
|
180 |
+
$csl1 = "checked='checked'";
|
181 |
+
break;
|
182 |
+
|
183 |
+
case 2:
|
184 |
+
$csl2 = "checked='checked'";
|
185 |
+
break;
|
186 |
+
|
187 |
+
case 3:
|
188 |
+
$csl3 = "checked='checked'";
|
189 |
+
break;
|
190 |
+
|
191 |
+
case 4:
|
192 |
+
$csl4 = "checked='checked'";
|
193 |
+
break;
|
194 |
+
}
|
195 |
+
?>
|
196 |
+
<tr>
|
197 |
+
<th scope="row"><?php esc_html_e( 'Currency Sign Location', 'wp-e-commerce' ); ?></th>
|
198 |
+
<td>
|
199 |
+
<input type='radio' value='1' name='wpsc_options[currency_sign_location]' id='csl1' <?php echo $csl1; ?> />
|
200 |
+
<label for='csl1'><?php _ex( '100', 'Currency sign location - option 1', 'wp-e-commerce' ); ?><span id='cslchar1'><?php echo $currency_sign; ?></span></label>
|
201 |
+
<input type='radio' value='2' name='wpsc_options[currency_sign_location]' id='csl2' <?php echo $csl2; ?> />
|
202 |
+
<label for='csl2'><?php _ex( '100', 'Currency sign location - option 2', 'wp-e-commerce' ); ?> <span id='cslchar2'><?php echo $currency_sign; ?></span></label>
|
203 |
+
<input type='radio' value='3' name='wpsc_options[currency_sign_location]' id='csl3' <?php echo $csl3; ?> />
|
204 |
+
<label for='csl3'><span id='cslchar3'><?php echo $currency_sign; ?></span><?php _ex( '100', 'Currency sign location - option 3', 'wp-e-commerce' ); ?></label>
|
205 |
+
<input type='radio' value='4' name='wpsc_options[currency_sign_location]' id='csl4' <?php echo $csl4; ?> />
|
206 |
+
<label for='csl4'><span id='cslchar4'><?php echo $currency_sign; ?></span> <?php _ex( '100', 'Currency sign location - option 4', 'wp-e-commerce' ); ?></label>
|
207 |
+
</td>
|
208 |
+
</tr>
|
209 |
+
<tr>
|
210 |
+
<th scope="row"><?php esc_html_e( 'Thousands and decimal separators', 'wp-e-commerce' ); ?></th>
|
211 |
+
<td>
|
212 |
+
<label for="wpsc_options_wpsc_thousands_separator"><?php esc_html_e( 'Thousands separator', 'wp-e-commerce' ); ?></label>: <input name="wpsc_options[wpsc_thousands_separator]" id="wpsc_options_wpsc_thousands_separator" type="text" maxlength="1" size="1" value="<?php echo esc_attr( get_option( 'wpsc_thousands_separator' ) ); ?>" /><br />
|
213 |
+
<label for="wpsc_options_wpsc_decimal_separator"><?php esc_html_e( 'Decimal separator', 'wp-e-commerce' ); ?></label>: <input name="wpsc_options[wpsc_decimal_separator]" id="wpsc_options_wpsc_decimal_separator" type="text" maxlength="1" size="1" value="<?php echo esc_attr( get_option( 'wpsc_decimal_separator' ) ); ?>" /><br />
|
214 |
+
<?php esc_html_e( 'Preview:', 'wp-e-commerce' ); ?> 10<?php echo esc_attr( get_option( 'wpsc_thousands_separator' ) ); ?>000<?php echo esc_attr( get_option( 'wpsc_decimal_separator' ) ); ?>00
|
215 |
+
</td>
|
216 |
+
</tr>
|
217 |
+
</table>
|
218 |
+
|
219 |
+
<h3 class="form_group"><?php esc_html_e( 'Usage Tracking', 'wp-e-commerce' ); ?></h3>
|
220 |
+
<table class='wpsc_options form-table'>
|
221 |
+
<tr>
|
222 |
+
<th scope="row">
|
223 |
+
<label for="wpsc_options_usage_tracking"><?php esc_html_e( 'Allow Usage Tracking ?', 'wp-e-commerce' ); ?></label>
|
224 |
+
</th>
|
225 |
+
<td>
|
226 |
+
<?php $usage_tracking = get_option( 'wpsc_usage_tracking', 0 ); ?>
|
227 |
+
<label><input type="radio" <?php checked( $usage_tracking, 1 ); ?> name="wpsc_options[wpsc_usage_tracking]" value="1" /> <?php _e( 'Yes', 'wp-e-commerce' ); ?></label>
|
228 |
+
<label><input type="radio" <?php checked( $usage_tracking, 0 ); ?>name="wpsc_options[wpsc_usage_tracking]" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label><br />
|
229 |
+
<p class='description'>
|
230 |
+
<?php echo sprintf(
|
231 |
+
__( 'Allow WP eCommerce to anonymously track how this plugin is used and help us make the plugin better. Opt-in to tracking and our newsletter and immediately be emailed a 20% discount to the WPeC shop, valid towards the <a href="%s" target="_blank">purchase of extensions</a>. No sensitive data is tracked.', 'wp-e-commerce' ),
|
232 |
+
'https://wpecommerce.org/store/' );
|
233 |
+
?>
|
234 |
+
</p>
|
235 |
+
</td>
|
236 |
+
</tr>
|
237 |
+
</table>
|
238 |
+
<?php
|
239 |
+
}
|
240 |
+
} // end class
|
trunk/wpsc-admin/includes/settings-tabs/import.php
ADDED
@@ -0,0 +1,367 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Import extends WPSC_Settings_Tab {
|
4 |
+
|
5 |
+
private $file = false;
|
6 |
+
private $step = 1;
|
7 |
+
private $display_data = array();
|
8 |
+
private $completed = false;
|
9 |
+
private $default_fields = array();
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
|
13 |
+
parent::__construct();
|
14 |
+
|
15 |
+
$file = get_transient( 'wpsc_settings_tab_import_file' );
|
16 |
+
|
17 |
+
if ( $file ) {
|
18 |
+
$this->file = $file;
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->step = empty( $_REQUEST['step'] ) ? 1 : (int) $_REQUEST['step'];
|
22 |
+
|
23 |
+
if ( $this->step < 1 || $this->step > 3 ) {
|
24 |
+
$this->step = 1;
|
25 |
+
}
|
26 |
+
|
27 |
+
$this->default_fields = apply_filters( 'wpsc_product_import_default_fields', array(
|
28 |
+
'column_name' => __( 'Product Name' , 'wp-e-commerce' ),
|
29 |
+
'column_description' => __( 'Description' , 'wp-e-commerce' ),
|
30 |
+
'column_additional_description' => __( 'Additional Description', 'wp-e-commerce' ),
|
31 |
+
'column_price' => __( 'Price' , 'wp-e-commerce' ),
|
32 |
+
'column_sku' => __( 'SKU' , 'wp-e-commerce' ),
|
33 |
+
'column_weight' => __( 'Weight' , 'wp-e-commerce' ),
|
34 |
+
'column_weight_unit' => __( 'Weight Unit' , 'wp-e-commerce' ),
|
35 |
+
'column_quantity' => __( 'Stock Quantity' , 'wp-e-commerce' ),
|
36 |
+
'column_quantity_limited' => __( 'Stock Quantity Limit' , 'wp-e-commerce' )
|
37 |
+
) );
|
38 |
+
|
39 |
+
switch ( $this->step ) {
|
40 |
+
case 2:
|
41 |
+
$this->prepare_import_columns();
|
42 |
+
break;
|
43 |
+
case 3:
|
44 |
+
$this->import_data();
|
45 |
+
break;
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->hide_submit_button();
|
49 |
+
}
|
50 |
+
|
51 |
+
private function prepare_import_columns() {
|
52 |
+
$this->hide_update_message();
|
53 |
+
|
54 |
+
ini_set( 'auto_detect_line_endings', 1 );
|
55 |
+
$handle = @fopen( $this->file, 'r' );
|
56 |
+
|
57 |
+
if ( ! $handle ) {
|
58 |
+
$this->reset_state();
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
|
62 |
+
$rows = array();
|
63 |
+
|
64 |
+
while ( count( $rows ) < 5 && ( false !== ( $data = fgetcsv( $handle ) ) ) ) {
|
65 |
+
array_push( $rows, $data );
|
66 |
+
}
|
67 |
+
|
68 |
+
$sample_row_data = array();
|
69 |
+
|
70 |
+
foreach ( $rows as $row => $columns ) {
|
71 |
+
foreach ( $columns as $column => $data ) {
|
72 |
+
|
73 |
+
if ( ! isset( $sample_row_data[ $column ] ) ) {
|
74 |
+
$sample_row_data[ $column ] = array();
|
75 |
+
}
|
76 |
+
|
77 |
+
array_push( $sample_row_data[ $column ], $data );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
$categories = get_terms( 'wpsc_product_category', 'hide_empty=0' );
|
82 |
+
|
83 |
+
$this->display_data = array(
|
84 |
+
'sample_row_data' => $sample_row_data,
|
85 |
+
'categories' => $categories,
|
86 |
+
);
|
87 |
+
}
|
88 |
+
|
89 |
+
private function reset_state() {
|
90 |
+
delete_transient( 'wpsc_settings_tab_import_file' );
|
91 |
+
$this->file = false;
|
92 |
+
$this->completed = false;
|
93 |
+
$this->display_data = array();
|
94 |
+
}
|
95 |
+
|
96 |
+
private function import_data() {
|
97 |
+
ini_set( 'auto_detect_line_endings', 1 );
|
98 |
+
|
99 |
+
$handle = @fopen( $this->file, 'r' );
|
100 |
+
|
101 |
+
if ( ! $handle ) {
|
102 |
+
$this->reset_state();
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
|
106 |
+
$length = filesize( $this->file );
|
107 |
+
|
108 |
+
$column_map = array_flip( $_POST['value_name'] );
|
109 |
+
|
110 |
+
extract( $column_map, EXTR_SKIP );
|
111 |
+
|
112 |
+
$record_count = 0;
|
113 |
+
|
114 |
+
while ( $row = @fgetcsv( $handle, $length, ',' ) ) {
|
115 |
+
|
116 |
+
$product = array(
|
117 |
+
'post_title' => isset( $row[ $column_name ] ) ? $row[ $column_name ] : '',
|
118 |
+
'content' => isset( $row[ $column_description ] ) ? $row[ $column_description ] : '',
|
119 |
+
'price' => isset( $row[ $column_price ] ) ? str_replace( '$', '', $row[ $column_price ] ) : 0,
|
120 |
+
'weight' => isset( $row[ $column_weight ] ) ? $row[ $column_weight] : '',
|
121 |
+
'weight_unit' => isset( $row[ $column_weight_unit ] ) ? $row[ $column_weight_unit ] : '',
|
122 |
+
'additional_description' => isset( $row[ $column_additional_description ] ) ? $row[ $column_additional_description ] : '',
|
123 |
+
'pnp' => null,
|
124 |
+
'international_pnp' => null,
|
125 |
+
'file' => null,
|
126 |
+
'image' => '0',
|
127 |
+
'quantity_limited' => isset( $row[ $column_quantity_limited ] ) ? $row[ $column_quantity_limited ] : '',
|
128 |
+
'quantity' => isset( $row[ $column_quantity ] ) ? $row[ $column_quantity ] : null,
|
129 |
+
'special' => null,
|
130 |
+
'special_price' => null,
|
131 |
+
'display_frontpage' => null,
|
132 |
+
'notax' => null,
|
133 |
+
'active' => null,
|
134 |
+
'donation' => null,
|
135 |
+
'no_shipping' => null,
|
136 |
+
'thumbnail_image' => null,
|
137 |
+
'thumbnail_state' => null,
|
138 |
+
'meta' => array(
|
139 |
+
'_wpsc_price' => isset( $row[$column_price] ) ? str_replace( '$', '', $row[$column_price] ) : 0,
|
140 |
+
'_wpsc_special_price' => '',
|
141 |
+
'_wpsc_sku' => isset( $row[$column_sku] ) ? $row[$column_sku] : '',
|
142 |
+
'_wpsc_stock' => isset( $row[$column_quantity] ) ? $row[$column_quantity] : null,
|
143 |
+
'_wpsc_limited_stock' => isset( $row[$column_quantity_limited] ) ? $row[$column_quantity_limited] : '',
|
144 |
+
'_wpsc_product_metadata' => array(
|
145 |
+
'weight' => isset( $row[$column_weight] ) ? $row[$column_weight] : '',
|
146 |
+
'weight_unit' => isset( $row[$column_weight_unit] ) ? $row[$column_weight_unit] : '',
|
147 |
+
)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
|
151 |
+
$product = apply_filters( 'wpsc_product_import_row', $product, $row, $this );
|
152 |
+
|
153 |
+
if ( empty( $product['post_title'] ) && apply_filters( 'wpsc_product_import_require_title', true, $product, $row, $this ) ) {
|
154 |
+
continue;
|
155 |
+
}
|
156 |
+
|
157 |
+
$product = wpsc_sanitise_product_forms( $product );
|
158 |
+
|
159 |
+
// status needs to be set here because wpsc_sanitise_product_forms overwrites it :/
|
160 |
+
$product['post_status'] = $_POST['post_status'];
|
161 |
+
|
162 |
+
$product_id = wpsc_insert_product( $product );
|
163 |
+
|
164 |
+
if ( (int) $_POST['category'] > 0 ) {
|
165 |
+
wp_set_object_terms( $product_id , array( (int) $_POST['category'] ) , 'wpsc_product_category' );
|
166 |
+
}
|
167 |
+
|
168 |
+
$record_count += 1;
|
169 |
+
}
|
170 |
+
|
171 |
+
$this->reset_state();
|
172 |
+
$this->completed = true;
|
173 |
+
add_settings_error( 'wpsc-settings', 'settings_updated', sprintf( __( 'CSV file successfully processed. %s record(s) imported.', 'wp-e-commerce' ), $record_count ), 'updated' );
|
174 |
+
}
|
175 |
+
|
176 |
+
public function callback_submit_options() {
|
177 |
+
if ( isset( $_FILES['csv_file'] ) && isset( $_FILES['csv_file']['name'] ) && ($_FILES['csv_file']['name'] != '') ) {
|
178 |
+
$this->hide_update_message();
|
179 |
+
ini_set( 'auto_detect_line_endings', 1 );
|
180 |
+
$file = $_FILES['csv_file'];
|
181 |
+
$file_path = WPSC_FILE_DIR . $file['name'];
|
182 |
+
if ( move_uploaded_file( $file['tmp_name'], WPSC_FILE_DIR . $file['name'] ) ) {
|
183 |
+
set_transient( 'wpsc_settings_tab_import_file', $file_path );
|
184 |
+
return array( 'step' => 2 );
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
if ( $this->completed ) {
|
189 |
+
return array( 'step' => 1 );
|
190 |
+
}
|
191 |
+
|
192 |
+
return array( 'step' => $this->step + 1 );
|
193 |
+
}
|
194 |
+
|
195 |
+
private function display_imported_columns() {
|
196 |
+
extract( $this->display_data );
|
197 |
+
?>
|
198 |
+
<h3 class='hndle'><?php esc_html_e( 'Assign CSV Columns to Product Fields', 'wp-e-commerce'); ?></h3>
|
199 |
+
<p><?php esc_html_e( 'For each column, select the field it corresponds to in \'Product Field\'.', 'wp-e-commerce' ); ?></p>
|
200 |
+
<p><?php esc_html_e( 'Note: In this view we only show sample data from the first 5 records. All records in the uploaded import file will actually be imported.', 'wp-e-commerce' ); ?></p>
|
201 |
+
<table class='wp-list-table widefat plugins' id="wpsc_imported_columns">
|
202 |
+
<thead>
|
203 |
+
<tr>
|
204 |
+
<th scope="col" class="manage-column"><?php _e( 'Column', 'wp-e-commerce' ); ?></th>
|
205 |
+
<th scope="col" class="manage-column"><?php _e( 'Sample Data from Column', 'wp-e-commerce' ); ?></th>
|
206 |
+
<th scope="col" class="manage-column"><?php _e( 'Product Field', 'wp-e-commerce' ); ?></th>
|
207 |
+
</tr>
|
208 |
+
</thead>
|
209 |
+
<tbody>
|
210 |
+
<?php foreach ( $sample_row_data as $key => $sample_data ) : ?>
|
211 |
+
<tr>
|
212 |
+
<td>
|
213 |
+
<p><?php printf( __('Column %s', 'wp-e-commerce' ), $this->num_to_alphacolumn( $key ) ); ?></p>
|
214 |
+
</td>
|
215 |
+
<td>
|
216 |
+
<ol>
|
217 |
+
<?php foreach ($sample_data as $datum) : ?>
|
218 |
+
<li>
|
219 |
+
<?php if ( $datum != "" ): ?>
|
220 |
+
<code><?php echo esc_html( $datum ); ?></code>
|
221 |
+
<?php else: ?>
|
222 |
+
<?php _e( '<em class="empty">empty</em>', 'wp-e-commerce' ); ?>
|
223 |
+
<?php endif; ?>
|
224 |
+
</li>
|
225 |
+
<?php endforeach; ?>
|
226 |
+
</ol>
|
227 |
+
</td>
|
228 |
+
<td>
|
229 |
+
<p>
|
230 |
+
<select name='value_name[<?php echo $key; ?>]'>
|
231 |
+
<?php
|
232 |
+
$i = 0;
|
233 |
+
foreach ( $this->default_fields as $value => $label ) :
|
234 |
+
?>
|
235 |
+
<option <?php selected( $key, $i ); ?> value='<?php echo esc_attr( $value ); ?>'><?php echo esc_html( $label ); ?></option>
|
236 |
+
<?php
|
237 |
+
$i++;
|
238 |
+
endforeach;
|
239 |
+
?>
|
240 |
+
</select>
|
241 |
+
</p>
|
242 |
+
</td>
|
243 |
+
</tr>
|
244 |
+
<?php endforeach; ?>
|
245 |
+
</tbody>
|
246 |
+
</table>
|
247 |
+
<h3><?php esc_html_e( 'Import Options', 'wp-e-commerce' ); ?></h3>
|
248 |
+
<table class='form-table'>
|
249 |
+
<tr>
|
250 |
+
<th>
|
251 |
+
<label for='post_status'><?php esc_html_e( 'Product Status' , 'wp-e-commerce' ); ?>
|
252 |
+
</th>
|
253 |
+
<td>
|
254 |
+
<select name='post_status' id='post_status'>
|
255 |
+
<option value='publish'><?php esc_html_e( 'Publish', 'wp-e-commerce' ); ?></option>
|
256 |
+
<option value='draft' ><?php esc_html_e( 'Draft' , 'wp-e-commerce' ); ?></option>
|
257 |
+
</select>
|
258 |
+
<p class="description">
|
259 |
+
<?php esc_html_e( 'Set your imported products as drafts, or publish them right away.' , 'wp-e-commerce' ); ?>
|
260 |
+
</p>
|
261 |
+
</td>
|
262 |
+
</tr>
|
263 |
+
<tr>
|
264 |
+
<th><label for="category"><?php esc_html_e( 'Import to Category', 'wp-e-commerce' ); ?></label></th>
|
265 |
+
<td>
|
266 |
+
<select id='category' name='category'>
|
267 |
+
<option value=""><?php esc_html_e( "No Category", 'wp-e-commerce' ); ?></option>
|
268 |
+
<?php foreach ( $categories as $category ): ?>
|
269 |
+
<option value="<?php echo $category->term_id; ?>"><?php echo esc_html( $category->name ); ?></option>
|
270 |
+
<?php endforeach; ?>
|
271 |
+
</select>
|
272 |
+
<p class="description">
|
273 |
+
<?php esc_html_e( 'Products imported from this CSV file will be placed in the selected category.', 'wp-e-commerce' ); ?></p>
|
274 |
+
</p>
|
275 |
+
</td>
|
276 |
+
</tr>
|
277 |
+
</table>
|
278 |
+
<input type="hidden" name="step" value="3" />
|
279 |
+
<input type='submit' value='<?php echo esc_html_x( 'Import Products', 'import csv', 'wp-e-commerce' ); ?>' class='button-primary'>
|
280 |
+
<?php
|
281 |
+
}
|
282 |
+
|
283 |
+
private function num_to_alphacolumn($n) {
|
284 |
+
// from http://stackoverflow.com/questions/3302857/algorithm-to-get-the-excel-like-column-name-of-a-number
|
285 |
+
|
286 |
+
for( $r = ""; $n >= 0; $n = intval( $n / 26 ) - 1 ) {
|
287 |
+
$r = chr( $n % 26 + 0x41) . $r;
|
288 |
+
}
|
289 |
+
|
290 |
+
return $r;
|
291 |
+
}
|
292 |
+
|
293 |
+
private function display_default() {
|
294 |
+
extract( $this->display_data );
|
295 |
+
?>
|
296 |
+
<h3><?php _e( 'Import Products', 'wp-e-commerce' ); ?></h3>
|
297 |
+
<p><?php _e( 'You can import your products from a <a href="http://en.wikipedia.org/wiki/Comma-separated_values"><abbr title="Comma-separated values">CSV</abbr> (Comma-separated values) file</a>, exportable from most spread-sheet programs or other software.</p>', 'wp-e-commerce' ); ?></p>
|
298 |
+
|
299 |
+
<h4><?php _e( 'Import New Products from CSV', 'wp-e-commerce' ); ?></h4>
|
300 |
+
<table class='form-table'>
|
301 |
+
<tr>
|
302 |
+
<th><label for='wpsc_csv_file'><?php _e( 'CSV File', 'wp-e-commerce' ); ?><label></th>
|
303 |
+
<td>
|
304 |
+
<input type='file' name='csv_file' id='wpsc_csv_file' />
|
305 |
+
</td>
|
306 |
+
</tr>
|
307 |
+
</table>
|
308 |
+
|
309 |
+
<?php submit_button( esc_html_x( 'Upload', 'import csv', 'wp-e-commerce' ) ); ?>
|
310 |
+
|
311 |
+
<h4><?php _e( 'Useful Information', 'wp-e-commerce' ); ?></h4>
|
312 |
+
<table class='form-table'>
|
313 |
+
<tr>
|
314 |
+
<th><?php echo _e( 'Supported Fields', 'wp-e-commerce' ); ?></th>
|
315 |
+
<td>
|
316 |
+
<?php _e( 'Columns supported are, in their default order:', 'wp-e-commerce'); ?><br />
|
317 |
+
<code>
|
318 |
+
<?php echo implode( ', ', $this->default_fields ); ?>
|
319 |
+
</code>
|
320 |
+
</td>
|
321 |
+
</tr>
|
322 |
+
<tr>
|
323 |
+
<th><?php _e( 'Understood Weight Units', 'wp-e-commerce' ); ?></th>
|
324 |
+
<td>
|
325 |
+
<?php _e( 'Metric', 'wp-e-commerce' ); ?>: <code>kilogram</code>,<code>kilograms</code>,<code>kg</code>,<code>kgs</code>,<code>gram</code>,<code>grams</code>,<code>g</code>,<code>gs</code><br />
|
326 |
+
<?php _e( 'Imperial', 'wp-e-commerce' ); ?>: <code>ounce</code>,<code>ounces</code>,<code>oz</code>,<code>pound</code>,<code>pounds</code>,<code>lb</code>,<code>lbs</code>
|
327 |
+
</td>
|
328 |
+
</tr>
|
329 |
+
<tr>
|
330 |
+
<th><?php _e( 'Stock Fields', 'wp-e-commerce' ); ?></th>
|
331 |
+
<td>
|
332 |
+
<?php _e( '<code>Stock Quantity</code> values are used only when <code>Stock Quantity Limited</code> is blank or <code>""</code>.', 'wp-e-commerce' ); ?>
|
333 |
+
</td>
|
334 |
+
</tr>
|
335 |
+
<tr>
|
336 |
+
<th><?php _e( 'HTML', 'wp-e-commerce' ); ?></th>
|
337 |
+
<td>
|
338 |
+
<?php _e( 'Supported in <code>Description</code> and <code>Additional Description</code>. Be sure you "quote" the whole description, and slash-escape \"quotes\" inside the description itself.', 'wp-e-commerce' ); ?>
|
339 |
+
</tr>
|
340 |
+
<tr>
|
341 |
+
<th><?php _e( 'Example CSV File', 'wp-e-commerce' ); ?></th>
|
342 |
+
<td>
|
343 |
+
<ol>
|
344 |
+
<li><code><?php esc_html_e( 'Banana, The Yellow Fruit, Contains Potassium, 0.67, "BANANA", 150, "g", 0, ""', 'wp-e-commerce' ); ?></code></li>
|
345 |
+
<li><code><?php esc_html_e( '"Apple, red", "Red, round, juicy. Isn\'t an <a href=\"http://example.com\">orange</a>.", "Red Delicious", 0.25, "RED_DELICIOUS", 5, "oz", 10, true', 'wp-e-commerce' ); ?></code></li>
|
346 |
+
</ol>
|
347 |
+
</td>
|
348 |
+
</tr>
|
349 |
+
</table>
|
350 |
+
|
351 |
+
<?php
|
352 |
+
}
|
353 |
+
|
354 |
+
public function display() {
|
355 |
+
switch ( $this->step ) {
|
356 |
+
case 1:
|
357 |
+
$this->display_default();
|
358 |
+
break;
|
359 |
+
case 2:
|
360 |
+
$this->display_imported_columns();
|
361 |
+
break;
|
362 |
+
default:
|
363 |
+
$this->display_default();
|
364 |
+
break;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/marketing.php
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Marketing extends WPSC_Settings_Tab {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
add_action( 'admin_notices', array( $this, 'yoast_check' ) );
|
7 |
+
}
|
8 |
+
|
9 |
+
public function yoast_check() {
|
10 |
+
$yoast_options = get_option( 'Yoast_Google_Analytics' );
|
11 |
+
$wpec_tracking = isset( $yoast_options['wpec_tracking'] ) && $yoast_options['wpec_tracking'] ? true : false;
|
12 |
+
|
13 |
+
if ( $wpec_tracking ) {
|
14 |
+
?>
|
15 |
+
<div class="error">
|
16 |
+
<p><?php _e( '<strong>You appear to have Google Analytics for WordPress installed.</strong>. <br /> This is not a problem, however, you also appear to have the WPeC tracking enabled. We highly recommend disabling that setting and using the settings on this page.', 'wp-e-commerce' ); ?></p>
|
17 |
+
</div>
|
18 |
+
<?php
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
public function display() {
|
23 |
+
$this->marketing_settings_form();
|
24 |
+
$this->rss_address_settings_form();
|
25 |
+
$this->google_merch_center_settings_form();
|
26 |
+
$this->google_analytics_integration_settings_form();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function marketing_settings_form() {
|
30 |
+
|
31 |
+
$wpsc_also_bought = get_option( 'wpsc_also_bought' );
|
32 |
+
$wpsc_also_bought1 = '';
|
33 |
+
|
34 |
+
if ( '1' == $wpsc_also_bought )
|
35 |
+
$wpsc_also_bought1 = "checked='checked'";
|
36 |
+
|
37 |
+
$wpsc_share_this = get_option( 'wpsc_share_this' );
|
38 |
+
$wpsc_share_this1 = '';
|
39 |
+
|
40 |
+
if ( '1' == $wpsc_share_this )
|
41 |
+
$wpsc_share_this1 = "checked='checked'";
|
42 |
+
|
43 |
+
$facebook_like = get_option( 'wpsc_facebook_like' );
|
44 |
+
$facebook_like1 = '';
|
45 |
+
if ( 'on' == $facebook_like )
|
46 |
+
$facebook_like1 = "checked='checked'";
|
47 |
+
|
48 |
+
$display_find_us = get_option( 'display_find_us' );
|
49 |
+
$display_find_us1 = '';
|
50 |
+
|
51 |
+
if ( '1' == $display_find_us )
|
52 |
+
$display_find_us1 = "checked='checked'";
|
53 |
+
|
54 |
+
?>
|
55 |
+
|
56 |
+
<h3><?php esc_html_e( 'Marketing Settings', 'wp-e-commerce'); ?></h3>
|
57 |
+
<table class='form-table'>
|
58 |
+
<tr>
|
59 |
+
<th>
|
60 |
+
<?php esc_html_e( "'Users who bought this also bought'", 'wp-e-commerce' ); ?>
|
61 |
+
</th>
|
62 |
+
<td>
|
63 |
+
<label>
|
64 |
+
<input <?php echo $wpsc_also_bought1; ?> type='checkbox' name='wpsc_also_bought' />
|
65 |
+
<?php esc_html_e( "Add 'Users who bought this also bought' item to the single products page.", 'wp-e-commerce' ); ?>
|
66 |
+
</label>
|
67 |
+
</td>
|
68 |
+
</tr>
|
69 |
+
<tr>
|
70 |
+
<th>
|
71 |
+
<?php esc_html_e( "'Share This' Social Bookmarks", 'wp-e-commerce' ); ?>
|
72 |
+
</th>
|
73 |
+
<td>
|
74 |
+
<label>
|
75 |
+
<input <?php echo $wpsc_share_this1; ?> type='checkbox' name='wpsc_share_this' />
|
76 |
+
<?php esc_html_e( 'Add the \'Share this link\' item to the single products page.', 'wp-e-commerce' ); ?>
|
77 |
+
</label>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
<tr>
|
81 |
+
<th>
|
82 |
+
<?php esc_html_e( "'How Customer Found Us' Survey", 'wp-e-commerce' ) ?>
|
83 |
+
</th>
|
84 |
+
<td>
|
85 |
+
<label>
|
86 |
+
<input <?php echo $display_find_us1; ?> type='checkbox' name='display_find_us' />
|
87 |
+
<?php esc_html_e( 'Add the \'How did you find out about us\' drop-down option at checkout.', 'wp-e-commerce' ); ?>
|
88 |
+
</label>
|
89 |
+
</td>
|
90 |
+
</tr>
|
91 |
+
<tr>
|
92 |
+
<th>
|
93 |
+
<?php esc_html_e( "Facebook 'Like' Button", 'wp-e-commerce' ) ?>
|
94 |
+
</th>
|
95 |
+
<td>
|
96 |
+
<input type='hidden' value='0' name='wpsc_options[wpsc_facebook_like]' />
|
97 |
+
<input <?php echo $facebook_like1; ?> type='checkbox' name='wpsc_options[wpsc_facebook_like]' />
|
98 |
+
<?php esc_html_e( 'Add the Facebook Like button on your single products page.', 'wp-e-commerce' ); ?>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
</table>
|
102 |
+
<?php
|
103 |
+
}
|
104 |
+
|
105 |
+
public function rss_address_settings_form() {
|
106 |
+
?>
|
107 |
+
<h3><?php esc_html_e( 'Product RSS Address', 'wp-e-commerce'); ?></h3>
|
108 |
+
<p><?php esc_html_e( 'People can use this RSS feed to keep up to date with your product list.', 'wp-e-commerce' ); ?></p>
|
109 |
+
|
110 |
+
<table class='form-table'>
|
111 |
+
<tr>
|
112 |
+
<th>
|
113 |
+
<?php esc_html_e( 'RSS Feed Address', 'wp-e-commerce' ); ?>
|
114 |
+
</th>
|
115 |
+
<td>
|
116 |
+
<?php $rss_url = add_query_arg( array( 'rss' => 'true', 'action' => 'product_list' ), home_url( '/' ) ); ?>
|
117 |
+
<a href="<?php echo esc_url( $rss_url ); ?>"><code><?php echo esc_url( $rss_url ); ?></code></a>
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
</table>
|
121 |
+
<?php
|
122 |
+
}
|
123 |
+
|
124 |
+
public function google_merch_center_settings_form() {
|
125 |
+
?>
|
126 |
+
<h3><?php esc_html_e( 'Google Merchant Centre / Google Product Search', 'wp-e-commerce'); ?></h3>
|
127 |
+
<p><?php printf( __( 'To import your products into <a href="%s" 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:', 'wp-e-commerce' ), 'http://www.google.com/merchants/' ); ?></p>
|
128 |
+
|
129 |
+
<table class='form-table'>
|
130 |
+
<tr>
|
131 |
+
<th>
|
132 |
+
<?php esc_html_e( 'Google Product Feed', 'wp-e-commerce' ); ?>
|
133 |
+
</th>
|
134 |
+
<td>
|
135 |
+
<?php $google_feed_url = add_query_arg( array( 'rss' => 'true', 'action' => 'product_list', 'xmlformat' => 'google' ), home_url( '/' ) ); ?>
|
136 |
+
<a href="<?php echo esc_url( $google_feed_url ); ?>"><code><?php echo esc_url( $google_feed_url ); ?></code></a>
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
</table>
|
140 |
+
<?php
|
141 |
+
}
|
142 |
+
|
143 |
+
public function google_analytics_integration_settings_form() {
|
144 |
+
?>
|
145 |
+
<h3><?php esc_html_e( 'Google Analytics E-Commerce Tracking', 'wp-e-commerce' ); ?></h3>
|
146 |
+
<p><?php printf( __( 'Track successful transactions and items purchased in <a href="%s">Google Analytics</a>.', 'wp-e-commerce' ), 'http://www.google.com/analytics/' ); ?></p>
|
147 |
+
<input type='hidden' name='change-settings' value='true' />
|
148 |
+
<table class='form-table'>
|
149 |
+
<tr>
|
150 |
+
<th>
|
151 |
+
<?php _e( 'Enable', 'wp-e-commerce' ); ?>
|
152 |
+
</th>
|
153 |
+
<td>
|
154 |
+
<label>
|
155 |
+
<input value='1' type='hidden' name='wpsc_ga_disable_tracking' />
|
156 |
+
<input value='0' <?php checked( '0', get_option( 'wpsc_ga_disable_tracking' ) ); ?> type='checkbox' name='wpsc_ga_disable_tracking' />
|
157 |
+
<?php _e( 'Enable Google Analytics tracking', 'wp-e-commerce' ); ?>
|
158 |
+
</label>
|
159 |
+
<p class='description'><?php _e( 'If, for whatever reason, you decide you do not want any tracking, disable it.', 'wp-e-commerce' ); ?></p>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
<tr>
|
163 |
+
<th>
|
164 |
+
<?php _ex( 'Google Analytics Tracking ID', 'google analytics', 'wp-e-commerce' ); ?>
|
165 |
+
</th>
|
166 |
+
<td>
|
167 |
+
<input value="<?php echo esc_attr( get_option( 'wpsc_ga_tracking_id' ) ); ?>" type='text' name='wpsc_ga_tracking_id' />
|
168 |
+
<span class='description'><?php _e( 'e.g. <code>UA-XXXXX-Y</code>', 'wp-e-commerce' ); ?></span>
|
169 |
+
</td>
|
170 |
+
</tr>
|
171 |
+
<tr>
|
172 |
+
<th>
|
173 |
+
<?php _e( 'Universal Analytics', 'wp-e-commerce' ); ?>
|
174 |
+
</th>
|
175 |
+
<td>
|
176 |
+
<label>
|
177 |
+
<input value="1" <?php checked( '1', get_option( 'wpsc_ga_use_universal' ) ); ?> type="checkbox" name="wpsc_ga_use_universal" />
|
178 |
+
<?php printf( __( 'Use <a%s>Universal Analytics</a> tracking code', 'wp-e-commerce' ), ' href="https://support.google.com/analytics/answer/2790010?hl=en-GB&ref_topic=6010376" target="universal_analytics"' ); ?>
|
179 |
+
</label>
|
180 |
+
</td>
|
181 |
+
</tr>
|
182 |
+
<tr>
|
183 |
+
<th>
|
184 |
+
<?php _e( 'Tracking Code Present', 'wp-e-commerce' ); ?>
|
185 |
+
</th>
|
186 |
+
<td>
|
187 |
+
<label>
|
188 |
+
<input value='1' <?php checked( '1', get_option( 'wpsc_ga_currently_tracking' ) ); ?> type='checkbox' name='wpsc_ga_currently_tracking' />
|
189 |
+
<?php _e( 'Google Analytics is tracking my site', 'wp-e-commerce' ); ?>
|
190 |
+
</label>
|
191 |
+
<p class='description'><?php printf( __( 'Enable this if the Google Analytics tracking code is already present on your site, e.g. manually placed in your theme, or managed by another plugin. We will only insert the <a href="%s">E-Commerce tracking events</a> on the transaction results page.', 'wp-e-commerce' ), 'https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEcommerce'); ?></p>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<tr>
|
195 |
+
<th>
|
196 |
+
<?php _e( 'Advanced Mode', 'wp-e-commerce' ); ?>
|
197 |
+
</th>
|
198 |
+
<td>
|
199 |
+
<label>
|
200 |
+
<input value='1' <?php checked( '1', get_option( 'wpsc_ga_advanced' ) ); ?> type='checkbox' name='wpsc_ga_advanced' />
|
201 |
+
<?php _e( 'Enable Advanced Mode', 'wp-e-commerce' ); ?>
|
202 |
+
</label>
|
203 |
+
<p class='description'><?php _e( 'By default, we insert the multiple-domain asynchronous tracking code. This should be fine for 99% of users. If you need to fine-tune it, select the Advanced option. Then, instead of simply entering your tracking ID, you will enter the tracking code from Google Analytics into the header.php file of your theme.', 'wp-e-commerce' ); ?></p>
|
204 |
+
</td>
|
205 |
+
</tr>
|
206 |
+
</table>
|
207 |
+
<?php
|
208 |
+
}
|
209 |
+
|
210 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/shipping.php
ADDED
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class WPSC_Settings_Tab_Shipping extends WPSC_Settings_Tab {
|
3 |
+
public function __construct() {
|
4 |
+
parent::__construct();
|
5 |
+
|
6 |
+
if ( isset( $_REQUEST['shipping_module_id'] ) )
|
7 |
+
update_user_option( get_current_user_id(), 'wpsc_settings_selected_shipping_module', sanitize_text_field( $_REQUEST['shipping_module_id'] ) );
|
8 |
+
|
9 |
+
add_action( 'admin_notices', array( $this, 'no_shipping_notice' ) );
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Hooks shipping notice into admin_notice if shipping is enabled but no shipping methods are selected
|
14 |
+
*
|
15 |
+
* @since 3.8.9
|
16 |
+
* @return null
|
17 |
+
*/
|
18 |
+
public function no_shipping_notice() {
|
19 |
+
if ( ! empty( $_GET['shipping_disabled'] ) ) {
|
20 |
+
?>
|
21 |
+
<div class="notice error is-dismissible below-h2">
|
22 |
+
<p><?php _e( '<strong>Shipping has been disabled.</strong> You enabled shipping but none of the shipping methods were selected. Please re-enable shipping, select and configure a shipping method, and then update your settings.', 'wp-e-commerce' ); ?></p>
|
23 |
+
</div>
|
24 |
+
<?php
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
public function callback_submit_options() {
|
29 |
+
global $wpsc_shipping_modules;
|
30 |
+
|
31 |
+
foreach ( $wpsc_shipping_modules as $shipping ) {
|
32 |
+
if ( is_object( $shipping ) )
|
33 |
+
$shipping->submit_form();
|
34 |
+
}
|
35 |
+
|
36 |
+
//This is for submitting shipping details to the shipping module
|
37 |
+
if ( ! isset( $_POST['update_gateways'] ) )
|
38 |
+
$_POST['update_gateways'] = '';
|
39 |
+
|
40 |
+
if ( ! isset( $_POST['custom_shipping_options'] ) )
|
41 |
+
$_POST['custom_shipping_options'] = array();
|
42 |
+
|
43 |
+
update_option( 'custom_shipping_options', array_map( 'sanitize_text_field', $_POST['custom_shipping_options'] ) );
|
44 |
+
|
45 |
+
$shipadd = 0;
|
46 |
+
foreach ( $wpsc_shipping_modules as $shipping ) {
|
47 |
+
foreach ( (array) $_POST['custom_shipping_options'] as $shippingoption ) {
|
48 |
+
if ( $shipping->getInternalName() == $shippingoption ) {
|
49 |
+
$shipadd++;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if ( isset( $_POST['wpsc_options']['shipping_discount_value'] ) ) {
|
55 |
+
update_option( 'shipping_discount_value', wpsc_string_to_float( $_POST['wpsc_options']['shipping_discount_value'] ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( ! get_option( 'do_not_use_shipping' ) && ! get_option( 'custom_shipping_options' ) && ! ( bool ) get_option( 'shipwire' ) ) {
|
59 |
+
update_option( 'do_not_use_shipping', '1' );
|
60 |
+
return array( 'shipping_disabled' => 1 );
|
61 |
+
} else {
|
62 |
+
$_SERVER['REQUEST_URI'] = esc_url_raw( remove_query_arg( 'shipping_disabled' ) );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
public function display_shipping_module_settings_form( $selected_module_id = null ) {
|
67 |
+
global $wpsc_shipping_modules;
|
68 |
+
if ( ! $selected_module_id ) {
|
69 |
+
$selected_module_id = (string) get_user_option( 'wpsc_settings_selected_shipping_module', get_current_user_id() );
|
70 |
+
}
|
71 |
+
|
72 |
+
$found_selected_module = array_key_exists( $selected_module_id, $wpsc_shipping_modules );
|
73 |
+
|
74 |
+
if ( $found_selected_module ) {
|
75 |
+
$selected_module = $wpsc_shipping_modules[$selected_module_id];
|
76 |
+
$title = $selected_module->getName();
|
77 |
+
$content = apply_filters( 'wpsc_shipping_module_settings_form', $selected_module->getForm(), $selected_module );
|
78 |
+
} else {
|
79 |
+
$title = __( 'Edit Shipping Module Settings', 'wp-e-commerce' );
|
80 |
+
$content = __( 'To configure a shipping module select one on the left.', 'wp-e-commerce' );
|
81 |
+
}
|
82 |
+
|
83 |
+
?>
|
84 |
+
<div id='wpsc_shipping_settings_<?php echo esc_attr( $selected_module_id ); ?>_form' class='shipping-module-settings-form'>
|
85 |
+
<table class='form-table'>
|
86 |
+
<?php echo $content; ?>
|
87 |
+
</table>
|
88 |
+
<table class='form-table'>
|
89 |
+
<tr><td colspan='2'>
|
90 |
+
<p class="submit inline-edit-save">
|
91 |
+
<a class="button edit-shipping-module-cancel" title="<?php esc_attr_e( "Cancel editing this shipping calculator's settings", 'wp-e-commerce' ) ?>"><?php esc_html_e( "Cancel", 'wp-e-commerce' ); ?></a>
|
92 |
+
<input type="submit" name="submit" class="button button-primary edit-shipping-module-update" value='<?php _e( "Update »", 'wp-e-commerce' ); ?>'>
|
93 |
+
</p>
|
94 |
+
</td></tr>
|
95 |
+
</table>
|
96 |
+
</div>
|
97 |
+
<?php
|
98 |
+
}
|
99 |
+
|
100 |
+
private function get_shipping_module_url( $shipping ) {
|
101 |
+
$location = ( isset( $_REQUEST['current_url'] ) ? $_REQUEST['current_url'] : $_SERVER['REQUEST_URI'] );
|
102 |
+
$location = add_query_arg( array(
|
103 |
+
'tab' => 'shipping',
|
104 |
+
'page' => 'wpsc-settings',
|
105 |
+
'shipping_module_id' => $shipping->getInternalName(),
|
106 |
+
), $location );
|
107 |
+
$location .= '#wpsc-shipping-module-options';
|
108 |
+
return esc_url( $location );
|
109 |
+
}
|
110 |
+
|
111 |
+
public function display() {
|
112 |
+
global $wpdb, $wpsc_shipping_modules, $external_shipping_modules, $internal_shipping_modules;
|
113 |
+
|
114 |
+
// sort into external and internal arrays.
|
115 |
+
foreach ( $GLOBALS['wpsc_shipping_modules'] as $key => $module ) {
|
116 |
+
if ( empty( $module ) )
|
117 |
+
continue;
|
118 |
+
|
119 |
+
if ( isset( $module->is_external ) && $module->is_external ) {
|
120 |
+
$external_shipping_modules[$key] = $module;
|
121 |
+
} else {
|
122 |
+
$internal_shipping_modules[$key] = $module;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
?>
|
127 |
+
|
128 |
+
<h3><?php esc_html_e( 'Shipping Settings', 'wp-e-commerce'); ?></h3>
|
129 |
+
<input type='hidden' name='shipping_submits' value='true' />
|
130 |
+
<?php wp_nonce_field( 'update-options', 'wpsc-update-options' ); ?>
|
131 |
+
<input type='hidden' name='wpsc_admin_action' value='submit_options' />
|
132 |
+
<table class='form-table'>
|
133 |
+
<?php
|
134 |
+
/* wpsc_setting_page_update_notification displays the wordpress styled notifications */
|
135 |
+
wpsc_settings_page_update_notification();
|
136 |
+
?>
|
137 |
+
<tr>
|
138 |
+
<th scope="row"><?php _e( 'Use Shipping', 'wp-e-commerce' ); ?></th>
|
139 |
+
<td>
|
140 |
+
<input type='hidden' value='1' name='wpsc_options[do_not_use_shipping]' />
|
141 |
+
<input type='checkbox' value='0' name='wpsc_options[do_not_use_shipping]' id='do_not_use_shipping' <?php checked( '0', get_option( 'do_not_use_shipping' ) ); ?> /> <label for='do_not_use_shipping'><?php _e( 'Enable Shipping settings', 'wp-e-commerce' ); ?></label>
|
142 |
+
<p class='description'><?php esc_html_e( 'If you are only selling digital downloads, you should turn this off.', 'wp-e-commerce' ); ?></p>
|
143 |
+
</td>
|
144 |
+
</tr>
|
145 |
+
|
146 |
+
<tr>
|
147 |
+
<th><?php esc_html_e( 'Shipping Origin City', 'wp-e-commerce' ); ?></th>
|
148 |
+
<td>
|
149 |
+
<input type='text' name='wpsc_options[base_city]' value='<?php echo esc_attr( get_option( 'base_city' ) ); ?>' />
|
150 |
+
<p class='description'><?php esc_html_e( 'The name of the city where you fulfill and ship orders from. This enables us to give your customers more accurate shipping pricing.', 'wp-e-commerce' ); ?></p>
|
151 |
+
</td>
|
152 |
+
</tr>
|
153 |
+
<tr>
|
154 |
+
<th><?php esc_html_e( 'Shipping Origin Zipcode/Postcode', 'wp-e-commerce' ); ?></th>
|
155 |
+
<td>
|
156 |
+
<input type='text' name='wpsc_options[base_zipcode]' value='<?php echo esc_attr( get_option( 'base_zipcode' ) ); ?>' />
|
157 |
+
<p class='description'>
|
158 |
+
<?php esc_html_e( 'The ZIP code / Postal code from where you fulfill and ship orders.', 'wp-e-commerce' ); ?><br />
|
159 |
+
<?php esc_html_e( 'If you are based in the United States, then this field is required in order for the UPS and USPS Shipping Calculators to work.', 'wp-e-commerce' ); ?>
|
160 |
+
</p>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<tr>
|
164 |
+
<th scope="row"><?php _e( 'Shipwire', 'wp-e-commerce' ); ?><span style='color: red;'></span></th>
|
165 |
+
<td>
|
166 |
+
<input type='hidden' value='0' name='wpsc_options[shipwire]' />
|
167 |
+
<input type='checkbox' onclick='jQuery("#wpsc_shipwire_setting").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipwire]' id='shipwire' <?php checked( '1', get_option( 'shipwire' ) ); ?> />
|
168 |
+
<label for='shipwire'><?php _e( 'Enable Shipwire Integration', 'wp-e-commerce' ); ?></label>
|
169 |
+
<p class='description'><?php printf( __( '<a href="%1$s" target="_blank">Shipwire</a> provide e-commerce fulfillment warehouses. WP eCommerce can integrate stock inventory and shipping tracking with their service.', 'wp-e-commerce' ), 'http://www.shipwire.com/pp/o.php?id=11922' ); ?></p>
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
<?php
|
173 |
+
switch ( get_option( 'shipwire' ) ) {
|
174 |
+
case 1:
|
175 |
+
$shipwire_settings = '';
|
176 |
+
break;
|
177 |
+
|
178 |
+
case 0:
|
179 |
+
default:
|
180 |
+
$shipwire_settings = 'style="display: none;"';
|
181 |
+
break;
|
182 |
+
}
|
183 |
+
?>
|
184 |
+
<tr id='wpsc_shipwire_setting' <?php echo $shipwire_settings; ?>>
|
185 |
+
<th> </th>
|
186 |
+
<td>
|
187 |
+
<table>
|
188 |
+
<tr>
|
189 |
+
<th><?php esc_html_e( 'Shipwire Email', 'wp-e-commerce' ); ?></th>
|
190 |
+
<td><input type="text" name='wpsc_options[shipwireemail]' value="<?php echo esc_attr( get_option( 'shipwireemail' ) ); ?>" /></td>
|
191 |
+
</tr>
|
192 |
+
<tr>
|
193 |
+
<th><?php esc_html_e( 'Shipwire Password', 'wp-e-commerce' ); ?></th>
|
194 |
+
<td><input type="text" name='wpsc_options[shipwirepassword]' value="<?php echo esc_attr( get_option( 'shipwirepassword' ) ); ?>" /></td>
|
195 |
+
</tr>
|
196 |
+
<tr>
|
197 |
+
<th><?php esc_html_e( 'Use Test Server?', 'wp-e-commerce' ); ?></th>
|
198 |
+
<td><input type="checkbox" name='wpsc_options[shipwire_test_server]' value="0" <?php checked( '1', get_option( 'shipwire_test_server', '0' ) ); ?> /></td>
|
199 |
+
</tr>
|
200 |
+
<tr>
|
201 |
+
<th><?php esc_html_e( 'Force Sync with Shipwire', 'wp-e-commerce' ); ?></th>
|
202 |
+
<td>
|
203 |
+
<a class="shipwire_sync button"><?php esc_html_e( 'Update Tracking and Inventory', 'wp-e-commerce' ); ?></a>
|
204 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
205 |
+
</td>
|
206 |
+
</tr>
|
207 |
+
</table>
|
208 |
+
</td>
|
209 |
+
</tr>
|
210 |
+
<?php
|
211 |
+
$currency_data = WPSC_Countries::get_currency_data( get_option( 'currency_type' ), true );
|
212 |
+
if ( $currency_data['symbol'] != '' ) {
|
213 |
+
$currency_sign = $currency_data['symbol_html'];
|
214 |
+
} else {
|
215 |
+
$currency_sign = $currency_data['code'];
|
216 |
+
}
|
217 |
+
?>
|
218 |
+
<tr>
|
219 |
+
<th><?php _e( 'Free Shipping Discount', 'wp-e-commerce' ); ?></th>
|
220 |
+
<td>
|
221 |
+
<?php
|
222 |
+
if ( get_option( 'shipping_discount' ) == 1 ) {
|
223 |
+
$shipping_discount_settings = 'style=\'display: block;\'';
|
224 |
+
} else {
|
225 |
+
$shipping_discount_settings = '';
|
226 |
+
}
|
227 |
+
?>
|
228 |
+
<input type='hidden' value='0' name='wpsc_options[shipping_discount]' />
|
229 |
+
<input type='checkbox' onclick='jQuery("#shipping_discount_value").toggle( jQuery(this).prop("checked") );' value='1' name='wpsc_options[shipping_discount]' id='shipping_discount' <?php checked( '1', get_option( 'shipping_discount' ) ); ?> />
|
230 |
+
<label for='shipping_discount'><?php _e( 'Enable Free Shipping Discount', 'wp-e-commerce' ); ?></label>
|
231 |
+
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
+
<tr>
|
235 |
+
<td> </td>
|
236 |
+
<td colspan="2">
|
237 |
+
<?php
|
238 |
+
$value = wpsc_format_number( get_option( 'shipping_discount_value' ) );
|
239 |
+
?>
|
240 |
+
<div <?php echo $shipping_discount_settings; ?> id='shipping_discount_value'>
|
241 |
+
|
242 |
+
<?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.', 'wp-e-commerce' ), $currency_sign, esc_attr( $value ) ); ?>
|
243 |
+
</div>
|
244 |
+
</td>
|
245 |
+
</tr>
|
246 |
+
</table>
|
247 |
+
|
248 |
+
<?php submit_button( __( 'Save Changes', 'wp-e-commerce' ) ); ?>
|
249 |
+
|
250 |
+
<h3><?php _e( 'Shipping Modules', 'wp-e-commerce' ) ?></h3>
|
251 |
+
<p class='description'><?php _e( 'To enable shipping in WP eCommerce you must select which shipping methods you want to enable on your site.', 'wp-e-commerce' ); ?></p>
|
252 |
+
<p class='description'>
|
253 |
+
<strong><?php _e( 'Tip', 'wp-e-commerce' ); ?></strong>:
|
254 |
+
<?php printf( __( 'For fixed-price shipping options such as "Pickup - $0, Overnight - $10, Same day - $20, etc.", install our free <a href="%1$s">Fixed Rate Shipping</a> plugin.', 'wp-e-commerce' ), 'http://wordpress.org/extend/plugins/wp-e-commerce-fixed-rate-shipping/' ); ?>
|
255 |
+
</p>
|
256 |
+
|
257 |
+
<h4><?php _e( 'Internal Shipping Calculators', 'wp-e-commerce' ); ?></h4>
|
258 |
+
<table id='wpsc-shipping-options-internal' class='wpsc-edit-module-options wp-list-table widefat plugins'>
|
259 |
+
<thead>
|
260 |
+
<tr>
|
261 |
+
<th scope="col" id="wpsc-shipping-options-internal-active" class="manage-column"><?php _e( 'Active', 'wp-e-commerce' ); ?></th>
|
262 |
+
<th scope="col" id="wpsc-shipping-options-internal-name" class="manage-column column-name"><?php _e( 'Shipping Calculator', 'wp-e-commerce' ); ?></th>
|
263 |
+
</tr>
|
264 |
+
</thead>
|
265 |
+
<tfoot>
|
266 |
+
<tr>
|
267 |
+
<th scope="col" id="wpsc-shipping-options-internal-active" class="manage-column"><?php _e( 'Active', 'wp-e-commerce' ); ?></th>
|
268 |
+
<th scope="col" id="wpsc-shipping-options-internal-name" class="manage-column column-name"><?php _e( 'Shipping Calculator', 'wp-e-commerce' ); ?></th>
|
269 |
+
</tr>
|
270 |
+
</tfoot>
|
271 |
+
<tbody>
|
272 |
+
<?php
|
273 |
+
foreach ( $internal_shipping_modules as $shipping ) {
|
274 |
+
$force = ( $shipping->getInternalName() === (string) get_user_option( 'wpsc_settings_selected_shipping_module', get_current_user_id() ) );
|
275 |
+
$this->shipping_list_item( $shipping, $force );
|
276 |
+
}
|
277 |
+
?>
|
278 |
+
</tbody>
|
279 |
+
</table>
|
280 |
+
<?php submit_button( __( 'Save Changes', 'wp-e-commerce' ) ); ?>
|
281 |
+
|
282 |
+
<h4><?php _e( 'External Shipping Calculators', 'wp-e-commerce' ); ?></h4>
|
283 |
+
<?php if ( ! function_exists( 'curl_init' ) ) : ?>
|
284 |
+
<p style='color: red; font-size:8pt; line-height:10pt;'>
|
285 |
+
<?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. ', 'wp-e-commerce' ); ?>
|
286 |
+
</p>
|
287 |
+
<?php endif; ?>
|
288 |
+
<table id='wpsc-shipping-options-external' class='wpsc-edit-module-options wp-list-table widefat plugins'>
|
289 |
+
<thead>
|
290 |
+
<tr>
|
291 |
+
<th scope="col" id="wpsc-shipping-options-external-active" class="manage-column"><?php _e( 'Active', 'wp-e-commerce' ); ?></th>
|
292 |
+
<th scope="col" id="wpsc-shipping-options-external-name" class="manage-column column-name"><?php _e( 'Shipping Calculator', 'wp-e-commerce' ); ?></th>
|
293 |
+
</tr>
|
294 |
+
</thead>
|
295 |
+
<tfoot>
|
296 |
+
<tr>
|
297 |
+
<th scope="col" id="wpsc-shipping-options-external-active" class="manage-column"><?php _e( 'Active', 'wp-e-commerce' ); ?></th>
|
298 |
+
<th scope="col" id="wpsc-shipping-options-external-name" class="manage-column column-name"><?php _e( 'Shipping Calculator', 'wp-e-commerce' ); ?></th>
|
299 |
+
</tr>
|
300 |
+
</tfoot>
|
301 |
+
<tbody>
|
302 |
+
<?php
|
303 |
+
foreach ( $external_shipping_modules as $shipping ) {
|
304 |
+
$force = ( $shipping->getInternalName() === (string) get_user_option( 'wpsc_settings_selected_shipping_module', get_current_user_id() ) );
|
305 |
+
$this->shipping_list_item( $shipping, $force );
|
306 |
+
}
|
307 |
+
?>
|
308 |
+
</tbody>
|
309 |
+
</table>
|
310 |
+
<?php
|
311 |
+
}
|
312 |
+
|
313 |
+
private function shipping_list_item ( $shipping, $force ) {
|
314 |
+
//get shipping options that are selected
|
315 |
+
$selected_shippings = get_option( 'custom_shipping_options' );
|
316 |
+
|
317 |
+
$shipping->checked = is_object( $shipping ) && in_array( $shipping->getInternalName(), (array) $selected_shippings );
|
318 |
+
$shipping->active = $shipping->checked ? 'active' : 'inactive';
|
319 |
+
$shipping->hidden = $force ? '' : "style='display: none;'";
|
320 |
+
$shipping->disabled = isset( $shipping->requires_curl ) && $shipping->requires_curl && ! function_exists( 'curl_init' ) ;
|
321 |
+
|
322 |
+
?>
|
323 |
+
<tr class="wpsc-select-shipping <?php echo $shipping->active; ?>" data-shipping-id="<?php echo esc_attr( $shipping->getInternalName() ); ?>" id="shipping_list_item_<?php echo $shipping->getInternalName();?>">
|
324 |
+
<th scope="row" class="check-column">
|
325 |
+
<input name='custom_shipping_options[]' <?php disabled( $shipping->disabled ); ?> <?php checked( $shipping->checked ); ?> type='checkbox' value='<?php echo $shipping->getInternalName(); ?>' id='<?php echo $shipping->getInternalName(); ?>_id' />
|
326 |
+
</th>
|
327 |
+
<td class="plugin-title">
|
328 |
+
<label for='<?php echo $shipping->getInternalName(); ?>_id'><strong><?php echo $shipping->getName(); ?></strong></label>
|
329 |
+
<div class="row-actions-visible">
|
330 |
+
<span class="edit">
|
331 |
+
<a class='edit-shipping-module' data-module-id="<?php echo $shipping->getInternalName(); ?>" title="<?php esc_attr_e( 'Edit this Shipping Module', 'wp-e-commerce' ); ?>" href='<?php echo esc_url( $this->get_shipping_module_url( $shipping ) ); ?>'><?php _ex( 'Settings', 'Shipping modules link to individual settings', 'wp-e-commerce' ); ?>
|
332 |
+
<img src="<?php echo esc_url( wpsc_get_ajax_spinner() ); ?>" class="ajax-feedback" title="" alt="" />
|
333 |
+
</span>
|
334 |
+
</div>
|
335 |
+
</td>
|
336 |
+
</tr>
|
337 |
+
<tr id="wpsc_shipping_settings_<?php echo esc_attr( $shipping->getInternalName() ); ?>" data-shipping-id="<?php echo esc_attr( $shipping->getInternalName() ); ?>" class='wpsc-select-shipping <?php echo $shipping->active; ?>' <?php echo $shipping->hidden; ?> >
|
338 |
+
<td colspan="3" id="wpsc_shipping_settings_<?php echo esc_attr( $shipping->getInternalName() ); ?>_container">
|
339 |
+
<?php $this->display_shipping_module_settings_form( $shipping->getInternalName() ); ?>
|
340 |
+
</td>
|
341 |
+
</tr>
|
342 |
+
<?php
|
343 |
+
}
|
344 |
+
}
|
trunk/wpsc-admin/includes/settings-tabs/taxes.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WPSC_Settings_Tab_Taxes extends WPSC_Settings_Tab {
|
4 |
+
public function __construct() {
|
5 |
+
}
|
6 |
+
|
7 |
+
public function callback_submit_options() {
|
8 |
+
$taxes_enabled = ( isset( $_POST['wpsc_options']['wpec_taxes_enabled'] ) ) ? 1 : 0;
|
9 |
+
update_option( 'wpec_taxes_enabled', $taxes_enabled );
|
10 |
+
|
11 |
+
//currently there are two types - bands and rates
|
12 |
+
$taxes_rates_types = array( 'rates', 'bands' );
|
13 |
+
|
14 |
+
foreach ( $taxes_rates_types as $taxes_type ) {
|
15 |
+
$saved_rates = array( ); //keep track of saved rates
|
16 |
+
$exists = array( ); //keep track of what rates or names have been saved
|
17 |
+
//check the rates
|
18 |
+
if ( isset( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] ) ) {
|
19 |
+
foreach ( $_POST['wpsc_options']['wpec_taxes_' . $taxes_type] as $tax_rate ) {
|
20 |
+
if( !isset( $tax_rate['region_code'] ) )
|
21 |
+
$tax_rate['region_code'] = '';
|
22 |
+
|
23 |
+
//if there is no country then skip
|
24 |
+
if ( empty( $tax_rate['country_code'] ) ) {
|
25 |
+
continue;
|
26 |
+
}
|
27 |
+
|
28 |
+
//bands - if the name already exists then skip - if not save it
|
29 |
+
if ( $taxes_type == 'bands' ) {
|
30 |
+
if ( empty( $tax_rate['name'] ) || in_array( $tax_rate['name'], $exists ) || $tax_rate['name'] == 'Disabled' ) {
|
31 |
+
continue;
|
32 |
+
} else {
|
33 |
+
$exists[] = $tax_rate['name'];
|
34 |
+
$saved_rates[] = $tax_rate;
|
35 |
+
}// if
|
36 |
+
}// if
|
37 |
+
//rates - check the shipping checkbox
|
38 |
+
if ( $taxes_type == 'rates' ) {
|
39 |
+
//if there is no rate then skip
|
40 |
+
if ( empty( $tax_rate['rate'] ) ) {
|
41 |
+
continue;
|
42 |
+
}
|
43 |
+
|
44 |
+
$tax_rate['shipping'] = (isset( $tax_rate['shipping'] )) ? 1 : 0;
|
45 |
+
|
46 |
+
//check if country exists
|
47 |
+
if ( array_key_exists( $tax_rate['country_code'], $exists ) ) {
|
48 |
+
//if region already exists skip
|
49 |
+
if ( array_search( $tax_rate['region_code'], $exists[$tax_rate['country_code']] ) == $tax_rate['country_code'] ) {
|
50 |
+
continue;
|
51 |
+
} else {
|
52 |
+
//it's not in the array add it
|
53 |
+
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
54 |
+
|
55 |
+
//save it
|
56 |
+
$saved_rates[] = $tax_rate;
|
57 |
+
}// if
|
58 |
+
} else {
|
59 |
+
//add codes to exists array
|
60 |
+
$exists[$tax_rate['country_code']][] = $tax_rate['region_code'];
|
61 |
+
|
62 |
+
//save it
|
63 |
+
$saved_rates[] = $tax_rate;
|
64 |
+
}// if
|
65 |
+
}// if
|
66 |
+
}// foreach
|
67 |
+
}// if
|
68 |
+
//replace post tax rates with filtered rates
|
69 |
+
update_option( 'wpec_taxes_' . $taxes_type, $saved_rates );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
public function display() {
|
74 |
+
$wpec_taxes_controller = new wpec_taxes_controller;
|
75 |
+
$wpec_taxes_options = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_options();
|
76 |
+
|
77 |
+
?>
|
78 |
+
<h3><?php esc_html_e( 'Tax Settings', 'wp-e-commerce' ); ?></h3>
|
79 |
+
<table class='form-table'>
|
80 |
+
<tr>
|
81 |
+
<th><?php esc_html_e( "Enable Tax", 'wp-e-commerce' ); ?></th>
|
82 |
+
<td>
|
83 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_enabled'] ) echo 'checked="checked"'; ?> type="checkbox" id='wpec_taxes_enabled' name='wpsc_options[wpec_taxes_enabled]' />
|
84 |
+
<label for='wpec_taxes_enabled'>
|
85 |
+
<?php esc_html_e( 'Turn tax on', 'wp-e-commerce' ); ?>
|
86 |
+
</label>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<th><?php esc_html_e( "Product Prices", 'wp-e-commerce' ); ?></th>
|
91 |
+
<td>
|
92 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'exclusive' ) echo 'checked="checked"'; ?> type="radio" value='exclusive' id='wpec_taxes_inprice1' name='wpsc_options[wpec_taxes_inprice]' />
|
93 |
+
<label for='wpec_taxes_inprice1'>
|
94 |
+
<?php esc_html_e( 'Product prices are tax exclusive - add tax to the price during checkout', 'wp-e-commerce' ); ?>
|
95 |
+
</label><br />
|
96 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_inprice'] == 'inclusive' ) echo 'checked="checked"'; ?> type="radio" value='inclusive' id='wpec_taxes_inprice2' name='wpsc_options[wpec_taxes_inprice]' />
|
97 |
+
<label for='wpec_taxes_inprice2'>
|
98 |
+
<?php esc_html_e( "Product prices are tax inclusive - during checkout the total price doesn't increase but tax is shown as a line item", 'wp-e-commerce' ); ?>
|
99 |
+
</label>
|
100 |
+
</td>
|
101 |
+
</tr>
|
102 |
+
<tr>
|
103 |
+
<th><?php esc_html_e( 'Product Specific Tax', 'wp-e-commerce' ); ?></th>
|
104 |
+
<td>
|
105 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'add' ) echo 'checked="checked"'; ?> type="radio" value='add' id='wpec_taxes_product_1' name='wpsc_options[wpec_taxes_product]' />
|
106 |
+
<label for='wpec_taxes_product_1'>
|
107 |
+
<?php esc_html_e( 'Add per product tax to tax percentage if product has a specific tax rate', 'wp-e-commerce' ); ?>
|
108 |
+
</label><br />
|
109 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_product'] == 'replace' ) echo 'checked="checked"'; ?> type="radio" value='replace' id='wpec_taxes_product_2' name='wpsc_options[wpec_taxes_product]' />
|
110 |
+
<label for='wpec_taxes_product_2'>
|
111 |
+
<?php esc_html_e( 'Replace tax percentage with product specific tax rate', 'wp-e-commerce' ); ?>
|
112 |
+
</label>
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<tr>
|
116 |
+
<th><?php _e( 'Tax Logic', 'wp-e-commerce' ); ?></th>
|
117 |
+
<td>
|
118 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' ) echo 'checked="checked"'; ?> type="radio" value='billing_shipping' id='wpec_taxes_logic_1' name='wpsc_options[wpec_taxes_logic]' />
|
119 |
+
<label for='wpec_taxes_logic_1'>
|
120 |
+
<?php esc_html_e( 'Apply tax when Billing and Shipping Region is the same as Tax Rate', 'wp-e-commerce' ); ?>
|
121 |
+
</label>
|
122 |
+
<div id='billing_shipping_preference_container' style='margin-left: 20px;'>
|
123 |
+
<?php
|
124 |
+
$checked = ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'billing_address' ? 'checked="checked"' : '' );
|
125 |
+
?>
|
126 |
+
<input <?php echo $checked;?> type="radio" value='billing_address' id='wpec_billing_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
127 |
+
<label for='wpec_billing_preference'>
|
128 |
+
<?php esc_html_e( 'Apply tax to Billing Address', 'wp-e-commerce' ); ?>
|
129 |
+
</label><br />
|
130 |
+
<?php
|
131 |
+
$checked = ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing_shipping' && $wpec_taxes_options['wpec_billing_shipping_preference'] == 'shipping_address' ? 'checked="checked"' : '' );
|
132 |
+
?>
|
133 |
+
<input <?php echo $checked; ?>type="radio" value='shipping_address' id='wpec_shipping_preference' name='wpsc_options[wpec_billing_shipping_preference]' />
|
134 |
+
<label for='wpec_shipping_preference'>
|
135 |
+
<?php esc_html_e( 'Apply tax to Shipping Address', 'wp-e-commerce' ); ?>
|
136 |
+
</label>
|
137 |
+
</div>
|
138 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'billing' ) echo 'checked="checked"'; ?> type="radio" value='billing' id='wpec_taxes_logic_2' name='wpsc_options[wpec_taxes_logic]' />
|
139 |
+
<label for='wpec_taxes_logic_2'>
|
140 |
+
<?php esc_html_e( 'Apply tax when Billing Region is the same as Tax Rate', 'wp-e-commerce' ); ?>
|
141 |
+
</label><br />
|
142 |
+
<input <?php if ( $wpec_taxes_options['wpec_taxes_logic'] == 'shipping' ) echo 'checked="checked"'; ?> type="radio" value='shipping' id='wpec_taxes_logic_3' name='wpsc_options[wpec_taxes_logic]' />
|
143 |
+
<label for='wpec_taxes_logic_3'>
|
144 |
+
<?php esc_html_e( 'Apply tax when Shipping Region is the same as Tax Rate', 'wp-e-commerce' ); ?>
|
145 |
+
</label>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
</table>
|
149 |
+
|
150 |
+
<h3><?php esc_html_e( 'Tax Rates', 'wp-e-commerce' ); ?></h3>
|
151 |
+
<div id='wpec-taxes-rates'>
|
152 |
+
<!--Start Taxes Output-->
|
153 |
+
<table class='widefat page fixed ui-sortable'>
|
154 |
+
<thead>
|
155 |
+
<th scope='col' width='60%'><?php _e( 'Market', 'wp-e-commerce' ); ?></th>
|
156 |
+
<th scope='col' width='10%'><?php _e( 'Tax Rate', 'wp-e-commerce' ); ?></th>
|
157 |
+
<th scope='col'><?php _e( 'Tax Shipping?', 'wp-e-commerce' ); ?></th>
|
158 |
+
<th scope='col' style='width: 60px'><?php _e( 'Actions', 'wp-e-commerce' ); ?></th>
|
159 |
+
</thead>
|
160 |
+
<tbody>
|
161 |
+
<?php
|
162 |
+
$tax_rates = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_rates();
|
163 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'rates', 'prototype', array( 'row_class' => 'prototype' ) );
|
164 |
+
if ( count( $tax_rates ) === 0 ) {
|
165 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'rates', 0, null );
|
166 |
+
}
|
167 |
+
$tax_rate_count = 0;
|
168 |
+
if ( ! empty( $tax_rates ) ) {
|
169 |
+
foreach ( $tax_rates as $tax_rate ) {
|
170 |
+
// OLD: echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_rate_count, $tax_rate );
|
171 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'rates', $tax_rate_count, $tax_rate );
|
172 |
+
$tax_rate_count++;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
?>
|
176 |
+
</tbody>
|
177 |
+
</table>
|
178 |
+
<!--End Taxes Output-->
|
179 |
+
</div>
|
180 |
+
<div id='wpec-taxes-bands-container'>
|
181 |
+
<h3><?php esc_html_e( 'Tax Bands', 'wp-e-commerce' ); ?></h3>
|
182 |
+
<div id='wpec-taxes-bands'>
|
183 |
+
<div class="updated inline">
|
184 |
+
<p><?php _e( 'Note: Tax Bands are special tax rules you can create and apply on a per-product basis. Please visit the product page to apply your Tax Band.', 'wp-e-commerce' ); ?></p>
|
185 |
+
</div>
|
186 |
+
<?php if ( !$wpec_taxes_controller->wpec_taxes_isincluded() ) : ?>
|
187 |
+
<div class="error inline">
|
188 |
+
<p><?php _e( 'Warning: Tax Bands do not take effect when product prices are tax exclusive.', 'wp-e-commerce' ); ?></p>
|
189 |
+
</div>
|
190 |
+
<?php endif; ?>
|
191 |
+
<table class='widefat page fixed ui-sortable'>
|
192 |
+
<thead>
|
193 |
+
<th scope='col'><?php _e( 'Band Name', 'wp-e-commerce' ); ?></th>
|
194 |
+
<th scope='col' width="50%"><?php _e( 'Market', 'wp-e-commerce' ); ?></th>
|
195 |
+
<th scope='col' width='20%'><?php _e( 'Tax Rate', 'wp-e-commerce' ); ?></th>
|
196 |
+
<th scope='col' style='width: 60px'><?php _e( 'Actions', 'wp-e-commerce' ); ?></th>
|
197 |
+
</thead>
|
198 |
+
<tbody>
|
199 |
+
<?php
|
200 |
+
$tax_bands = $wpec_taxes_controller->wpec_taxes->wpec_taxes_get_bands();
|
201 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'bands', 'prototype', array( 'row_class' => 'prototype' ) );
|
202 |
+
if ( count( $tax_bands ) === 0 ) {
|
203 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'bands', 0, null );
|
204 |
+
}
|
205 |
+
$tax_band_count = 0;
|
206 |
+
if ( ! empty( $tax_bands ) ) {
|
207 |
+
foreach ( $tax_bands as $tax_band ) {
|
208 |
+
// OLD: echo $wpec_taxes_controller->wpec_taxes_build_form( $tax_band_count, $tax_band, 'bands' );
|
209 |
+
echo $wpec_taxes_controller->wpsc_build_taxes_row( 'bands', $tax_band_count, $tax_band );
|
210 |
+
$tax_band_count++;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
?>
|
214 |
+
|
215 |
+
</tbody>
|
216 |
+
</table>
|
217 |
+
</div>
|
218 |
+
</div><!--wpec-taxes-bands-container-->
|
219 |
+
<?php
|
220 |
+
}
|
221 |
+
}
|
trunk/wpsc-admin/includes/tax_and_shipping.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The HTML outputting the tax and shipping form
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
6 |
+
* @since 3.8
|
7 |
+
*/
|
8 |
+
|
9 |
+
global $wpdb;
|
10 |
+
$changes_made = false;
|
11 |
+
$country_isocode = preg_match( "/[a-zA-Z]{2,4}/", $_GET['isocode'] ) ? $_GET['isocode'] : get_option( 'base_country' );
|
12 |
+
$base_region = get_option('base_region');
|
13 |
+
?>
|
14 |
+
<div class="wrap">
|
15 |
+
<h2><?php esc_html_e( 'GST/Tax Rate', 'wp-e-commerce' );?></h2>
|
16 |
+
<?php
|
17 |
+
if($changes_made === true)
|
18 |
+
{
|
19 |
+
echo esc_html__( 'Thanks, your changes have been made', 'wp-e-commerce' ) . "<br />";
|
20 |
+
}
|
21 |
+
?>
|
22 |
+
<form action='' method='post' name='regional_tax' class='wpsc_form_track'>
|
23 |
+
<?php
|
24 |
+
$country_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `isocode` IN(%s) LIMIT 1", $country_isocode ), ARRAY_A );
|
25 |
+
if(($country_data['has_regions'] == 1))
|
26 |
+
{
|
27 |
+
$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) ;
|
28 |
+
$region_data = array_chunk($region_data, 14);
|
29 |
+
|
30 |
+
echo "<table>\n\r";
|
31 |
+
echo " <tr>\n\r";
|
32 |
+
foreach($region_data as $region_col)
|
33 |
+
{
|
34 |
+
echo " <td style='vertical-align: top; padding-right: 3em;'>\n\r";
|
35 |
+
echo "<table>\n\r";
|
36 |
+
foreach($region_col as $region)
|
37 |
+
{
|
38 |
+
$tax_percentage = $region['tax'];
|
39 |
+
echo " <tr>\n\r";
|
40 |
+
if($region['id'] == $base_region)
|
41 |
+
{
|
42 |
+
echo " <td><label for='region_tax_".$region['id']."' style='text-decoration: underline;'>".$region['name'].":</label></td>\n\r";
|
43 |
+
}
|
44 |
+
else
|
45 |
+
{
|
46 |
+
echo " <td><label for='region_tax_".$region['id']."'>".$region['name'].":</label></td>\n\r";
|
47 |
+
}
|
48 |
+
echo " <td><input type='text' id='region_tax_".$region['id']."' name='region_tax[".$region['id']."]' value='".$tax_percentage."' class='tax_forms' size='2'/>%</td>\n\r";
|
49 |
+
echo " </tr>\n\r";
|
50 |
+
}
|
51 |
+
echo "</table>\n\r";
|
52 |
+
echo " </td>\n\r";
|
53 |
+
}
|
54 |
+
echo " </tr>\n\r";
|
55 |
+
echo "</table>\n\r";
|
56 |
+
}
|
57 |
+
else
|
58 |
+
{
|
59 |
+
$tax_percentage = $country_data['tax'];
|
60 |
+
echo "<label for='country_tax'>" . esc_html__( 'Tax Rate', 'wp-e-commerce' ) .":</label> ";
|
61 |
+
echo "<input type='text' id='country_tax' name='country_tax' value='".$tax_percentage."' class='tax_forms' maxlength='3' size='3'/>%";
|
62 |
+
}
|
63 |
+
?>
|
64 |
+
<input type='hidden' name='wpsc_admin_action' value='change_region_tax' />
|
65 |
+
<input class='button-secondary' type='submit' name='submit' value='<?php esc_attr_e( 'Save Changes', 'wp-e-commerce' );?>' />
|
66 |
+
</form>
|
67 |
+
</div>
|
trunk/wpsc-admin/includes/updating-functions.php
ADDED
@@ -0,0 +1,898 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP eCommerce database updating functions
|
4 |
+
*
|
5 |
+
* @package wp-e-commerce
|
6 |
+
* @since 3.8
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WPSC_Update {
|
10 |
+
private static $instance;
|
11 |
+
private $timeout;
|
12 |
+
private $script_start;
|
13 |
+
private $stages;
|
14 |
+
|
15 |
+
public static function get_instance() {
|
16 |
+
if ( empty( self::$instance ) )
|
17 |
+
self::$instance = new WPSC_Update();
|
18 |
+
|
19 |
+
return self::$instance;
|
20 |
+
}
|
21 |
+
|
22 |
+
private function __construct() {
|
23 |
+
$this->timeout = ini_get( 'max_execution_time' );
|
24 |
+
$this->script_start = time();
|
25 |
+
|
26 |
+
if ( ! $this->stages = get_transient( 'wpsc_update_progress' ) ) {
|
27 |
+
$this->stages = array();
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function clean_up() {
|
32 |
+
delete_transient( 'wpsc_update_progress' );
|
33 |
+
delete_transient( 'wpsc_update_product_offset' );
|
34 |
+
delete_transient( 'wpsc_update_variation_comb_offset' );
|
35 |
+
delete_transient( 'wpsc_update_current_product' );
|
36 |
+
delete_transient( 'wpsc_update_current_child_products' );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function check_timeout() {
|
40 |
+
$safety = 2; // refresh page within 2 seconds of PHP max execution time limit
|
41 |
+
$wiggle_room = $this->timeout - $safety;
|
42 |
+
|
43 |
+
$terminate = time() - $this->script_start >= $wiggle_room;
|
44 |
+
|
45 |
+
if ( $terminate ) {
|
46 |
+
do_action( 'wpsc_update_timeout_terminate' );
|
47 |
+
$location = remove_query_arg( array( 'start_over', 'eta', 'current_percent' ) );
|
48 |
+
$location = add_query_arg( 'run_updates', 1, $location );
|
49 |
+
$location = esc_url_raw( apply_filters( 'wpsc_update_terminate_location', $location ) );
|
50 |
+
?>
|
51 |
+
<script type="text/javascript">
|
52 |
+
location.href = "<?php echo $location; ?>"
|
53 |
+
</script>
|
54 |
+
<?php
|
55 |
+
exit;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
public function run( $function, $message = '' ) {
|
60 |
+
|
61 |
+
if ( $message ) {
|
62 |
+
echo "<p>{$message}</p>";
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( empty( $this->stages[$function] ) ) {
|
66 |
+
call_user_func( 'wpsc_' . $function );
|
67 |
+
$this->stages[ $function ] = true;
|
68 |
+
set_transient( 'wpsc_update_progress', $this->stages, WEEK_IN_SECONDS );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
class WPSC_Update_Progress {
|
74 |
+
private $milestone;
|
75 |
+
private $start;
|
76 |
+
private $count;
|
77 |
+
private $current_percent = 0;
|
78 |
+
private $total;
|
79 |
+
private $eta;
|
80 |
+
private $i;
|
81 |
+
|
82 |
+
public function __construct( $total ) {
|
83 |
+
$this->total = $total;
|
84 |
+
$this->milestone = $this->start = time();
|
85 |
+
if ( ! empty( $_REQUEST['current_percent'] ) )
|
86 |
+
$this->current_percent = (int) $_REQUEST['current_percent'];
|
87 |
+
|
88 |
+
add_filter( 'wpsc_update_terminate_location', array( $this, 'filter_terminate_location' ) );
|
89 |
+
|
90 |
+
echo '<div class="wpsc-progress-bar">';
|
91 |
+
if ( ! empty( $_REQUEST['start_over'] ) )
|
92 |
+
return;
|
93 |
+
|
94 |
+
if ( isset( $_REQUEST['current_percent'] ) ) {
|
95 |
+
echo "<div class='block' style='width:" . absint( $_REQUEST['current_percent'] ) . "%;'> </div>";
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( isset( $_REQUEST['eta'] ) ) {
|
99 |
+
$this->eta = (int) $_REQUEST['eta'];
|
100 |
+
$this->print_eta();
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( isset( $_REQUEST['i'] ) )
|
104 |
+
echo "<span>" . absint( $_REQUEST['i'] ) . "/{$this->total}</span>";
|
105 |
+
}
|
106 |
+
|
107 |
+
public function filter_terminate_location( $location ) {
|
108 |
+
$location = add_query_arg( array(
|
109 |
+
'current_percent' => $this->current_percent,
|
110 |
+
'i' => $this->i,
|
111 |
+
), $location );
|
112 |
+
if ( $this->eta !== null )
|
113 |
+
$location = add_query_arg( 'eta', $this->eta, $location );
|
114 |
+
else
|
115 |
+
$location = remove_query_arg( 'eta', $location );
|
116 |
+
return esc_url_raw( $location );
|
117 |
+
}
|
118 |
+
|
119 |
+
private function print_eta() {
|
120 |
+
echo '<div class="eta">';
|
121 |
+
_e( 'Estimated time left:', 'wp-e-commerce' );
|
122 |
+
echo ' ';
|
123 |
+
if ( $this->eta == 0 )
|
124 |
+
_e( 'Under a minute', 'wp-e-commerce' );
|
125 |
+
else
|
126 |
+
printf( _n( '%d minute', '%d minutes', $this->eta, 'wp-e-commerce' ), $this->eta );
|
127 |
+
echo '</div>';
|
128 |
+
}
|
129 |
+
|
130 |
+
public function update( $i ) {
|
131 |
+
if ( empty( $this->count ) )
|
132 |
+
$this->count = $i;
|
133 |
+
|
134 |
+
$this->i = $i;
|
135 |
+
$now = time();
|
136 |
+
$percent = min( floor( $i * 100 / $this->total ), 100 );
|
137 |
+
|
138 |
+
if ( $percent != $this->current_percent ) {
|
139 |
+
echo "<div class='block' style='width:{$percent}%;'> </div>";
|
140 |
+
$this->current_percent = $percent;
|
141 |
+
}
|
142 |
+
|
143 |
+
echo "<span>{$i}/{$this->total}</span>";
|
144 |
+
|
145 |
+
if ( $now - $this->milestone >= 5 ) {
|
146 |
+
$processed = $i - $this->count + 1;
|
147 |
+
$this->eta = floor( ( $this->total - $i ) * ( $now - $this->start ) / ( $processed * 60 ) );
|
148 |
+
$this->print_eta();
|
149 |
+
$this->milestone = $now;
|
150 |
+
}
|
151 |
+
|
152 |
+
if ( $percent == 100 ) {
|
153 |
+
remove_filter( 'wpsc_update_terminate_location', array( $this, 'filter_terminate_location' ) );
|
154 |
+
echo '<div class="eta">' . _x( 'Done!', 'Update routine completed', 'wp-e-commerce' ) . '</div>';
|
155 |
+
echo '</div>';
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
function wpsc_update_step( $i, $total ) {
|
161 |
+
static $current;
|
162 |
+
static $milestone;
|
163 |
+
static $start;
|
164 |
+
static $count;
|
165 |
+
static $current_percent;
|
166 |
+
|
167 |
+
$now = time();
|
168 |
+
|
169 |
+
if ( $current != $total ) {
|
170 |
+
$current = $total;
|
171 |
+
$milestone = $start = $now;
|
172 |
+
$count = $i;
|
173 |
+
}
|
174 |
+
|
175 |
+
$percent = min( round( $i * 100 / $total, 2 ), 100 );
|
176 |
+
|
177 |
+
if ( floor( $percent ) != $current_percent ) {
|
178 |
+
echo "<div class='block' style='width:{$percent}%;'> </div>";
|
179 |
+
$current_percent = floor( $percent );
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( $now - $milestone == 5 ) {
|
183 |
+
$processed = $i - $count + 1;
|
184 |
+
$eta = floor( ( $total - $i ) * ( $now - $start ) / ( $processed * 60 ) );
|
185 |
+
echo '<div class="eta">';
|
186 |
+
_e( 'Estimated time left:', 'wp-e-commerce' );
|
187 |
+
echo ' ';
|
188 |
+
if ( $eta == 0 )
|
189 |
+
_e( 'Under a minute', 'wp-e-commerce' );
|
190 |
+
else
|
191 |
+
printf( _n( '%d minute', '%d minutes', $eta, 'wp-e-commerce' ), $eta );
|
192 |
+
echo '</div>';
|
193 |
+
$milestone = $now;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
function wpsc_update_purchase_logs() {
|
198 |
+
global $wpdb;
|
199 |
+
|
200 |
+
// bump all purchase log status
|
201 |
+
$wpdb->query( "UPDATE " . WPSC_TABLE_PURCHASE_LOGS . " SET processed = processed + 1, plugin_version = '" . WPSC_VERSION . "' WHERE plugin_version IN ('3.6', '3.7') " );
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* wpsc_convert_category_groups function.
|
206 |
+
*
|
207 |
+
* @access public
|
208 |
+
* @return void
|
209 |
+
*/
|
210 |
+
function wpsc_convert_category_groups() {
|
211 |
+
global $wpdb, $user_ID;
|
212 |
+
$wpsc_update = WPSC_Update::get_instance();
|
213 |
+
|
214 |
+
//if they're updating from 3.6, and they've got categories with no group, let's fix that problem, eh?
|
215 |
+
$categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
|
216 |
+
if(count($categorisation_groups) == 0) {
|
217 |
+
$sql = "insert into `".WPSC_TABLE_CATEGORISATION_GROUPS."` set `id` = 1000, `name` = 'Default Group', `description` = 'This is your default category group', `active` = 1, `default` = 1;";
|
218 |
+
$wpdb->query($sql);
|
219 |
+
$sql = "update `".WPSC_TABLE_PRODUCT_CATEGORIES."` set group_id = 1000";
|
220 |
+
$wpdb->query($sql);
|
221 |
+
$categorisation_groups = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CATEGORISATION_GROUPS."` WHERE `active` IN ('1')");
|
222 |
+
}
|
223 |
+
|
224 |
+
foreach((array)$categorisation_groups as $cat_group) {
|
225 |
+
$wpsc_update->check_timeout();
|
226 |
+
|
227 |
+
$category_id = wpsc_get_meta($cat_group->id, 'category_group_id', 'wpsc_category_group');
|
228 |
+
|
229 |
+
if(!is_numeric($category_id) || ( $category_id < 1)) {
|
230 |
+
$new_category = wp_insert_term( $cat_group->name, 'wpsc_product_category', array('description' => $cat_group->description));
|
231 |
+
if(!is_wp_error($new_category))
|
232 |
+
$category_id = $new_category['term_id'];
|
233 |
+
|
234 |
+
}
|
235 |
+
if(is_numeric($category_id)) {
|
236 |
+
|
237 |
+
wpsc_update_meta($cat_group->id, 'category_group_id', $category_id, 'wpsc_category_group');
|
238 |
+
wpsc_update_categorymeta($category_id, 'category_group_id', $cat_group->id);
|
239 |
+
|
240 |
+
wpsc_update_categorymeta($category_id, 'image', '');
|
241 |
+
wpsc_update_categorymeta($category_id, 'uses_billing_address', 0);
|
242 |
+
}
|
243 |
+
|
244 |
+
if(! isset( $new_category ) || !is_wp_error($new_category))
|
245 |
+
wpsc_convert_categories($category_id, $cat_group->id);
|
246 |
+
}
|
247 |
+
delete_option("wpsc_product_category_children");
|
248 |
+
_get_term_hierarchy('wpsc_product_category');
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* wpsc_convert_categories function.
|
253 |
+
*
|
254 |
+
* @access public
|
255 |
+
* @param int $parent_category. (default: 0)
|
256 |
+
* @return void
|
257 |
+
*/
|
258 |
+
function wpsc_convert_categories($new_parent_category, $group_id, $old_parent_category = 0) {
|
259 |
+
global $wpdb, $user_ID;
|
260 |
+
|
261 |
+
if($old_parent_category > 0) {
|
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 (%d)", $group_id, $old_parent_category ) );
|
263 |
+
} else {
|
264 |
+
$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 ) );
|
265 |
+
}
|
266 |
+
$wpsc_update = WPSC_Update::get_instance();
|
267 |
+
|
268 |
+
if($categorisation > 0) {
|
269 |
+
|
270 |
+
foreach((array)$categorisation as $category) {
|
271 |
+
$wpsc_update->check_timeout();
|
272 |
+
$category_id = wpsc_get_meta($category->id, 'category_id', 'wpsc_old_category');
|
273 |
+
|
274 |
+
if(!is_numeric($category_id) || ( $category_id < 1)) {
|
275 |
+
$new_category = wp_insert_term( $category->name, 'wpsc_product_category', array('description' => $category->description, 'parent' => $new_parent_category));
|
276 |
+
if(!is_wp_error($new_category))
|
277 |
+
$category_id = $new_category['term_id'];
|
278 |
+
}
|
279 |
+
|
280 |
+
if(is_numeric($category_id)) {
|
281 |
+
|
282 |
+
wpsc_update_meta($category->id, 'category_id', $category_id, 'wpsc_old_category');
|
283 |
+
wpsc_update_categorymeta($category_id, 'category_id', $category->id);
|
284 |
+
|
285 |
+
wpsc_update_categorymeta($category_id, 'image', $category->image);
|
286 |
+
wpsc_update_categorymeta($category_id, 'display_type', $category->display_type);
|
287 |
+
|
288 |
+
wpsc_update_categorymeta($category_id, 'image_height', $category->image_height);
|
289 |
+
wpsc_update_categorymeta($category_id, 'image_width', $category->image_width);
|
290 |
+
|
291 |
+
$use_additonal_form_set = wpsc_get_categorymeta($category->id, 'use_additonal_form_set');
|
292 |
+
if($use_additonal_form_set != '') {
|
293 |
+
wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $use_additonal_form_set);
|
294 |
+
} else {
|
295 |
+
wpsc_delete_categorymeta($category_id, 'use_additonal_form_set');
|
296 |
+
}
|
297 |
+
|
298 |
+
|
299 |
+
wpsc_update_categorymeta($category_id, 'uses_billing_address', (bool)(int)wpsc_get_categorymeta($category->id, 'uses_billing_address'));
|
300 |
+
|
301 |
+
|
302 |
+
}
|
303 |
+
if($category_id > 0) {
|
304 |
+
wpsc_convert_categories($category_id, $group_id, $category->id);
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
function wpsc_convert_variation_sets() {
|
312 |
+
global $wpdb, $user_ID;
|
313 |
+
$variation_sets = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."`");
|
314 |
+
$wpsc_update = WPSC_Update::get_instance();
|
315 |
+
|
316 |
+
foreach((array)$variation_sets as $variation_set) {
|
317 |
+
$wpsc_update->check_timeout();
|
318 |
+
$variation_set_id = wpsc_get_meta($variation_set->id, 'variation_set_id', 'wpsc_variation_set');
|
319 |
+
|
320 |
+
if(!is_numeric($variation_set_id) || ( $variation_set_id < 1)) {
|
321 |
+
$slug = sanitize_title( $variation_set->name );
|
322 |
+
$dummy_term = (object) array(
|
323 |
+
'taxonomy' => 'wpsc-variation',
|
324 |
+
'parent' => 0,
|
325 |
+
);
|
326 |
+
$slug = wp_unique_term_slug( $slug, $dummy_term );
|
327 |
+
$new_variation_set = wp_insert_term( $variation_set->name, 'wpsc-variation',array('parent' => 0, 'slug' => $slug ) );
|
328 |
+
if( ! is_wp_error( $new_variation_set ) )
|
329 |
+
$variation_set_id = $new_variation_set['term_id'];
|
330 |
+
}
|
331 |
+
|
332 |
+
if( ! empty( $variation_set_id ) && is_numeric($variation_set_id)) {
|
333 |
+
wpsc_update_meta($variation_set->id, 'variation_set_id', $variation_set_id, 'wpsc_variation_set');
|
334 |
+
|
335 |
+
|
336 |
+
$variations = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `variation_id` IN ({$variation_set->id})");
|
337 |
+
foreach((array)$variations as $variation) {
|
338 |
+
$variation_id = wpsc_get_meta($variation->id, 'variation_id', 'wpsc_variation');
|
339 |
+
|
340 |
+
if(!is_numeric($variation_id) || ( $variation_id < 1)) {
|
341 |
+
$new_variation = wp_insert_term( $variation->name, 'wpsc-variation',array('parent' => $variation_set_id));
|
342 |
+
|
343 |
+
if(!is_wp_error($new_variation))
|
344 |
+
$variation_id = $new_variation['term_id'];
|
345 |
+
}
|
346 |
+
if(is_numeric($variation_id)) {
|
347 |
+
wpsc_update_meta($variation->id, 'variation_id', $variation_id, 'wpsc_variation');
|
348 |
+
|
349 |
+
}
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* wpsc_convert_products_to_posts function.
|
357 |
+
*
|
358 |
+
* @access public
|
359 |
+
* @return void
|
360 |
+
*/
|
361 |
+
function wpsc_convert_products_to_posts() {
|
362 |
+
global $wpdb, $user_ID;
|
363 |
+
// Select all products
|
364 |
+
$wpsc_update = WPSC_Update::get_instance();
|
365 |
+
if ( ! empty($wpdb->charset) )
|
366 |
+
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
367 |
+
if ( ! empty($wpdb->collate) )
|
368 |
+
$charset_collate .= " COLLATE $wpdb->collate";
|
369 |
+
|
370 |
+
if ( ! $offset = get_transient( 'wpsc_update_product_offset' ) )
|
371 |
+
$offset = 0;
|
372 |
+
$limit = 90;
|
373 |
+
$sql = "
|
374 |
+
SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . "
|
375 |
+
WHERE active = '1'
|
376 |
+
LIMIT %d, %d
|
377 |
+
";
|
378 |
+
$post_created = get_transient( 'wpsc_update_current_product' );
|
379 |
+
$total = $wpdb->get_var( "SELECT COUNT(*) FROM " . WPSC_TABLE_PRODUCT_LIST . " WHERE active='1'" );
|
380 |
+
$progress = new WPSC_Update_Progress( $total );
|
381 |
+
|
382 |
+
while (true) {
|
383 |
+
$product_data = $wpdb->get_results( $wpdb->prepare( $sql, $offset, $limit ), ARRAY_A );
|
384 |
+
$i = $offset;
|
385 |
+
|
386 |
+
if ( empty( $product_data ) )
|
387 |
+
break;
|
388 |
+
|
389 |
+
foreach((array)$product_data as $product) {
|
390 |
+
$wpsc_update->check_timeout( '</div>' );
|
391 |
+
|
392 |
+
$post_id = 0;
|
393 |
+
|
394 |
+
// if a product is in the middle of being converted
|
395 |
+
if ( $post_created && ! empty( $post_created['original_id'] ) && $post_created['original_id'] == $product['id'] )
|
396 |
+
$post_id = $post_created['post_id'];
|
397 |
+
|
398 |
+
$sku = old_get_product_meta($product['id'], 'sku', true);
|
399 |
+
|
400 |
+
if($post_id == 0) {
|
401 |
+
$post_status = "publish";
|
402 |
+
if($product['publish'] != 1) {
|
403 |
+
$post_status = "draft";
|
404 |
+
}
|
405 |
+
|
406 |
+
//check the product added time with the current time to make sure its not out - this aviods the future post status
|
407 |
+
$product_added_time = strtotime($product['date_added']);
|
408 |
+
$current_time = time();
|
409 |
+
|
410 |
+
$post_date = $product['date_added'];
|
411 |
+
if ((int)$current_time < (int)$product_added_time)
|
412 |
+
$post_date = date("Y-m-d H:i:s");
|
413 |
+
|
414 |
+
$product_post_values = array(
|
415 |
+
'post_author' => $user_ID,
|
416 |
+
'post_date' => $post_date,
|
417 |
+
'post_content' => $product['description'],
|
418 |
+
'post_excerpt' => $product['additional_description'],
|
419 |
+
'post_title' => $product['name'],
|
420 |
+
'post_status' => $post_status,
|
421 |
+
'post_type' => "wpsc-product",
|
422 |
+
'post_name' => $product['name']
|
423 |
+
);
|
424 |
+
|
425 |
+
$product['order'] = $wpdb->get_var( $wpdb->prepare( "
|
426 |
+
SELECT `order` FROM " . WPSC_TABLE_PRODUCT_ORDER . "
|
427 |
+
WHERE product_id = %d
|
428 |
+
", $product['id'] ) );
|
429 |
+
|
430 |
+
$product_post_values['menu_order'] = $product['order'];
|
431 |
+
|
432 |
+
$post_id = wp_insert_post($product_post_values);
|
433 |
+
$post_created = array(
|
434 |
+
'original_id' => $product['id'],
|
435 |
+
'post_id' => $post_id,
|
436 |
+
);
|
437 |
+
set_transient( 'wpsc_update_current_product', $post_created, 604800 );
|
438 |
+
}
|
439 |
+
$product_meta_sql = $wpdb->prepare( "
|
440 |
+
SELECT IF( ( `custom` != 1 ),
|
441 |
+
CONCAT( '_wpsc_', `meta_key` ) ,
|
442 |
+
`meta_key`
|
443 |
+
) AS `meta_key`,
|
444 |
+
`meta_value`
|
445 |
+
FROM `".WPSC_TABLE_PRODUCTMETA."`
|
446 |
+
WHERE `product_id` = %d
|
447 |
+
AND `meta_value` != ''", $product['id'] );
|
448 |
+
|
449 |
+
$product_meta = $wpdb->get_results( $product_meta_sql, ARRAY_A );
|
450 |
+
|
451 |
+
$post_data = array();
|
452 |
+
|
453 |
+
foreach($product_meta as $k => $pm) :
|
454 |
+
if($pm['meta_value'] == 'om')
|
455 |
+
$pm['meta_value'] = 1;
|
456 |
+
$pm['meta_value'] = maybe_unserialize($pm['meta_value']);
|
457 |
+
if(strpos($pm['meta_key'], '_wpsc_') === 0)
|
458 |
+
$post_data['_wpsc_product_metadata'][$pm['meta_key']] = $pm['meta_value'];
|
459 |
+
else
|
460 |
+
update_post_meta($post_id, $pm['meta_key'], $pm['meta_value']);
|
461 |
+
endforeach;
|
462 |
+
|
463 |
+
|
464 |
+
$post_data['_wpsc_original_id'] = (int)$product['id'];
|
465 |
+
$post_data['_wpsc_price'] = (float)$product['price'];
|
466 |
+
$post_data['_wpsc_special_price'] = $post_data['_wpsc_price'] - (float)$product['special_price']; // special price get stored in a weird way in 3.7.x
|
467 |
+
$post_data['_wpsc_stock'] = (float)$product['quantity'];
|
468 |
+
$post_data['_wpsc_is_donation'] = $product['donation'];
|
469 |
+
$post_data['_wpsc_sku'] = $sku;
|
470 |
+
if((bool)$product['quantity_limited'] != true) {
|
471 |
+
$post_data['_wpsc_stock'] = false;
|
472 |
+
}
|
473 |
+
unset($post_data['_wpsc_limited_stock']);
|
474 |
+
|
475 |
+
$post_data['_wpsc_product_metadata']['is_stock_limited'] = (int)(bool)$product['quantity_limited'];
|
476 |
+
|
477 |
+
// Product Weight
|
478 |
+
$post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($product['weight'], $product['weight_unit'], "pound", true);
|
479 |
+
$post_data['_wpsc_product_metadata']['weight_unit'] = $product['weight_unit'];
|
480 |
+
$post_data['_wpsc_product_metadata']['display_weight_as'] = $product['weight_unit'];
|
481 |
+
|
482 |
+
$post_data['_wpsc_product_metadata']['has_no_shipping'] = (int)(bool)$product['no_shipping'];
|
483 |
+
$post_data['_wpsc_product_metadata']['shipping'] = array('local' => $product['pnp'], 'international' => $product['international_pnp']);
|
484 |
+
|
485 |
+
|
486 |
+
$post_data['_wpsc_product_metadata']['quantity_limited'] = (int)(bool)$product['quantity_limited'];
|
487 |
+
$post_data['_wpsc_product_metadata']['special'] = (int)(bool)$product['special'];
|
488 |
+
if(isset($post_data['meta'])) {
|
489 |
+
$post_data['_wpsc_product_metadata']['notify_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['notify_when_none_left'];
|
490 |
+
$post_data['_wpsc_product_metadata']['unpublish_when_none_left'] = (int)(bool)$post_data['meta']['_wpsc_product_metadata']['unpublish_when_none_left'];
|
491 |
+
}
|
492 |
+
$post_data['_wpsc_product_metadata']['no_shipping'] = (int)(bool)$product['no_shipping'];
|
493 |
+
|
494 |
+
foreach($post_data as $meta_key => $meta_value) {
|
495 |
+
// prefix all meta keys with _wpsc_
|
496 |
+
update_post_meta($post_id, $meta_key, $meta_value);
|
497 |
+
}
|
498 |
+
|
499 |
+
// get the wordpress upload directory data
|
500 |
+
$wp_upload_dir_data = wp_upload_dir();
|
501 |
+
$wp_upload_basedir = $wp_upload_dir_data['basedir'];
|
502 |
+
|
503 |
+
$category_ids = array();
|
504 |
+
$category_data = $wpdb->get_col("SELECT `category_id` FROM `".WPSC_TABLE_ITEM_CATEGORY_ASSOC."` WHERE `product_id` IN ('{$product['id']}')");
|
505 |
+
foreach($category_data as $old_category_id) {
|
506 |
+
$category_ids[] = wpsc_get_meta($old_category_id, 'category_id', 'wpsc_old_category');
|
507 |
+
|
508 |
+
}
|
509 |
+
wp_set_product_categories($post_id, $category_ids);
|
510 |
+
|
511 |
+
$product_data = get_post($post_id);
|
512 |
+
$image_data_sql = $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `product_id` = %d ORDER BY `image_order` ASC", $product['id'] );
|
513 |
+
$image_data = $wpdb->get_results( $image_data_sql, ARRAY_A );
|
514 |
+
foreach((array)$image_data as $image_row) {
|
515 |
+
$wpsc_update->check_timeout( '</div>' );
|
516 |
+
// Get the image path info
|
517 |
+
$image_pathinfo = pathinfo($image_row['image']);
|
518 |
+
|
519 |
+
// use the path info to clip off the file extension
|
520 |
+
$image_name = basename($image_pathinfo['basename'], ".{$image_pathinfo['extension']}");
|
521 |
+
|
522 |
+
// construct the full image path
|
523 |
+
$full_image_path = WPSC_IMAGE_DIR.$image_row['image'];
|
524 |
+
$attached_file_path = str_replace($wp_upload_basedir."/", '', $full_image_path);
|
525 |
+
$upload_dir = wp_upload_dir();
|
526 |
+
$new_path = $upload_dir['path'].'/'.$image_name.'.'.$image_pathinfo['extension'];
|
527 |
+
if(is_file($full_image_path)){
|
528 |
+
copy($full_image_path, $new_path);
|
529 |
+
}else{
|
530 |
+
continue;
|
531 |
+
}
|
532 |
+
// construct the full image url
|
533 |
+
$subdir = $upload_dir['subdir'].'/'.$image_name.'.'.$image_pathinfo['extension'];
|
534 |
+
$subdir = substr($subdir , 1);
|
535 |
+
$attachment_id_sql = $wpdb->prepare( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_title` = %s AND `post_parent` = %d LIMIT 1", $image_name, $post_id );
|
536 |
+
$attachment_id = (int)$wpdb->get_var( $attachment_id_sql );
|
537 |
+
|
538 |
+
// get the image MIME type
|
539 |
+
$mime_type_data = wpsc_get_mimetype($full_image_path, true);
|
540 |
+
if((int)$attachment_id == 0 ) {
|
541 |
+
// construct the image data array
|
542 |
+
$image_post_values = array(
|
543 |
+
'post_author' => $user_ID,
|
544 |
+
'post_parent' => $post_id,
|
545 |
+
'post_date' => $product_data->post_date,
|
546 |
+
'post_content' => $image_name,
|
547 |
+
'post_title' => $image_name,
|
548 |
+
'post_status' => "inherit",
|
549 |
+
'post_type' => "attachment",
|
550 |
+
'post_name' => sanitize_title($image_name),
|
551 |
+
'post_mime_type' => $mime_type_data['mime_type'],
|
552 |
+
'menu_order' => absint($image_row['image_order']),
|
553 |
+
'guid' => $new_path
|
554 |
+
);
|
555 |
+
$attachment_id = wp_insert_post($image_post_values);
|
556 |
+
}
|
557 |
+
|
558 |
+
update_attached_file( $attachment_id, $new_path );
|
559 |
+
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $new_path ) );
|
560 |
+
}
|
561 |
+
$i ++;
|
562 |
+
$progress->update( $i );
|
563 |
+
set_transient( 'wpsc_update_product_offset', $i, 604800 );
|
564 |
+
}
|
565 |
+
|
566 |
+
$offset += $limit;
|
567 |
+
}
|
568 |
+
//Just throwing the payment gateway update in here because it doesn't really warrant it's own function :)
|
569 |
+
$custom_gateways = get_option('custom_gateway_options');
|
570 |
+
array_walk($custom_gateways, "wpec_update_gateway");
|
571 |
+
update_option('custom_gateway_options', $custom_gateways);
|
572 |
+
}
|
573 |
+
|
574 |
+
function wpec_update_gateway(&$value,$key) {
|
575 |
+
if ( $value == "testmode" )
|
576 |
+
$value = "wpsc_merchant_testmode";
|
577 |
+
if ( $value == "paypal_certified" )
|
578 |
+
$value = "wpsc_merchant_paypal_express";
|
579 |
+
if ( $value == "paypal_multiple" )
|
580 |
+
$value = "wpsc_merchant_paypal_standard";
|
581 |
+
if ( $value == "paypal_pro" )
|
582 |
+
$value = "wpsc_merchant_paypal_pro";
|
583 |
+
|
584 |
+
}
|
585 |
+
function wpsc_convert_variation_combinations() {
|
586 |
+
global $wpdb, $user_ID, $current_version_number;
|
587 |
+
$wpsc_update = WPSC_Update::get_instance();
|
588 |
+
remove_filter( 'get_terms', 'wpsc_get_terms_category_sort_filter' );
|
589 |
+
if ( ! $offset = get_transient( 'wpsc_update_variation_comb_offset' ) )
|
590 |
+
$offset = 0;
|
591 |
+
$limit = 150;
|
592 |
+
wp_defer_term_counting( true );
|
593 |
+
$sql = "SELECT * FROM {$wpdb->posts} WHERE post_type = 'wpsc-product' AND post_parent = 0 LIMIT %d, %d";
|
594 |
+
|
595 |
+
$total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'wpsc-product' AND post_parent = 0" );
|
596 |
+
$progress = new WPSC_Update_Progress( $total );
|
597 |
+
|
598 |
+
while ( true ) {
|
599 |
+
// get the posts
|
600 |
+
// I use a direct SQL query here because the get_posts function sometimes does not function for a reason that is not clear.
|
601 |
+
$posts = $wpdb->get_results( $wpdb->prepare( $sql, $offset, $limit ) );
|
602 |
+
$i = $offset;
|
603 |
+
if ( empty( $posts ) )
|
604 |
+
break;
|
605 |
+
|
606 |
+
foreach((array)$posts as $post) {
|
607 |
+
if ( ! $child_products = get_transient( 'wpsc_update_current_child_products' ) )
|
608 |
+
$child_products = array();
|
609 |
+
|
610 |
+
$wpsc_update->check_timeout();
|
611 |
+
$base_product_terms = array();
|
612 |
+
//create a post template
|
613 |
+
$child_product_template = array(
|
614 |
+
'post_author' => $user_ID,
|
615 |
+
'post_content' => $post->post_content,
|
616 |
+
'post_excerpt' => $post->post_excerpt,
|
617 |
+
'post_title' => $post->post_title,
|
618 |
+
'post_status' => 'inherit',
|
619 |
+
'post_type' => "wpsc-product",
|
620 |
+
'post_name' => $post->post_title,
|
621 |
+
'post_parent' => $post->ID
|
622 |
+
);
|
623 |
+
|
624 |
+
// select the original product ID
|
625 |
+
$original_id = get_post_meta($post->ID, '_wpsc_original_id', true);
|
626 |
+
$parent_stock = get_post_meta($post->ID, '_wpsc_stock', true);
|
627 |
+
|
628 |
+
// select the variation set associations
|
629 |
+
$variation_set_associations = $wpdb->get_col("SELECT `variation_id` FROM ".WPSC_TABLE_VARIATION_ASSOC." WHERE `associated_id` = '{$original_id}'");
|
630 |
+
// select the variation associations if the count of variation sets is greater than zero
|
631 |
+
if(($original_id > 0) && (count($variation_set_associations) > 0)) {
|
632 |
+
$variation_associations = $wpdb->get_col("SELECT `value_id` FROM ".WPSC_TABLE_VARIATION_VALUES_ASSOC." WHERE `product_id` = '{$original_id}' AND `variation_id` IN(".implode(", ", $variation_set_associations).") AND `visible` IN ('1')");
|
633 |
+
} else {
|
634 |
+
// otherwise, we have no active variations, skip to the next product
|
635 |
+
$i++;
|
636 |
+
$progress->update( $i );
|
637 |
+
set_transient( 'wpsc_update_variation_comb_offset', $i, 604800 );
|
638 |
+
continue;
|
639 |
+
}
|
640 |
+
|
641 |
+
$variation_set_id_sql = "SELECT meta_value FROM " . WPSC_TABLE_META . " WHERE object_type='wpsc_variation_set' AND object_id IN (" . implode( ',', $variation_set_associations ) . ") AND meta_key = 'variation_set_id'";
|
642 |
+
|
643 |
+
$variation_set_terms = $wpdb->get_col( $variation_set_id_sql );
|
644 |
+
|
645 |
+
$variation_associations_sql = "SELECT meta_value FROM " . WPSC_TABLE_META . " WHERE object_type='wpsc_variation' AND object_id IN (" . implode( ',', $variation_associations ) . ") AND meta_key = 'variation_id'";
|
646 |
+
|
647 |
+
$variation_associations_terms = $wpdb->get_col( $variation_associations_sql );
|
648 |
+
|
649 |
+
$base_product_terms = array_merge( $base_product_terms, $variation_set_terms, $variation_associations_terms );
|
650 |
+
|
651 |
+
// Now that we have the term IDs, we need to retrieve the slugs, as wp_set_object_terms will not use IDs in the way we want
|
652 |
+
// If we pass IDs into wp_set_object_terms, it creates terms using the ID as the name.
|
653 |
+
$parent_product_terms = get_terms('wpsc-variation', array(
|
654 |
+
'hide_empty' => 0,
|
655 |
+
'include' => implode(",", $base_product_terms),
|
656 |
+
'orderby' => 'parent'
|
657 |
+
));
|
658 |
+
$base_product_term_slugs = array();
|
659 |
+
foreach($parent_product_terms as $parent_product_term) {
|
660 |
+
$base_product_term_slugs[] = $parent_product_term->slug;
|
661 |
+
|
662 |
+
}
|
663 |
+
|
664 |
+
wp_set_object_terms($post->ID, $base_product_term_slugs, 'wpsc-variation');
|
665 |
+
|
666 |
+
// select all variation "products"
|
667 |
+
$variation_items = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `product_id` = '{$original_id}'");
|
668 |
+
|
669 |
+
foreach((array)$variation_items as $variation_item) {
|
670 |
+
$wpsc_update->check_timeout();
|
671 |
+
// initialize the requisite arrays to empty
|
672 |
+
$variation_ids = array();
|
673 |
+
$term_data = array(
|
674 |
+
'ids' => array(),
|
675 |
+
'slugs' => array(),
|
676 |
+
'names' => array(),
|
677 |
+
);
|
678 |
+
// make a temporary copy of the product teplate
|
679 |
+
$product_values = $child_product_template;
|
680 |
+
|
681 |
+
// select all values this "product" is associated with, then loop through them, getting the term id of the variation using the value ID
|
682 |
+
$variation_associations_combinations = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_VARIATION_COMBINATIONS." WHERE `priceandstock_id` = '{$variation_item->id}'");
|
683 |
+
foreach((array)$variation_associations_combinations as $association) {
|
684 |
+
$variation_id = (int)wpsc_get_meta($association->value_id, 'variation_id', 'wpsc_variation');
|
685 |
+
// discard any values that are null, as they break the selecting of the terms
|
686 |
+
if($variation_id > 0 && in_array($association->value_id, $variation_associations) ) {
|
687 |
+
$variation_ids[] = $variation_id;
|
688 |
+
}
|
689 |
+
}
|
690 |
+
|
691 |
+
// if we have more than zero remaining terms, get the term data, then loop through it to convert it to a more useful set of arrays.
|
692 |
+
if(count($variation_ids) > 0 && ( count($variation_set_associations) == count($variation_ids) ) ) {
|
693 |
+
$combination_terms = get_terms('wpsc-variation', array(
|
694 |
+
'hide_empty' => 0,
|
695 |
+
'include' => implode(",", $variation_ids),
|
696 |
+
));
|
697 |
+
|
698 |
+
foreach($combination_terms as $term) {
|
699 |
+
$term_data['ids'][] = $term->term_id;
|
700 |
+
$term_data['slugs'][] = $term->slug;
|
701 |
+
$term_data['names'][] = $term->name;
|
702 |
+
}
|
703 |
+
|
704 |
+
$product_values['post_title'] .= " (".implode(", ", $term_data['names']).")";
|
705 |
+
$product_values['post_name'] = sanitize_title($product_values['post_title']);
|
706 |
+
|
707 |
+
$selected_post = get_posts(array(
|
708 |
+
'name' => $product_values['post_name'],
|
709 |
+
'post_parent' => $post->ID,
|
710 |
+
'post_type' => "wpsc-product",
|
711 |
+
'post_status' => 'all',
|
712 |
+
'suppress_filters' => true
|
713 |
+
));
|
714 |
+
|
715 |
+
$selected_post = array_shift($selected_post);
|
716 |
+
$key = md5( $post->ID . ':' . count( $term_data['ids'] ) . ':' . implode(',', $term_data['ids'] ) );
|
717 |
+
$child_product_id = false;
|
718 |
+
|
719 |
+
if ( ! empty( $child_products[$key] ) )
|
720 |
+
$child_product_id = $child_products[$key];
|
721 |
+
|
722 |
+
$post_data = array();
|
723 |
+
$post_data['_wpsc_price'] = (float)$variation_item->price;
|
724 |
+
$post_data['_wpsc_stock'] = (float)$variation_item->stock;
|
725 |
+
if( !is_numeric( $parent_stock ) )
|
726 |
+
$post_data['_wpsc_stock'] = false;
|
727 |
+
|
728 |
+
$post_data['_wpsc_original_variation_id'] = (float)$variation_item->id;
|
729 |
+
|
730 |
+
// Product Weight
|
731 |
+
$post_data['_wpsc_product_metadata']['weight'] = wpsc_convert_weight($variation_item->weight, $variation_item->weight_unit, "pound", true);
|
732 |
+
$post_data['_wpsc_product_metadata']['display_weight_as'] = $variation_item->weight_unit;
|
733 |
+
$post_data['_wpsc_product_metadata']['weight_unit'] = $variation_item->weight_unit;
|
734 |
+
|
735 |
+
// Parts of the code (eg wpsc_product_variation_price_from() make the assumption that these meta keys exist
|
736 |
+
$post_data['_wpsc_special_price'] = 0;
|
737 |
+
$post_data['_wpsc_sku'] = '';
|
738 |
+
|
739 |
+
$already_exists = true;
|
740 |
+
|
741 |
+
if ( ! empty( $selected_post ) && $selected_post->ID != $child_product_id ) {
|
742 |
+
$child_product_id = $selected_post->ID;
|
743 |
+
} elseif ( empty( $child_product_id ) ) {
|
744 |
+
$child_product_id = wp_insert_post( $product_values );
|
745 |
+
$already_exists = false;
|
746 |
+
}
|
747 |
+
|
748 |
+
if($child_product_id > 0) {
|
749 |
+
|
750 |
+
foreach($post_data as $meta_key => $meta_value) {
|
751 |
+
// prefix all meta keys with _wpsc_
|
752 |
+
update_post_meta($child_product_id, $meta_key, $meta_value);
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
wp_set_object_terms($child_product_id, $term_data['slugs'], 'wpsc-variation');
|
757 |
+
if ( ! $already_exists ) {
|
758 |
+
$child_products[$key] = $child_product_id;
|
759 |
+
set_transient( 'wpsc_update_current_child_products', $child_products, 604800 );
|
760 |
+
}
|
761 |
+
}
|
762 |
+
|
763 |
+
unset($term_data);
|
764 |
+
}
|
765 |
+
|
766 |
+
}
|
767 |
+
$i++;
|
768 |
+
$progress->update( $i );
|
769 |
+
set_transient( 'wpsc_update_variation_comb_offset', $i, 604800 );
|
770 |
+
delete_transient( 'wpsc_update_current_child_products' );
|
771 |
+
}
|
772 |
+
|
773 |
+
$offset += $limit;
|
774 |
+
|
775 |
+
}
|
776 |
+
delete_option("wpsc-variation_children");
|
777 |
+
_get_term_hierarchy('wpsc-variation');
|
778 |
+
delete_option("wpsc_product_category_children");
|
779 |
+
_get_term_hierarchy('wpsc_product_category');
|
780 |
+
}
|
781 |
+
|
782 |
+
function wpsc_update_files() {
|
783 |
+
global $wpdb, $user_ID;
|
784 |
+
$product_files = $wpdb->get_results("SELECT * FROM ".WPSC_TABLE_PRODUCT_FILES."");
|
785 |
+
$wpsc_update = WPSC_Update::get_instance();
|
786 |
+
|
787 |
+
foreach($product_files as $product_file) {
|
788 |
+
$wpsc_update->check_timeout();
|
789 |
+
$variation_post_ids = array();
|
790 |
+
if(!empty($product_file->product_id)){
|
791 |
+
$product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_file->product_id ));
|
792 |
+
}else{
|
793 |
+
$product_post_id = (int)$wpdb->get_var("SELECT `id` FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE file=".$product_file->id);
|
794 |
+
$product_post_id = (int)$wpdb->get_var($wpdb->prepare( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = %s AND `meta_value` = %d LIMIT 1", '_wpsc_original_id', $product_post_id ));
|
795 |
+
}
|
796 |
+
$variation_items = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_VARIATION_PROPERTIES." WHERE `file` = '{$product_file->id}'");
|
797 |
+
|
798 |
+
if(count($variation_items) > 0) {
|
799 |
+
$variation_post_ids = $wpdb->get_col("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE meta_key = '_wpsc_original_variation_id' AND `meta_value` IN(".implode(", ", $variation_items).")");
|
800 |
+
}
|
801 |
+
|
802 |
+
$attachment_template = array(
|
803 |
+
'post_mime_type' => $product_file->mimetype,
|
804 |
+
'post_title' => $product_file->filename,
|
805 |
+
'post_name' => $product_file->idhash,
|
806 |
+
'post_content' => '',
|
807 |
+
'post_parent' => $product_post_id,
|
808 |
+
'post_type' => "wpsc-product-file",
|
809 |
+
'post_status' => 'inherit'
|
810 |
+
);
|
811 |
+
|
812 |
+
$file_id = wpsc_get_meta($product_file->id, '_new_file_id', 'wpsc_files');
|
813 |
+
|
814 |
+
if($file_id == null && count($variation_post_ids) == 0) {
|
815 |
+
$file_data = $attachment_template;
|
816 |
+
$file_data['post_parent'] = $product_post_id;
|
817 |
+
$new_file_id = wp_insert_post($file_data);
|
818 |
+
wpsc_update_meta($product_file->id, '_new_file_id', $new_file_id, 'wpsc_files');
|
819 |
+
}
|
820 |
+
if(count($variation_post_ids) > 0) {
|
821 |
+
foreach($variation_post_ids as $variation_post_id) {
|
822 |
+
$old_file_id = get_product_meta($variation_post_id, 'old_file_id', true);
|
823 |
+
if($old_file_id == null) {
|
824 |
+
$file_data = $attachment_template;
|
825 |
+
$file_data['post_parent'] = $variation_post_id;
|
826 |
+
$new_file_id = wp_insert_post($file_data);
|
827 |
+
update_product_meta($variation_post_id, 'old_file_id', $product_file->id, 'wpsc_files');
|
828 |
+
}
|
829 |
+
}
|
830 |
+
}
|
831 |
+
|
832 |
+
if(!empty($product_file->preview)){
|
833 |
+
$preview_template = array(
|
834 |
+
'post_mime_type' => $product_file->preview_mimetype,
|
835 |
+
'post_title' => $product_file->preview,
|
836 |
+
'post_name' => $product_file->filename,
|
837 |
+
'post_content' => '',
|
838 |
+
'post_parent' => $new_file_id,
|
839 |
+
'post_type' => "wpsc-product-preview",
|
840 |
+
'post_status' => 'inherit'
|
841 |
+
);
|
842 |
+
wp_insert_post($preview_template);
|
843 |
+
|
844 |
+
|
845 |
+
}
|
846 |
+
}
|
847 |
+
|
848 |
+
$download_ids = $wpdb->get_col("SELECT `id` FROM ".WPSC_TABLE_DOWNLOAD_STATUS."");
|
849 |
+
foreach($download_ids as $download_id) {
|
850 |
+
if(wpsc_get_meta($download_id, '_is_legacy', 'wpsc_downloads') !== 'false') {
|
851 |
+
wpsc_update_meta($download_id, '_is_legacy', 'true', 'wpsc_downloads');
|
852 |
+
}
|
853 |
+
}
|
854 |
+
}
|
855 |
+
|
856 |
+
function wpsc_update_database() {
|
857 |
+
global $wpdb;
|
858 |
+
|
859 |
+
$result = $wpdb->get_results("SHOW COLUMNS FROM ". WPSC_TABLE_PURCHASE_LOGS."", ARRAY_A);
|
860 |
+
if (!$result) {
|
861 |
+
echo 'Could not run query: ' . mysql_error();
|
862 |
+
exit;
|
863 |
+
}
|
864 |
+
foreach($result as $row_key=>$value) {
|
865 |
+
$has_taxes = ($value["Field"] == "wpec_taxes_total" || $value["Field"] == "wpec_taxes_rate") ? true: false;
|
866 |
+
}
|
867 |
+
if (!$has_taxes) {
|
868 |
+
$add_fields = $wpdb->query( "ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_total decimal(11,2)" );
|
869 |
+
$add_fields = $wpdb->query( "ALTER TABLE ".WPSC_TABLE_PURCHASE_LOGS." ADD wpec_taxes_rate decimal(11,2)" );
|
870 |
+
}
|
871 |
+
}
|
872 |
+
/*
|
873 |
+
* The Old Get Product Meta for 3.7 Tables used in converting Products to Posts
|
874 |
+
*/
|
875 |
+
|
876 |
+
function old_get_product_meta($product_id, $key, $single = false) {
|
877 |
+
global $wpdb, $post_meta_cache, $blog_id;
|
878 |
+
$product_id = (int)$product_id;
|
879 |
+
$meta_values = false;
|
880 |
+
if($product_id > 0) {
|
881 |
+
$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 ) );
|
882 |
+
//exit($meta_id);
|
883 |
+
if(is_numeric($meta_id) && ($meta_id > 0)) {
|
884 |
+
if($single != false) {
|
885 |
+
$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"));
|
886 |
+
} else {
|
887 |
+
$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 ) );
|
888 |
+
$meta_values = array_map('maybe_unserialize', $meta_values);
|
889 |
+
}
|
890 |
+
}
|
891 |
+
}
|
892 |
+
if (is_array($meta_values) && (count($meta_values) == 1)) {
|
893 |
+
return array_pop($meta_values);
|
894 |
+
} else {
|
895 |
+
return $meta_values;
|
896 |
+
}
|
897 |
+
}
|
898 |
+
?>
|
trunk/wpsc-admin/includes/walker-variation-checklist.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
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 = 0, $args = array(), $current_object_id = 0 ) {
|
14 |
+
extract( $args );
|
15 |
+
|
16 |
+
if ( empty( $taxonomy ) ) {
|
17 |
+
$taxonomy = 'category';
|
18 |
+
}
|
19 |
+
|
20 |
+
if ( empty( $selected_cats ) ) {
|
21 |
+
$selected_cats = array();
|
22 |
+
}
|
23 |
+
|
24 |
+
$checked = in_array( $category->term_id, $selected_cats );
|
25 |
+
$input_class = ( $depth === 0 ) ? ' class="variation-set"' : '';
|
26 |
+
$li_classes = array( 'wpsc-variation-checklist-item' );
|
27 |
+
|
28 |
+
if ( $depth === 0 && wpsc_is_doing_ajax( 'add_variation_set' ) ) {
|
29 |
+
$li_classes[] = 'ajax';
|
30 |
+
$li_classes[] = 'expanded';
|
31 |
+
} elseif ( in_array( $category->term_id, $this->highlighted ) ) {
|
32 |
+
$li_classes[] = 'ajax';
|
33 |
+
}
|
34 |
+
|
35 |
+
ob_start();
|
36 |
+
?>
|
37 |
+
<li id="<?php echo esc_attr( $taxonomy ); ?>-<?php echo $category->term_id; ?>" class="<?php echo implode( ' ', $li_classes ); ?>">
|
38 |
+
<?php if ( $depth == 0 ): ?>
|
39 |
+
<a href="#" class="expand"><?php echo esc_html_x( 'Expand', 'product variation set', 'wp-e-commerce' ); ?></a>
|
40 |
+
<?php endif ?>
|
41 |
+
|
42 |
+
<label class="selectit">
|
43 |
+
<input
|
44 |
+
<?php echo $input_class; ?>
|
45 |
+
type="checkbox" value="1"
|
46 |
+
<?php if ( $depth !== 0 ): ?>
|
47 |
+
name="edit_var_val[<?php echo $category->parent; ?>][<?php echo $category->term_id ?>]"
|
48 |
+
<?php endif ?>
|
49 |
+
id="in-<?php echo esc_attr( $taxonomy ) . '-' . $category->term_id; ?>"
|
50 |
+
<?php checked( $checked, true ); disabled( empty( $args['disabled'] ), false ); ?>
|
51 |
+
/>
|
52 |
+
<?php echo esc_html( apply_filters( 'wpsc_variation_name', $category->name, $category ) ); ?>
|
53 |
+
</label>
|
54 |
+
<?php
|
55 |
+
$output .= ob_get_clean();
|
56 |
+
}
|
57 |
+
}
|
trunk/wpsc-admin/init.php
ADDED
@@ -0,0 +1,893 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function wpsc_ajax_sales_quarterly() {
|
3 |
+
|
4 |
+
if ( ! wpsc_is_store_admin() ) {
|
5 |
+
return;
|
6 |
+
}
|
7 |
+
|
8 |
+
$lastdate = sanitize_text_field( $_POST['add_start'] );
|
9 |
+
$date = preg_split( '/-/', $lastdate );
|
10 |
+
if ( !isset( $date[0] ) )
|
11 |
+
$date[0] = 0;
|
12 |
+
if ( !isset( $date[1] ) )
|
13 |
+
$date[1] = 0;
|
14 |
+
if ( !isset( $date[2] ) )
|
15 |
+
$date[2] = 0;
|
16 |
+
$lastquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] );
|
17 |
+
if ( $lastquart != get_option( 'wpsc_last_quarter' ) ) {
|
18 |
+
update_option( 'wpsc_last_date', $lastdate );
|
19 |
+
update_option( 'wpsc_fourth_quart', $lastquart );
|
20 |
+
$thirdquart = mktime( 0, 0, 0, $date[1] - 3, $date[2], $date[0] );
|
21 |
+
update_option( 'wpsc_third_quart', $thirdquart );
|
22 |
+
$secondquart = mktime( 0, 0, 0, $date[1] - 6, $date[2], $date[0] );
|
23 |
+
update_option( 'wpsc_second_quart', $secondquart );
|
24 |
+
$firstquart = mktime( 0, 0, 0, $date[1] - 9, $date[2], $date[0] );
|
25 |
+
update_option( 'wpsc_first_quart', $firstquart );
|
26 |
+
$finalquart = mktime( 0, 0, 0, $date[1], $date[2], $date[0] - 1 );
|
27 |
+
update_option( 'wpsc_final_quart', $finalquart );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_quarterly') )
|
32 |
+
add_action( 'admin_init', 'wpsc_ajax_sales_quarterly' );
|
33 |
+
|
34 |
+
function wpsc_delete_file() {
|
35 |
+
$product_id = absint( $_REQUEST['product_id'] );
|
36 |
+
$file_name = basename( $_REQUEST['file_name'] );
|
37 |
+
check_admin_referer( 'delete_file_' . $file_name );
|
38 |
+
|
39 |
+
_wpsc_delete_file( $product_id, $file_name );
|
40 |
+
|
41 |
+
$sendback = wp_get_referer();
|
42 |
+
wp_redirect( $sendback );
|
43 |
+
exit;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_file') )
|
48 |
+
add_action( 'admin_init', 'wpsc_delete_file' );
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Function and action for publishing or unpublishing single products
|
52 |
+
*/
|
53 |
+
function wpsc_ajax_toggle_published() {
|
54 |
+
$product_id = absint( $_GET['product'] );
|
55 |
+
check_admin_referer( 'toggle_publish_' . $product_id );
|
56 |
+
|
57 |
+
$status = (wpsc_toggle_publish_status( $product_id )) ? ('true') : ('false');
|
58 |
+
$sendback = add_query_arg( 'flipped', "1", wp_get_referer() );
|
59 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
60 |
+
exit();
|
61 |
+
}
|
62 |
+
|
63 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'toggle_publish') )
|
64 |
+
add_action( 'admin_init', 'wpsc_ajax_toggle_published' );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Function and action for duplicating products,
|
68 |
+
* Refactored for 3.8
|
69 |
+
* Purposely not duplicating stick post status (logically, products are most often duplicated because they share many attributes, where products are generally 'featured' uniquely.)
|
70 |
+
*/
|
71 |
+
function wpsc_duplicate_product() {
|
72 |
+
|
73 |
+
if ( ! wpsc_is_store_admin() ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Get the original post
|
78 |
+
$id = absint( $_GET['product'] );
|
79 |
+
$post = get_post( $id );
|
80 |
+
|
81 |
+
// Copy the post and insert it
|
82 |
+
if ( isset( $post ) && $post != null ) {
|
83 |
+
|
84 |
+
$duplicate = new WPSC_Duplicate_Product( $post->ID );
|
85 |
+
$new_id = $duplicate->duplicate_product_process();
|
86 |
+
|
87 |
+
$duplicated = true;
|
88 |
+
$sendback = wp_get_referer();
|
89 |
+
$sendback = add_query_arg( 'duplicated', (int) $duplicated, $sendback );
|
90 |
+
|
91 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
92 |
+
exit();
|
93 |
+
} else {
|
94 |
+
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: ', 'wp-e-commerce' ) . $id );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( isset( $_GET['wpsc_admin_action'] ) && ( $_GET['wpsc_admin_action'] == 'duplicate_product' ) )
|
99 |
+
add_action( 'admin_init', 'wpsc_duplicate_product' );
|
100 |
+
|
101 |
+
function wpsc_purchase_log_csv() {
|
102 |
+
if ( 'key' == $_REQUEST['rss_key'] && wpsc_is_store_admin() ) {
|
103 |
+
_wpsc_download_purchase_log_csv( $_REQUEST );
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
function _wpsc_download_purchase_log_csv( $args = array() ) {
|
108 |
+
global $wpdb, $wpsc_gateways;
|
109 |
+
get_currentuserinfo();
|
110 |
+
$count = 0;
|
111 |
+
|
112 |
+
if ( isset( $args['start_timestamp'] ) && isset( $args['end_timestamp'] ) ) {
|
113 |
+
$start_timestamp = $args['start_timestamp'];
|
114 |
+
$end_timestamp = $args['end_timestamp'];
|
115 |
+
$start_end_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date` BETWEEN '%d' AND '%d' ORDER BY `date` DESC";
|
116 |
+
$start_end_sql = apply_filters( 'wpsc_purchase_log_start_end_csv', $start_end_sql );
|
117 |
+
$data = $wpdb->get_results( $wpdb->prepare( $start_end_sql, $start_timestamp, $end_timestamp ), ARRAY_A );
|
118 |
+
/* translators: %1$s is "start" date, %2$s is "to" date */
|
119 |
+
$csv_name = _x( 'Purchase Log %1$s to %2$s.csv', 'exported purchase log csv file name', 'wp-e-commerce' );
|
120 |
+
$csv_name = sprintf( $csv_name, date( "M-d-Y", $start_timestamp ), date( "M-d-Y", $end_timestamp ) );
|
121 |
+
} elseif ( isset( $args['m'] ) ) {
|
122 |
+
$year = (int) substr( $args['m'], 0, 4);
|
123 |
+
$month = (int) substr( $args['m'], -2 );
|
124 |
+
$month_year_sql = "
|
125 |
+
SELECT *
|
126 |
+
FROM " . WPSC_TABLE_PURCHASE_LOGS . "
|
127 |
+
WHERE YEAR(FROM_UNIXTIME(date)) = %d AND MONTH(FROM_UNIXTIME(date)) = %d
|
128 |
+
ORDER BY `id` DESC
|
129 |
+
";
|
130 |
+
$month_year_sql = apply_filters( 'wpsc_purchase_log_month_year_csv', $month_year_sql );
|
131 |
+
$data = $wpdb->get_results( $wpdb->prepare( $month_year_sql, $year, $month ), ARRAY_A );
|
132 |
+
/* translators: %1$s is month, %2$s is year */
|
133 |
+
$csv_name = _x( 'Purchase Log %1$s/%2$s.csv', 'exported purchase log csv file name', 'wp-e-commerce' );
|
134 |
+
$csv_name = sprintf( $csv_name, $month, $year );
|
135 |
+
} else {
|
136 |
+
$sql = apply_filters( 'wpsc_purchase_log_month_year_csv', "SELECT * FROM " . WPSC_TABLE_PURCHASE_LOGS . " ORDER BY `id` DESC" );
|
137 |
+
$data = $wpdb->get_results( $sql, ARRAY_A );
|
138 |
+
$csv_name = _x( "All Purchase Logs.csv", 'exported purchase log csv file name', 'wp-e-commerce' );
|
139 |
+
}
|
140 |
+
|
141 |
+
$form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `type` != 'heading' ORDER BY `checkout_order` DESC;";
|
142 |
+
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
|
143 |
+
|
144 |
+
$headers_array = array(
|
145 |
+
_x( 'Purchase ID' , 'purchase log csv headers', 'wp-e-commerce' ),
|
146 |
+
_x( 'Purchase Total', 'purchase log csv headers', 'wp-e-commerce' ),
|
147 |
+
);
|
148 |
+
$headers2_array = array(
|
149 |
+
_x( 'Payment Gateway', 'purchase log csv headers', 'wp-e-commerce' ),
|
150 |
+
_x( 'Payment Status' , 'purchase log csv headers', 'wp-e-commerce' ),
|
151 |
+
_x( 'Purchase Date' , 'purchase log csv headers', 'wp-e-commerce' ),
|
152 |
+
);
|
153 |
+
$form_headers_array = array();
|
154 |
+
|
155 |
+
$output = '';
|
156 |
+
|
157 |
+
foreach ( (array) $form_data as $form_field ) {
|
158 |
+
if ( empty ( $form_field['unique_name'] ) ) {
|
159 |
+
$form_headers_array[] = $form_field['name'];
|
160 |
+
} else {
|
161 |
+
$prefix = false === strstr( $form_field['unique_name'], 'billing' ) ? _x( 'Shipping ', 'purchase log csv header field prefix', 'wp-e-commerce' ) : _x( 'Billing ', 'purchase log csv header field prefix', 'wp-e-commerce' );
|
162 |
+
$form_headers_array[] = $prefix . $form_field['name'];
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
foreach ( (array) $data as $purchase ) {
|
167 |
+
$form_headers = '';
|
168 |
+
$output .= "\"" . $purchase['id'] . "\","; //Purchase ID
|
169 |
+
$output .= "\"" . $purchase['totalprice'] . "\","; //Purchase Total
|
170 |
+
foreach ( (array) $form_data as $form_field ) {
|
171 |
+
$collected_data_sql = "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
|
172 |
+
$collected_data = $wpdb->get_results( $collected_data_sql, ARRAY_A );
|
173 |
+
$collected_data = $collected_data[0];
|
174 |
+
|
175 |
+
if ( ( 'billingstate' == $form_field['unique_name'] || 'shippingstate' == $form_field['unique_name'] ) && is_numeric( $collected_data['value'] ) )
|
176 |
+
$output .= "\"" . wpsc_get_state_by_id( $collected_data['value'], 'code' ) . "\","; // get form fields
|
177 |
+
else
|
178 |
+
$output .= "\"" . str_replace( array( "\r", "\r\n", "\n" ), ' ', $collected_data['value'] ) . "\","; // get form fields
|
179 |
+
}
|
180 |
+
|
181 |
+
if ( isset( $wpsc_gateways[$purchase['gateway']] ) && isset( $wpsc_gateways[$purchase['gateway']]['display_name'] ) )
|
182 |
+
$output .= "\"" . $wpsc_gateways[$purchase['gateway']]['display_name'] . "\","; //get gateway name
|
183 |
+
else
|
184 |
+
$output .= "\"\",";
|
185 |
+
|
186 |
+
|
187 |
+
$status_name = wpsc_find_purchlog_status_name( $purchase['processed'] );
|
188 |
+
|
189 |
+
$output .= "\"" . $status_name . "\","; //get purchase status
|
190 |
+
$output .= "\"" . date( apply_filters( 'wpsc_purchase_log_csv_date_format', 'jS M Y' ), $purchase['date'] ) . "\","; //date
|
191 |
+
|
192 |
+
$cartsql = "SELECT `prodid`, `quantity`, `name` FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase['id'] . "";
|
193 |
+
$cart = $wpdb->get_results( $cartsql, ARRAY_A );
|
194 |
+
|
195 |
+
if ( $count < count( $cart ) )
|
196 |
+
$count = count( $cart );
|
197 |
+
|
198 |
+
$items = count( $cart );
|
199 |
+
$i = 1;
|
200 |
+
|
201 |
+
// Go through all products in cart and display quantity and sku
|
202 |
+
foreach ( (array) $cart as $item ) {
|
203 |
+
$skuvalue = get_product_meta( $item['prodid'], 'sku', true );
|
204 |
+
if( empty( $skuvalue ) )
|
205 |
+
$skuvalue = __( 'N/A', 'wp-e-commerce' );
|
206 |
+
$output .= "\"" . $item['quantity'] . "\",";
|
207 |
+
$output .= "\"" . str_replace( '"', '\"', $item['name'] ) . "\",";
|
208 |
+
|
209 |
+
if ( $items <= 1 )
|
210 |
+
$output .= "\"" . $skuvalue . "\"" ;
|
211 |
+
elseif ( $items > 1 && $i != $items )
|
212 |
+
$output .= "\"" . $skuvalue . "\"," ;
|
213 |
+
else
|
214 |
+
$output .= "\"" . $skuvalue . "\"" ;
|
215 |
+
|
216 |
+
$i++;
|
217 |
+
}
|
218 |
+
|
219 |
+
$output .= "\n"; // terminates the row/line in the CSV file
|
220 |
+
}
|
221 |
+
// Get the most number of products and create a header for them
|
222 |
+
$headers3 = array();
|
223 |
+
for( $i = 0; $i < $count; $i++ ){
|
224 |
+
$headers3[] = _x( 'Quantity', 'purchase log csv headers', 'wp-e-commerce' );
|
225 |
+
$headers3[] = _x( 'Product Name', 'purchase log csv headers', 'wp-e-commerce' );
|
226 |
+
$headers3[] = _x( 'SKU', 'purchase log csv headers', 'wp-e-commerce' );
|
227 |
+
}
|
228 |
+
|
229 |
+
$headers = '"' . implode( '","', $headers_array ) . '",';
|
230 |
+
$form_headers = '"' . implode( '","', $form_headers_array ) . '",';
|
231 |
+
$headers2 = '"' . implode( '","', $headers2_array ) . '",';
|
232 |
+
$headers3 = '"' . implode( '","', $headers3 ) . '"';
|
233 |
+
|
234 |
+
$headers = apply_filters( 'wpsc_purchase_log_csv_headers', $headers . $form_headers . $headers2 . $headers3, $data, $form_data );
|
235 |
+
$output = apply_filters( 'wpsc_purchase_log_csv_output' , $output, $data, $form_data );
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Fires when the WPSC purchase log is exported as a CSV
|
239 |
+
*/
|
240 |
+
do_action( 'wpsc_purchase_log_csv' );
|
241 |
+
|
242 |
+
header( 'Content-Type: text/csv' );
|
243 |
+
header( 'Content-Disposition: inline; filename="' . $csv_name . '"' );
|
244 |
+
echo $headers . "\n". $output;
|
245 |
+
exit;
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'wpsc_downloadcsv') ) {
|
249 |
+
add_action( 'admin_init', 'wpsc_purchase_log_csv' );
|
250 |
+
}
|
251 |
+
|
252 |
+
if ( isset( $_GET['purchase_log_csv'] ) && ( 'true' == $_GET['purchase_log_csv'] ) )
|
253 |
+
add_action( 'admin_init', 'wpsc_purchase_log_csv' );
|
254 |
+
|
255 |
+
function wpsc_admin_sale_rss() {
|
256 |
+
|
257 |
+
if ( ! wpsc_is_store_admin() ) {
|
258 |
+
return;
|
259 |
+
}
|
260 |
+
|
261 |
+
global $wpdb;
|
262 |
+
if ( ($_GET['rss'] == "true") && ($_GET['rss_key'] == 'key') && ($_GET['action'] == "purchase_log") ) {
|
263 |
+
$sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!='' ORDER BY `date` DESC";
|
264 |
+
$purchase_log = $wpdb->get_results( $sql, ARRAY_A );
|
265 |
+
header( "Content-Type: application/xml; charset=UTF-8" );
|
266 |
+
header( 'Content-Disposition: inline; filename="WP_E-Commerce_Purchase_Log.rss"' );
|
267 |
+
$output = '';
|
268 |
+
$output .= "<?xml version='1.0'?>\n\r";
|
269 |
+
$output .= "<rss version='2.0'>\n\r";
|
270 |
+
$output .= " <channel>\n\r";
|
271 |
+
$output .= " <title>" . _x( 'WP eCommerce Product Log', 'admin rss product feed', 'wp-e-commerce' ) . "</title>\n\r";
|
272 |
+
$output .= " <link>" . admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "</link>\n\r";
|
273 |
+
$output .= " <description>" . _x( 'This is the WP eCommerce Product Log RSS feed', 'admin rss product feed', 'wp-e-commerce' ) . "</description>\n\r";
|
274 |
+
$output .= " <generator>" . _x( 'WP eCommerce Plugin', 'admin rss product feed', 'wp-e-commerce' ) . "</generator>\n\r";
|
275 |
+
|
276 |
+
foreach ( (array)$purchase_log as $purchase ) {
|
277 |
+
$purchase_link = admin_url( 'admin.php?page=' . WPSC_DIR_NAME . '/display-log.php' ) . "&purchaseid=" . $purchase['id'];
|
278 |
+
$purchase_title = _x( 'Purchase # %d', 'admin rss product feed', 'wp-e-commerce' );
|
279 |
+
$purchase_title = sprintf( $purchase_title, $purchase['id'] );
|
280 |
+
$output .= " <item>\n\r";
|
281 |
+
$output .= " <title>{$purchase_title}</title>\n\r";
|
282 |
+
$output .= " <link>$purchase_link</link>\n\r";
|
283 |
+
$output .= " <description>" . _x( 'This is an entry in the purchase log', 'admin rss product feed', 'wp-e-commerce' ) . ".</description>\n\r";
|
284 |
+
$output .= " <pubDate>" . date( "r", $purchase['date'] ) . "</pubDate>\n\r";
|
285 |
+
$output .= " <guid>$purchase_link</guid>\n\r";
|
286 |
+
$output .= " </item>\n\r";
|
287 |
+
}
|
288 |
+
$output .= " </channel>\n\r";
|
289 |
+
$output .= "</rss>";
|
290 |
+
echo $output;
|
291 |
+
exit();
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
if ( isset( $_GET['action'] ) && ( 'purchase_log' == $_GET['action'] ) ) {
|
296 |
+
add_action( 'admin_init', 'wpsc_admin_sale_rss' );
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Do Purchase Log Actions
|
301 |
+
*
|
302 |
+
* All purchase log actions are capability and nonce checked before calling
|
303 |
+
* the relevent 'wpsc_purchase_log_action-{wpsc_purchase_log_action}' hook.
|
304 |
+
*
|
305 |
+
* @since 3.9.0
|
306 |
+
*/
|
307 |
+
function wpsc_do_purchase_log_actions() {
|
308 |
+
|
309 |
+
if ( ! wpsc_is_store_admin() ) {
|
310 |
+
return;
|
311 |
+
}
|
312 |
+
|
313 |
+
if ( isset( $_GET['wpsc_purchase_log_action'] ) && isset( $_GET['id'] ) && isset( $_GET['_wpnonce'] ) ) {
|
314 |
+
$wpsc_purchase_log_action = sanitize_key( $_GET['wpsc_purchase_log_action'] );
|
315 |
+
|
316 |
+
if ( wp_verify_nonce( $_GET['_wpnonce'], 'wpsc_purchase_log_action_' . $wpsc_purchase_log_action ) ) {
|
317 |
+
|
318 |
+
do_action( 'wpsc_purchase_log_action-' . $wpsc_purchase_log_action, absint( $_GET['id'] ) );
|
319 |
+
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
}
|
324 |
+
add_action( 'admin_init', 'wpsc_do_purchase_log_actions' );
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Handle clear downloads lock purchase log action
|
328 |
+
*
|
329 |
+
* The 'wpsc_purchase_log_action-downloads_lock' action hook which calls this function is nonce and capability checked
|
330 |
+
* in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-downloads_lock' ).
|
331 |
+
*
|
332 |
+
* @since 3.9.0
|
333 |
+
*
|
334 |
+
* @param int $log_id Purchase log ID.
|
335 |
+
*/
|
336 |
+
function wpsc_purchase_log_action_downloads_lock( $log_id ) {
|
337 |
+
|
338 |
+
wpsc_purchlog_clear_download_items( $log_id );
|
339 |
+
|
340 |
+
// Redirect back to purchase logs list
|
341 |
+
$sendback = wp_get_referer();
|
342 |
+
$sendback = esc_url_raw( add_query_arg( 'cleared', 1, $sendback ) );
|
343 |
+
wp_redirect( $sendback );
|
344 |
+
exit();
|
345 |
+
|
346 |
+
}
|
347 |
+
add_action( 'wpsc_purchase_log_action-downloads_lock', 'wpsc_purchase_log_action_downloads_lock' );
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Handle delete purchase log action
|
351 |
+
*
|
352 |
+
* The 'wpsc_purchase_log_action-delete' action hook which calls this function is nonce and capability checked
|
353 |
+
* in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-delete' ).
|
354 |
+
*
|
355 |
+
* @since 3.9.0
|
356 |
+
*
|
357 |
+
* @param int $log_id Purchase log ID.
|
358 |
+
*/
|
359 |
+
function wpsc_purchase_log_action_delete( $log_id ) {
|
360 |
+
|
361 |
+
$log = new WPSC_Purchase_Log( $log_id );
|
362 |
+
$deleted = $log->delete();
|
363 |
+
|
364 |
+
// Redirect back to purchase logs list
|
365 |
+
$sendback = wp_get_referer();
|
366 |
+
$sendback = remove_query_arg( array( 'c', 'id' ), $sendback );
|
367 |
+
$sendback = esc_url_raw( add_query_arg( 'deleted', absint( $deleted ), $sendback ) );
|
368 |
+
wp_redirect( $sendback );
|
369 |
+
exit();
|
370 |
+
|
371 |
+
}
|
372 |
+
add_action( 'wpsc_purchase_log_action-delete', 'wpsc_purchase_log_action_delete' );
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Handle email receipt purchase log action
|
376 |
+
*
|
377 |
+
* The 'wpsc_purchase_log_action-email_receipt' action hook which calls this function is nonce and capability checked
|
378 |
+
* in wpsc_do_purchase_log_actions() before triggering do_action( 'wpsc_purchase_log_action-email_receipt' ).
|
379 |
+
*
|
380 |
+
* @since 3.9.0
|
381 |
+
*
|
382 |
+
* @param int $log_id Purchase log ID.
|
383 |
+
*/
|
384 |
+
function wpsc_purchase_log_action_email_receipt( $log_id ) {
|
385 |
+
|
386 |
+
$sent = wpsc_purchlog_resend_email( $log_id );
|
387 |
+
|
388 |
+
// Redirect back to purchase logs list
|
389 |
+
$sendback = wp_get_referer();
|
390 |
+
$sendback = esc_url_raw( add_query_arg( 'sent', absint( $sent ), $sendback ) );
|
391 |
+
wp_redirect( $sendback );
|
392 |
+
exit();
|
393 |
+
|
394 |
+
}
|
395 |
+
add_action( 'wpsc_purchase_log_action-email_receipt', 'wpsc_purchase_log_action_email_receipt' );
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Resend Purchase Log Email
|
399 |
+
*
|
400 |
+
* @param int|string $log_id Required. Purchase log ID (empty string is deprecated).
|
401 |
+
* @return boolean Sent successfully.
|
402 |
+
*/
|
403 |
+
function wpsc_purchlog_resend_email( $log_id = '' ) {
|
404 |
+
|
405 |
+
if ( ! wpsc_is_store_admin() ) {
|
406 |
+
return;
|
407 |
+
}
|
408 |
+
|
409 |
+
global $wpdb;
|
410 |
+
|
411 |
+
// Deprecate empty purchase log ID parameter.
|
412 |
+
if ( $log_id == '' ) {
|
413 |
+
_wpsc_doing_it_wrong( 'wpsc_purchlog_resend_email', __( '$log_id parameter requires a numeric purchase log ID.', 'wp-e-commerce' ), '3.9.0' );
|
414 |
+
|
415 |
+
// Support redirect for legacy purposes for the moment
|
416 |
+
$sendback = esc_url_raw( add_query_arg( 'sent', 0, wp_get_referer() ) );
|
417 |
+
wp_redirect( $sendback );
|
418 |
+
exit();
|
419 |
+
|
420 |
+
}
|
421 |
+
|
422 |
+
$log_id = absint( $log_id );
|
423 |
+
|
424 |
+
if ( $log_id > 0 ) {
|
425 |
+
|
426 |
+
$wpec_taxes_controller = new wpec_taxes_controller();
|
427 |
+
|
428 |
+
if ( is_numeric( $log_id ) ) {
|
429 |
+
$purchase_log = new WPSC_Purchase_Log( $log_id );
|
430 |
+
return wpsc_send_customer_email( $purchase_log );
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
+
return false;
|
435 |
+
}
|
436 |
+
|
437 |
+
// Deprecate resending purchase log email receipt via URL query
|
438 |
+
if ( isset( $_REQUEST['email_buyer_id'] ) && is_numeric( $_REQUEST['email_buyer_id'] ) ) {
|
439 |
+
_wpsc_doing_it_wrong( 'wpsc_purchlog_resend_email', __( 'Do not trigger resend purchase log email action via email_buyer_id URL query. Instead use the Purchase Log Action Links API.', 'wp-e-commerce' ), '3.9.0' );
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Clear Purchase Log Download Locks
|
444 |
+
*
|
445 |
+
* @param string $log_id Required. Purchase log ID (empty string is deprecated).
|
446 |
+
* @return boolean
|
447 |
+
*/
|
448 |
+
function wpsc_purchlog_clear_download_items( $log_id = '' ) {
|
449 |
+
|
450 |
+
if ( ! wpsc_is_store_admin() ) {
|
451 |
+
return;
|
452 |
+
}
|
453 |
+
|
454 |
+
global $wpdb;
|
455 |
+
|
456 |
+
// Deprecate empty purchase log ID parameter.
|
457 |
+
if ( $log_id == '' ) {
|
458 |
+
_wpsc_doing_it_wrong( 'wpsc_purchlog_clear_download_items', __( '$log_id parameter requires a numeric purchase log ID.', 'wp-e-commerce' ), '3.9.0' );
|
459 |
+
return false;
|
460 |
+
}
|
461 |
+
|
462 |
+
$log_id = absint( $log_id );
|
463 |
+
|
464 |
+
if ( $log_id > 0 ) {
|
465 |
+
|
466 |
+
$downloadable_items = (array) $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` = %d", $log_id ), ARRAY_A );
|
467 |
+
|
468 |
+
$wpdb->update( WPSC_TABLE_DOWNLOAD_STATUS, array( 'ip_number' => '' ), array( 'purchid' => $log_id ), '%s', '%d' );
|
469 |
+
|
470 |
+
$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" );
|
471 |
+
$email_address = $wpdb->get_var( $wpdb->prepare( "SELECT `value` FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = '{$email_form_field}' LIMIT 1", $log_id ) );
|
472 |
+
|
473 |
+
foreach ( $downloadable_items as $downloadable_item ) {
|
474 |
+
$download_links .= add_query_arg( 'downloadid', $downloadable_item['uniqueid'], home_url() ) . "\n";
|
475 |
+
}
|
476 |
+
|
477 |
+
wp_mail( $email_address, __( 'The administrator has unlocked your file', 'wp-e-commerce' ), str_replace( "[download_links]", $download_links, __( 'Dear Customer, We are pleased to advise you that your order has been updated and your downloads are now active. Please download your purchase using the links provided below. [download_links] Thank you for your order.', 'wp-e-commerce' ) ), "From: " . get_option( 'return_email' ) );
|
478 |
+
|
479 |
+
return true;
|
480 |
+
|
481 |
+
}
|
482 |
+
|
483 |
+
return false;
|
484 |
+
|
485 |
+
}
|
486 |
+
|
487 |
+
// Deprecate clearing purchase log download locks via URL query
|
488 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'clear_locks') ) {
|
489 |
+
_wpsc_doing_it_wrong( 'wpsc_purchlog_clear_download_items', __( 'Do not trigger clear purchase log download locks action via wpsc_admin_action = clear_locks URL query. Instead use the Purchase Log Action Links API.', 'wp-e-commerce' ), '3.9.0' );
|
490 |
+
}
|
491 |
+
|
492 |
+
//bulk actions for purchase log
|
493 |
+
function wpsc_purchlog_bulk_modify() {
|
494 |
+
|
495 |
+
if ( ! wpsc_is_store_admin() ) {
|
496 |
+
return;
|
497 |
+
}
|
498 |
+
|
499 |
+
if ( $_POST['purchlog_multiple_status_change'] != -1 ) {
|
500 |
+
if ( is_numeric( $_POST['purchlog_multiple_status_change'] ) && $_POST['purchlog_multiple_status_change'] != 'delete' ) {
|
501 |
+
foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
|
502 |
+
wpsc_purchlog_edit_status( $purchlogid, $_POST['purchlog_multiple_status_change'] );
|
503 |
+
$updated++;
|
504 |
+
}
|
505 |
+
} elseif ( $_POST['purchlog_multiple_status_change'] == 'delete' ) {
|
506 |
+
foreach ( (array)$_POST['purchlogids'] as $purchlogid ) {
|
507 |
+
|
508 |
+
$log = new WPSC_Purchase_Log( $purchlogid );
|
509 |
+
$deleted_log = $log->delete();
|
510 |
+
if ( $deleted_log ) {
|
511 |
+
$deleted++;
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
$sendback = wp_get_referer();
|
517 |
+
if ( isset( $updated ) ) {
|
518 |
+
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
519 |
+
}
|
520 |
+
if ( isset( $deleted ) ) {
|
521 |
+
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
522 |
+
}
|
523 |
+
if ( isset( $_POST['view_purchlogs_by'] ) ) {
|
524 |
+
$sendback = add_query_arg( 'view_purchlogs_by', $_POST['view_purchlogs_by'], $sendback );
|
525 |
+
}
|
526 |
+
if ( isset( $_POST['view_purchlogs_by_status'] ) ) {
|
527 |
+
$sendback = add_query_arg( 'view_purchlogs_by_status', $_POST['view_purchlogs_by_status'], $sendback );
|
528 |
+
}
|
529 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
530 |
+
exit();
|
531 |
+
}
|
532 |
+
|
533 |
+
if ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') ) {
|
534 |
+
add_action( 'admin_init', 'wpsc_purchlog_bulk_modify' );
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Update Purchase Log Notes
|
539 |
+
*
|
540 |
+
* @param int $purchlog_id Purchase log ID.
|
541 |
+
* @param string $purchlog_notes Notes.
|
542 |
+
*
|
543 |
+
* @return mixed Result of save.
|
544 |
+
*/
|
545 |
+
function wpsc_purchlogs_update_notes( $purchlog_id = 0, $purchlog_notes = '' ) {
|
546 |
+
if ( empty( $purchlog_id ) && isset( $_POST['purchlog_id'] ) && '' == $purchlog_notes ) {
|
547 |
+
$purchlog_id = absint( $_POST['purchlog_id'] );
|
548 |
+
|
549 |
+
if ( isset( $_POST['purchlog_notes'] ) ) {
|
550 |
+
$purchlog_notes = wp_unslash( $_POST['purchlog_notes'] );
|
551 |
+
}
|
552 |
+
}
|
553 |
+
|
554 |
+
if ( ! $purchlog_id ) {
|
555 |
+
return;
|
556 |
+
}
|
557 |
+
|
558 |
+
$purchase_log = $purchlog_id instanceof WPSC_Purchase_Log
|
559 |
+
? $purchlog_id
|
560 |
+
: wpsc_get_order( $purchlog_id );
|
561 |
+
|
562 |
+
$notes = wpsc_get_order_notes( $purchase_log );
|
563 |
+
|
564 |
+
return $notes->add( $purchlog_notes )->save();
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Delete a purchase log
|
569 |
+
*
|
570 |
+
* @deprecated Use WPSC_Purchase_Log->delete() instead.
|
571 |
+
*
|
572 |
+
* @param int|string $purchlog_id Required. Purchase log ID (empty string is deprecated).
|
573 |
+
* @return boolean Deleted successfully.
|
574 |
+
*/
|
575 |
+
function wpsc_delete_purchlog( $purchlog_id = '' ) {
|
576 |
+
|
577 |
+
global $wpdb;
|
578 |
+
|
579 |
+
// Deprecate empty purchase log ID parameter.
|
580 |
+
if ( $purchlog_id == '' ) {
|
581 |
+
_wpsc_doing_it_wrong( 'wpsc_delete_purchlog', __( '$purchlog_id parameter requires a numeric purchase log ID.', 'wp-e-commerce' ), '3.9.0' );
|
582 |
+
return false;
|
583 |
+
}
|
584 |
+
|
585 |
+
$log = new WPSC_Purchase_Log( $purchlog_id );
|
586 |
+
|
587 |
+
return $log->delete();
|
588 |
+
|
589 |
+
}
|
590 |
+
|
591 |
+
// Deprecate deleting purchase log via URL query
|
592 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'delete_purchlog' ) ) {
|
593 |
+
_wpsc_doing_it_wrong( 'wpsc_delete_purchlog', __( 'Do not trigger delete purchase log action via wpsc_admin_action = delete_purchlog URL query. Instead use the Purchase Log Action Links API.', 'wp-e-commerce' ), '3.9.0' );
|
594 |
+
}
|
595 |
+
|
596 |
+
function _wpsc_action_flush_rewrite_rules() {
|
597 |
+
flush_rewrite_rules( false );
|
598 |
+
}
|
599 |
+
|
600 |
+
function wpsc_update_option_product_category_hierarchical_url() {
|
601 |
+
_wpsc_action_flush_rewrite_rules();
|
602 |
+
}
|
603 |
+
|
604 |
+
add_action( 'update_option_product_category_hierarchical_url', 'wpsc_update_option_product_category_hierarchical_url' );
|
605 |
+
|
606 |
+
function _wpsc_action_sanitize_option_grid_number_per_row( $value, $option ) {
|
607 |
+
$value = (int) $value;
|
608 |
+
if ( $value === 0 ) {
|
609 |
+
add_settings_error( $option, 'invalid_grid_number_per_row', __( 'You just set the number of item per row for the grid view to 0. This means the column width will fall back to using whatever CSS you have for it. This could break your theme layout, so please make sure you have adjusted your theme\'s CSS accordingly.', 'wp-e-commerce' ) );
|
610 |
+
}
|
611 |
+
|
612 |
+
return $value;
|
613 |
+
}
|
614 |
+
add_filter( 'sanitize_option_grid_number_per_row', '_wpsc_action_sanitize_option_grid_number_per_row', 10, 2 );
|
615 |
+
|
616 |
+
/**
|
617 |
+
* Automatically enable "Anyone can register" if registration before checkout is required.
|
618 |
+
*
|
619 |
+
* @since 3.8.9
|
620 |
+
* @access private
|
621 |
+
* @param mixed $old_value Old value
|
622 |
+
* @param mixed $new_value New value
|
623 |
+
*/
|
624 |
+
function _wpsc_action_update_option_require_register( $old_value, $new_value ) {
|
625 |
+
if ( $new_value == 1 && ! get_option( 'users_can_register' ) ) {
|
626 |
+
update_option( 'users_can_register', 1 );
|
627 |
+
$message = __( 'You wanted to require your customers to log in before checking out. However, the WordPress setting <a href="%s">"Anyone can register"</a> was disabled. WP eCommerce has enabled that setting for you automatically.', 'wp-e-commerce' );
|
628 |
+
$message = sprintf( $message, admin_url( 'options-general.php' ) );
|
629 |
+
add_settings_error( 'require_register', 'users_can_register_turned_on', $message, 'updated' );
|
630 |
+
}
|
631 |
+
}
|
632 |
+
add_action( 'update_option_require_register', '_wpsc_action_update_option_require_register', 10, 2 );
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Automatically turn off "require registration before checkout" if "Anyone can register" is disabled.
|
636 |
+
*
|
637 |
+
* @since 3.8.9
|
638 |
+
* @access private
|
639 |
+
* @param mixed $old_value Old value
|
640 |
+
* @param mixed $new_value New value
|
641 |
+
*/
|
642 |
+
function _wpsc_action_update_option_users_can_register( $old_value, $new_value ) {
|
643 |
+
if ( ! $new_value && get_option( 'require_register' ) ) {
|
644 |
+
update_option( 'require_register', 0 );
|
645 |
+
$message = __( 'You just disabled the "Anyone can register" setting. As a result, the <a href="%s">"Require registration before checking out"</a> setting has been disabled.', 'wp-e-commerce' );
|
646 |
+
$message = sprintf( $message, admin_url( 'options-general.php?page=wpsc-settings&tab=checkout' ) );
|
647 |
+
add_settings_error( 'users_can_register', 'require_register_turned_off', $message, 'updated' );
|
648 |
+
}
|
649 |
+
}
|
650 |
+
add_action( 'update_option_users_can_register', '_wpsc_action_update_option_users_can_register', 10, 2 );
|
651 |
+
|
652 |
+
/**
|
653 |
+
* wpsc_update_page_urls gets the permalinks for products pages and stores them in the options for quick reference
|
654 |
+
* @public
|
655 |
+
*
|
656 |
+
* @since 3.6
|
657 |
+
* @param $auto (Boolean) true if coming from WordPress Permalink Page, false otherwise
|
658 |
+
* @return nothing
|
659 |
+
*/
|
660 |
+
function wpsc_update_page_urls( $auto = false ) {
|
661 |
+
|
662 |
+
if ( ! wpsc_is_store_admin() ) {
|
663 |
+
return;
|
664 |
+
}
|
665 |
+
|
666 |
+
wpsc_update_permalink_slugs();
|
667 |
+
wpsc_core_load_page_titles();
|
668 |
+
wpsc_register_post_types();
|
669 |
+
|
670 |
+
if ( ! $auto ) {
|
671 |
+
$sendback = wp_get_referer();
|
672 |
+
if ( isset( $updated ) )
|
673 |
+
$sendback = add_query_arg( 'updated', $updated, $sendback );
|
674 |
+
|
675 |
+
if ( isset( $_SESSION['wpsc_settings_curr_page'] ) )
|
676 |
+
$sendback = add_query_arg( 'tab', $_SESSION['wpsc_settings_curr_page'], $sendback );
|
677 |
+
|
678 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
679 |
+
exit();
|
680 |
+
}
|
681 |
+
}
|
682 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'update_page_urls') )
|
683 |
+
add_action( 'admin_init', 'wpsc_update_page_urls' );
|
684 |
+
|
685 |
+
//change the regions tax settings
|
686 |
+
function wpsc_change_region_tax() {
|
687 |
+
|
688 |
+
if ( ! wpsc_is_store_admin() ) {
|
689 |
+
return;
|
690 |
+
}
|
691 |
+
|
692 |
+
global $wpdb;
|
693 |
+
if ( is_array( $_POST['region_tax'] ) ) {
|
694 |
+
foreach ( $_POST['region_tax'] as $region_id => $tax ) {
|
695 |
+
if ( is_numeric( $region_id ) && is_numeric( $tax ) ) {
|
696 |
+
$previous_tax = $wpdb->get_var( $wpdb->prepare( "SELECT `tax` FROM `" . WPSC_TABLE_REGION_TAX . "` WHERE `id` = %d LIMIT 1", $region_id ) );
|
697 |
+
if ( $tax != $previous_tax ) {
|
698 |
+
$wpdb->update(
|
699 |
+
WPSC_TABLE_REGION_TAX,
|
700 |
+
array(
|
701 |
+
'tax' => $tax
|
702 |
+
),
|
703 |
+
array(
|
704 |
+
'id' => $region_id
|
705 |
+
),
|
706 |
+
'%s',
|
707 |
+
'%d'
|
708 |
+
);
|
709 |
+
$changes_made = true;
|
710 |
+
}
|
711 |
+
}
|
712 |
+
}
|
713 |
+
$sendback = wp_get_referer();
|
714 |
+
wp_redirect( $sendback );
|
715 |
+
}
|
716 |
+
}
|
717 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'change_region_tax') )
|
718 |
+
add_action( 'admin_init', 'wpsc_change_region_tax' );
|
719 |
+
|
720 |
+
function wpsc_product_files_existing() {
|
721 |
+
//List all product_files, with checkboxes
|
722 |
+
|
723 |
+
if ( ! wpsc_is_store_admin() ) {
|
724 |
+
return;
|
725 |
+
}
|
726 |
+
|
727 |
+
$product_id = absint( $_GET["product_id"] );
|
728 |
+
$file_list = wpsc_uploaded_files();
|
729 |
+
|
730 |
+
$args = array(
|
731 |
+
'post_type' => 'wpsc-product-file',
|
732 |
+
'post_parent' => $product_id,
|
733 |
+
'numberposts' => -1,
|
734 |
+
'post_status' => 'all'
|
735 |
+
);
|
736 |
+
$attached_files = (array)get_posts( $args );
|
737 |
+
|
738 |
+
$attached_files_by_file = array();
|
739 |
+
foreach ( $attached_files as $key => $attached_file ) {
|
740 |
+
$attached_files_by_file[$attached_file->post_title] = & $attached_files[$key];
|
741 |
+
}
|
742 |
+
|
743 |
+
$output = "<span class='admin_product_notes select_product_note '>" . esc_html__( 'Choose a downloadable file for this product:', 'wp-e-commerce' ) . "</span><br>";
|
744 |
+
$output .= "<form method='post' class='product_upload'>";
|
745 |
+
$output .= '<div class="ui-widget-content multiple-select select_product_file" style="width:100%">';
|
746 |
+
$num = 0;
|
747 |
+
foreach ( (array)$file_list as $file ) {
|
748 |
+
$num++;
|
749 |
+
$checked_curr_file = "";
|
750 |
+
if ( isset( $attached_files_by_file[$file['display_filename']] ) ) {
|
751 |
+
$checked_curr_file = "checked='checked'";
|
752 |
+
}
|
753 |
+
|
754 |
+
$output .= "<p " . ((($num % 2) > 0) ? '' : "class='alt'") . " id='select_product_file_row_$num'>\n";
|
755 |
+
$output .= " <input type='checkbox' name='select_product_file[]' value='" . $file['real_filename'] . "' id='select_product_file_$num' " . $checked_curr_file . " />\n";
|
756 |
+
$output .= " <label for='select_product_file_$num'>" . $file['display_filename'] . "</label>\n";
|
757 |
+
$output .= "</p>\n";
|
758 |
+
}
|
759 |
+
|
760 |
+
$output .= "</div>";
|
761 |
+
$output .= "<input type='hidden' id='hidden_id' value='$product_id' />";
|
762 |
+
$output .= "<input data-nonce='" . _wpsc_create_ajax_nonce( 'upload_product_file' ) . "' type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='" . esc_html__( 'Save Product Files', 'wp-e-commerce' ) . "' />";
|
763 |
+
$output .= "</form>";
|
764 |
+
$output .= "<div class='" . ((is_numeric( $product_id )) ? "edit_" : "") . "select_product_handle'><div></div></div>";
|
765 |
+
$output .= "<script type='text/javascript'>\n\r";
|
766 |
+
$output .= "var select_min_height = " . (25 * 3) . ";\n\r";
|
767 |
+
$output .= "var select_max_height = " . (25 * ($num + 1)) . ";\n\r";
|
768 |
+
$output .= "</script>";
|
769 |
+
echo $output;
|
770 |
+
}
|
771 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'product_files_existing') )
|
772 |
+
add_action( 'admin_init', 'wpsc_product_files_existing' );
|
773 |
+
|
774 |
+
function wpsc_update_variations() {
|
775 |
+
$product_id = absint( $_POST["product_id"] );
|
776 |
+
$product_type_object = get_post_type_object('wpsc-product');
|
777 |
+
if (!current_user_can($product_type_object->cap->edit_post, $product_id))
|
778 |
+
return;
|
779 |
+
|
780 |
+
//Setup postdata
|
781 |
+
$post_data = array();
|
782 |
+
$post_data['edit_var_val'] = isset( $_POST['edit_var_val'] ) ? $_POST["edit_var_val"] : '';
|
783 |
+
|
784 |
+
//Add or delete variations
|
785 |
+
wpsc_edit_product_variations( $product_id, $post_data );
|
786 |
+
}
|
787 |
+
|
788 |
+
if ( isset($_POST["edit_var_val"]) )
|
789 |
+
add_action( 'admin_init', 'wpsc_update_variations', 50 );
|
790 |
+
|
791 |
+
function wpsc_delete_variation_set() {
|
792 |
+
check_admin_referer( 'delete-variation' );
|
793 |
+
|
794 |
+
if ( is_numeric( $_GET['deleteid'] ) ) {
|
795 |
+
$variation_id = absint( $_GET['deleteid'] );
|
796 |
+
|
797 |
+
$variation_set = get_term( $variation_id, 'wpsc-variation', ARRAY_A );
|
798 |
+
|
799 |
+
$variations = get_terms( 'wpsc-variation', array(
|
800 |
+
'hide_empty' => 0,
|
801 |
+
'parent' => $variation_id
|
802 |
+
) );
|
803 |
+
|
804 |
+
foreach ( (array) $variations as $variation ) {
|
805 |
+
$return_value = wp_delete_term( $variation->term_id, 'wpsc-variation' );
|
806 |
+
}
|
807 |
+
|
808 |
+
if ( !empty( $variation_set ) ) {
|
809 |
+
$return_value = wp_delete_term( $variation_set['term_id'], 'wpsc-variation' );
|
810 |
+
}
|
811 |
+
$deleted = 1;
|
812 |
+
}
|
813 |
+
|
814 |
+
$sendback = wp_get_referer();
|
815 |
+
if ( isset( $deleted ) ) {
|
816 |
+
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
817 |
+
}
|
818 |
+
$sendback = remove_query_arg( array(
|
819 |
+
'deleteid',
|
820 |
+
'variation_id'
|
821 |
+
), $sendback );
|
822 |
+
|
823 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
824 |
+
exit();
|
825 |
+
}
|
826 |
+
|
827 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-variation-set' == $_REQUEST['wpsc_admin_action'] ) )
|
828 |
+
add_action( 'admin_init', 'wpsc_delete_variation_set' );
|
829 |
+
|
830 |
+
function wpsc_backup_theme() {
|
831 |
+
|
832 |
+
if ( ! wpsc_is_store_admin() ) {
|
833 |
+
return;
|
834 |
+
}
|
835 |
+
|
836 |
+
$wp_theme_path = get_stylesheet_directory();
|
837 |
+
wpsc_recursive_copy( $wp_theme_path, WPSC_THEME_BACKUP_DIR );
|
838 |
+
$_SESSION['wpsc_themes_backup'] = true;
|
839 |
+
$sendback = wp_get_referer();
|
840 |
+
wp_redirect( $sendback );
|
841 |
+
|
842 |
+
exit();
|
843 |
+
}
|
844 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( $_REQUEST['wpsc_admin_action'] == 'backup_themes' ) )
|
845 |
+
add_action( 'admin_init', 'wpsc_backup_theme' );
|
846 |
+
|
847 |
+
/**
|
848 |
+
* Delete a coupon
|
849 |
+
*
|
850 |
+
* @since 3.8
|
851 |
+
*/
|
852 |
+
function wpsc_delete_coupon(){
|
853 |
+
|
854 |
+
global $wpdb;
|
855 |
+
|
856 |
+
check_admin_referer( 'delete-coupon' );
|
857 |
+
|
858 |
+
if ( ! function_exists( 'wpsc_is_store_admin' ) || ! wpsc_is_store_admin() ) {
|
859 |
+
return;
|
860 |
+
}
|
861 |
+
|
862 |
+
$deleted = 0;
|
863 |
+
|
864 |
+
if ( isset( $_GET['delete_id'] ) ) {
|
865 |
+
$coupon = new WPSC_Coupon( $_GET['delete_id'] );
|
866 |
+
$coupon->delete();
|
867 |
+
$deleted = 1;
|
868 |
+
}
|
869 |
+
|
870 |
+
$sendback = wp_get_referer();
|
871 |
+
|
872 |
+
if ( $deleted ) {
|
873 |
+
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
874 |
+
}
|
875 |
+
|
876 |
+
$sendback = remove_query_arg( array( 'deleteid', 'wpsc_admin_action' ), $sendback );
|
877 |
+
wp_redirect( esc_url_raw( $sendback ) );
|
878 |
+
exit();
|
879 |
+
|
880 |
+
}
|
881 |
+
|
882 |
+
// Delete Coupon
|
883 |
+
if ( isset( $_REQUEST['wpsc_admin_action'] ) && ( 'wpsc-delete-coupon' == $_REQUEST['wpsc_admin_action'] ) ) {
|
884 |
+
add_action( 'admin_init', 'wpsc_delete_coupon' );
|
885 |
+
}
|
886 |
+
|
887 |
+
function _wpsc_action_update_option_base_country( $old_value, $new_value ) {
|
888 |
+
global $wpdb;
|
889 |
+
$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')", $new_value ) );
|
890 |
+
if ( ! $region_count )
|
891 |
+
update_option( 'base_region', '' );
|
892 |
+
}
|
893 |
+
add_action( 'update_option_base_country', '_wpsc_action_update_option_base_country', 10, 2 );
|
trunk/wpsc-admin/js/admin-legacy.js
ADDED
@@ -0,0 +1,1066 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var someresults=function() {
|
2 |
+
document.getElementById('changenotice').innerHTML = "Thank you, your change has been saved";
|
3 |
+
}
|
4 |
+
|
5 |
+
var noresults=function() {
|
6 |
+
// see nothing, know nothing, do nothing
|
7 |
+
}
|
8 |
+
|
9 |
+
if(typeof(select_min_height) == undefined) {
|
10 |
+
var select_min_height = 0;
|
11 |
+
var select_max_height = 200;
|
12 |
+
}
|
13 |
+
|
14 |
+
jQuery(document).ready(
|
15 |
+
function() {
|
16 |
+
// jQuery('div.select_product_file').Resizable({
|
17 |
+
// minWidth: 300,
|
18 |
+
// minHeight: select_min_height,
|
19 |
+
// maxWidth: 300,
|
20 |
+
// maxHeight: select_max_height,
|
21 |
+
// handlers: {
|
22 |
+
// s: '.select_product_handle'
|
23 |
+
// }
|
24 |
+
// });
|
25 |
+
|
26 |
+
jQuery("div.admin_product_name a.shorttag_toggle").toggle(
|
27 |
+
function () {
|
28 |
+
jQuery("div.admin_product_shorttags", jQuery(this).parent("div.admin_product_name")).css('display', 'block');
|
29 |
+
},
|
30 |
+
function () {
|
31 |
+
//jQuery("div#admin_product_name a.shorttag_toggle").toggleClass('toggled');
|
32 |
+
jQuery("div.admin_product_shorttags", jQuery(this).parent("div.admin_product_name")).css('display', 'none');
|
33 |
+
}
|
34 |
+
);
|
35 |
+
enablebuttons();
|
36 |
+
|
37 |
+
}
|
38 |
+
);
|
39 |
+
|
40 |
+
function activate_resizable() {
|
41 |
+
// jQuery('div.edit_select_product_file').Resizable({
|
42 |
+
// minWidth: 300,
|
43 |
+
// minHeight: select_min_height,
|
44 |
+
// maxWidth: 300,
|
45 |
+
// maxHeight: select_max_height,
|
46 |
+
// handlers: {
|
47 |
+
// s: '.edit_select_product_handle'
|
48 |
+
// }
|
49 |
+
// });
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
jQuery(document).ready(function(){
|
55 |
+
// bind_shipping_rate_deletion();
|
56 |
+
jQuery(function() {
|
57 |
+
// set us up some mighty fine tabs for the options page
|
58 |
+
|
59 |
+
if (typeof jQuery('#wpsc_options > ul#tabs').tabs != "undefined") {
|
60 |
+
$tabs = jQuery('#wpsc_options > ul#tabs').tabs();
|
61 |
+
}
|
62 |
+
// current_tab = window.location.href.split('#');
|
63 |
+
|
64 |
+
// this here code handles remembering what tab you were on
|
65 |
+
jQuery('#wpsc_options > ul').bind('tabsselect', function(event, ui) {
|
66 |
+
form_action = jQuery('#cart_options').attr('action').split('#'); //split at the #
|
67 |
+
form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
68 |
+
jQuery('#cart_options').attr('action', form_action); // stick it all back in the action attribute
|
69 |
+
// var current_tab = $tabs.data('selected.tabs');
|
70 |
+
// alert(current_tab);
|
71 |
+
// if (current_tab == '3') {
|
72 |
+
// form_action = jQuery('#shipping_options').attr('action').split('#'); //split at the #
|
73 |
+
// form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
74 |
+
//
|
75 |
+
// jQuery('#shipping_options').attr('action', form_action); // stick it all back in the action attribute
|
76 |
+
// }
|
77 |
+
// if (current_tab == '4') {
|
78 |
+
// form_action = jQuery('#gateway_options').attr('action').split('#'); //split at the #
|
79 |
+
// form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
80 |
+
// jQuery('#gateway_options').attr('action', form_action); // stick it all back in the action attribute
|
81 |
+
// }
|
82 |
+
});
|
83 |
+
jQuery('#wpsc_options > ul').bind('tabsload', function(event, ui) {
|
84 |
+
bind_shipping_rate_deletion();
|
85 |
+
// form_action = jQuery('#cart_options').attr('action').split('#'); //split at the #
|
86 |
+
// form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
87 |
+
// jQuery('#cart_options').attr('action', form_action); // stick it all back in the action attribute
|
88 |
+
var current_tab = $tabs.data('selected.tabs');
|
89 |
+
if (current_tab == '3') {
|
90 |
+
form_action = jQuery('#shipping_options').attr('action').split('#'); //split at the #
|
91 |
+
form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
92 |
+
jQuery('#shipping_options').attr('action', form_action); // stick it all back in the action attribute
|
93 |
+
}
|
94 |
+
if (current_tab == '4') {
|
95 |
+
form_action = jQuery('#gateway_options_tbl').attr('action').split('#'); //split at the #
|
96 |
+
form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
97 |
+
jQuery('#gateway_options_tbl').attr('action', form_action); // stick it all back in the action attribute
|
98 |
+
}
|
99 |
+
if (current_tab == '5') {
|
100 |
+
form_action = jQuery('#chekcout_options_tbl').attr('action').split('#'); //split at the #
|
101 |
+
form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
102 |
+
jQuery('#chekcout_options_tbl').attr('action', form_action); // stick it all back in the action attribute
|
103 |
+
}
|
104 |
+
if (current_tab == '6') {
|
105 |
+
form_action = jQuery('#gold_cart_form').attr('action').split('#'); //split at the #
|
106 |
+
form_action = form_action[0]+"#"+ui.panel.id; // get the first item, add the hash then our current tab ID
|
107 |
+
jQuery('#gold_cart_form').attr('action', form_action); // stick it all back in the action attribute
|
108 |
+
}
|
109 |
+
|
110 |
+
});
|
111 |
+
});
|
112 |
+
});
|
113 |
+
|
114 |
+
|
115 |
+
function categorylist(url) {
|
116 |
+
self.location = url;
|
117 |
+
}
|
118 |
+
|
119 |
+
function submit_change_country() {
|
120 |
+
document.cart_options.submit();
|
121 |
+
//document.cart_options.submit();
|
122 |
+
}
|
123 |
+
|
124 |
+
var getresults=function(results) {
|
125 |
+
document.getElementById('formcontent').innerHTML = results;
|
126 |
+
jQuery('form.edititem').css('display', 'block');
|
127 |
+
jQuery('form.edititem').css('display', 'block');
|
128 |
+
jQuery('#additem').css('display', 'none');
|
129 |
+
jQuery('#productform').css('display', 'block');
|
130 |
+
jQuery("#loadingindicator_span").css('visibility','hidden');
|
131 |
+
enablebuttons();
|
132 |
+
|
133 |
+
jQuery("#gallery_list").sortable({
|
134 |
+
revert: false,
|
135 |
+
placeholder: "ui-selected",
|
136 |
+
start: function(e,ui) {
|
137 |
+
jQuery('#image_settings_box').hide();
|
138 |
+
jQuery('a.editButton').hide();
|
139 |
+
jQuery('img.deleteButton').hide();
|
140 |
+
jQuery('ul#gallery_list').children('li').removeClass('first');
|
141 |
+
},
|
142 |
+
stop:function (e,ui) {
|
143 |
+
jQuery('ul#gallery_list').children('li:first').addClass('first');
|
144 |
+
},
|
145 |
+
update: function (e,ui){
|
146 |
+
set = jQuery("#gallery_list").sortable('toArray');
|
147 |
+
img_id = jQuery('#gallery_image_'+set[0]).parent('li').attr('id');
|
148 |
+
|
149 |
+
jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
|
150 |
+
jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='" + WPSC_CORE_IMAGES_URL + "/pencil.png' alt='' /></a>");
|
151 |
+
jQuery('#gallery_image_'+set[0]).parent('li').attr('id', 0);
|
152 |
+
//for(i=1;i<set.length;i++) {
|
153 |
+
// jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
|
154 |
+
// jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "cross.png'/>");
|
155 |
+
//}
|
156 |
+
|
157 |
+
for(i=1;i<set.length;i++) {
|
158 |
+
jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
|
159 |
+
jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='" + WPSC_CORE_IMAGES_URL + "/cross.png'/>");
|
160 |
+
|
161 |
+
element_id = jQuery('#gallery_image_'+set[i]).parent('li').attr('id');
|
162 |
+
if(element_id == 0) {
|
163 |
+
jQuery('#gallery_image_'+set[i]).parent('li').attr('id', img_id);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
order = set.join(',');
|
168 |
+
prodid = jQuery('#prodid').val();
|
169 |
+
ajax.post("index.php",imageorderresults,"admin=true&ajax=true&prodid="+prodid+"&imageorder=true&order="+order);
|
170 |
+
},
|
171 |
+
'opacity':0.5
|
172 |
+
});
|
173 |
+
|
174 |
+
function imageorderresults(results) {
|
175 |
+
eval(results);
|
176 |
+
|
177 |
+
jQuery('#gallery_image_'+ser).append(output);
|
178 |
+
|
179 |
+
enablebuttons();
|
180 |
+
}
|
181 |
+
|
182 |
+
jQuery("div.previewimage").hover(
|
183 |
+
function () {
|
184 |
+
jQuery(this).children('img.deleteButton').show();
|
185 |
+
if(jQuery('#image_settings_box').css('display')!='block')
|
186 |
+
jQuery(this).children('a.editButton').show();
|
187 |
+
},
|
188 |
+
function () {
|
189 |
+
jQuery(this).children('img.deleteButton').hide();
|
190 |
+
jQuery(this).children('a.editButton').hide();
|
191 |
+
}
|
192 |
+
);
|
193 |
+
|
194 |
+
jQuery("a.closeimagesettings").click(
|
195 |
+
function (e) {
|
196 |
+
jQuery("div#image_settings_box").hide();
|
197 |
+
}
|
198 |
+
);
|
199 |
+
|
200 |
+
jQuery("#table_rate_price").click(
|
201 |
+
function() {
|
202 |
+
if (this.checked) {
|
203 |
+
jQuery("#table_rate").slideDown("fast");
|
204 |
+
} else {
|
205 |
+
jQuery("#table_rate").slideUp("fast");
|
206 |
+
}
|
207 |
+
}
|
208 |
+
);
|
209 |
+
|
210 |
+
jQuery(".add_level").click(
|
211 |
+
function() {
|
212 |
+
jQuery(this).parent().children('table').append('<tr><td><input type="text" size="10" value="" name="productmeta_values[table_rate_price][quantity][]"/> and above</td><td><input type="text" size="10" value="" name="productmeta_values[table_rate_price][table_price][]"/></td><td><img src="' + WPSC_CORE_IMAGES_URL + '/cross.png" class="remove_line"></td></tr>');
|
213 |
+
}
|
214 |
+
);
|
215 |
+
|
216 |
+
|
217 |
+
jQuery("#add_label").click(
|
218 |
+
function(){
|
219 |
+
jQuery("#labels").append("<br><table><tr><td>"+TXT_WPSC_LABEL+" :</td><td><input type='text' name='productmeta_values[labels][]'></td></tr><tr><td>"+TXT_WPSC_LIFE_NUMBER+" :</td><td><input type='text' name='productmeta_values[life_number][]'></td></tr><tr><td>"+TXT_WPSC_ITEM_NUMBER+" :</td><td><input type='text' name='productmeta_values[item_number][]'></td></tr><tr><td>"+TXT_WPSC_PRODUCT_CODE+" :</td><td><input type='text' name='productmeta_values[product_code][]'></td></tr><tr><td>"+TXT_WPSC_PDF+" :</td><td><input type='file' name='productmeta_values[product_pdf][]'></td></tr></table>");
|
220 |
+
}
|
221 |
+
);
|
222 |
+
|
223 |
+
jQuery(".remove_line").click(
|
224 |
+
function() {
|
225 |
+
jQuery(this).parent().parent('tr').remove();
|
226 |
+
}
|
227 |
+
);
|
228 |
+
|
229 |
+
jQuery("div.admin_product_name a.shorttag_toggle").toggle(
|
230 |
+
function () {
|
231 |
+
jQuery("div.admin_product_shorttags", jQuery(this).parent("div.admin_product_name")).css('display', 'block');
|
232 |
+
},
|
233 |
+
function () {
|
234 |
+
//jQuery("div#admin_product_name a.shorttag_toggle").toggleClass('toggled');
|
235 |
+
jQuery("div.admin_product_shorttags", jQuery(this).parent("div.admin_product_name")).css('display', 'none');
|
236 |
+
}
|
237 |
+
);
|
238 |
+
jQuery(".file_delete_button").click(
|
239 |
+
function() {
|
240 |
+
jQuery(this).parent().remove();
|
241 |
+
file_hash = jQuery(this).siblings("input").val();
|
242 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&del_file=true&del_file_hash="+file_hash);
|
243 |
+
}
|
244 |
+
);
|
245 |
+
boxes = ["price_and_stock", "shipping", "variation", "advanced", "product_image", "product_download"];
|
246 |
+
for (i=0;i<boxes.length;i++) {
|
247 |
+
if ( ! jQuery('#'+boxes[i]+'-hide').is(':checked')){
|
248 |
+
if (IS_WP27) {
|
249 |
+
jQuery('#'+boxes[i]).hide();
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
function filleditform(prodid) {
|
256 |
+
jQuery(document).ready(function(){
|
257 |
+
ajax.post("index.php",getresults,"ajax=true&admin=true&prodid="+prodid);
|
258 |
+
jQuery('.loadingimage').attr('src', jQuery(".loadingimage").attr('src'));
|
259 |
+
jQuery('#loadingindicator_span').css('visibility','visible');
|
260 |
+
});
|
261 |
+
}
|
262 |
+
|
263 |
+
function fillvariationform(variation_id) {
|
264 |
+
ajax.post("index.php",getresults,"ajax=true&admin=true&variation_id="+variation_id);
|
265 |
+
jQuery('.loadingimage').attr('src', WPSC_CORE_IMAGES_URL + 'indicator.gif');
|
266 |
+
jQuery('#loadingindicator_span').css('visibility','visible');
|
267 |
+
}
|
268 |
+
|
269 |
+
function showaddform() {
|
270 |
+
document.getElementById('productform').style.display = 'none';
|
271 |
+
document.getElementById('additem').style.display = 'block';
|
272 |
+
return false;
|
273 |
+
}
|
274 |
+
|
275 |
+
function showadd_categorisation_form() {
|
276 |
+
if(jQuery('div#add_categorisation').css('display') != 'block') {
|
277 |
+
jQuery('div#add_categorisation').css('display', 'block');
|
278 |
+
jQuery('div#edit_categorisation').css('display', 'none');
|
279 |
+
} else {
|
280 |
+
jQuery('div#add_categorisation').css('display', 'none');
|
281 |
+
}
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
|
285 |
+
|
286 |
+
function showedit_categorisation_form() {
|
287 |
+
if(jQuery('div#edit_categorisation').css('display') != 'block') {
|
288 |
+
jQuery('div#edit_categorisation').css('display', 'block');
|
289 |
+
jQuery('div#add_categorisation').css('display', 'none');
|
290 |
+
} else {
|
291 |
+
jQuery('div#edit_categorisation').css('display', 'none');
|
292 |
+
}
|
293 |
+
return false;
|
294 |
+
}
|
295 |
+
|
296 |
+
function fillcategoryform(catid) {
|
297 |
+
ajax.post("index.php",getresults,"ajax=true&admin=true&catid="+catid);
|
298 |
+
}
|
299 |
+
|
300 |
+
function fillbrandform(catid) {
|
301 |
+
ajax.post("index.php",getresults,"ajax=true&admin=true&brandid="+catid);
|
302 |
+
}
|
303 |
+
|
304 |
+
var gercurrency=function(results) {
|
305 |
+
document.getElementById('cslchar1').innerHTML = results;
|
306 |
+
document.getElementById('cslchar2').innerHTML = results;
|
307 |
+
document.getElementById('cslchar3').innerHTML = results;
|
308 |
+
document.getElementById('cslchar4').innerHTML = results;
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
|
313 |
+
function country_list(id) {
|
314 |
+
var country_list=function(results) {
|
315 |
+
document.getElementById('options_region').innerHTML = results;
|
316 |
+
}
|
317 |
+
ajax.post("index.php",country_list,"ajax=true&get_country_tax=true&country_id="+id);
|
318 |
+
}
|
319 |
+
|
320 |
+
function hideelement(id) {
|
321 |
+
state = document.getElementById(id).style.display;
|
322 |
+
//alert(document.getElementById(id).style.display);
|
323 |
+
if(state != 'block') {
|
324 |
+
document.getElementById(id).style.display = 'block';
|
325 |
+
} else {
|
326 |
+
document.getElementById(id).style.display = 'none';
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
function update_preview_url(prodid) {
|
331 |
+
image_height = document.getElementById("image_height").value;
|
332 |
+
image_width = document.getElementById("image_width").value;
|
333 |
+
if(((image_height > 0) && (image_height <= 1024)) && ((image_width > 0) && (image_width <= 1024))) {
|
334 |
+
new_url = "index.php?productid="+prodid+"&height="+image_height+"&width="+image_width+"";
|
335 |
+
document.getElementById("preview_link").setAttribute('href',new_url);
|
336 |
+
} else {
|
337 |
+
new_url = "index.php?productid="+prodid+"";
|
338 |
+
document.getElementById("preview_link").setAttribute('href',new_url);
|
339 |
+
}
|
340 |
+
return false;
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
function add_variation_value(value_type) {
|
345 |
+
container_id = value_type+"_variation_values";
|
346 |
+
//alert(container_id);
|
347 |
+
last_element_id = document.getElementById(container_id).lastChild.id;
|
348 |
+
// last_element_id = last_element_id.split("_");
|
349 |
+
// last_element_id = last_element_id.reverse();
|
350 |
+
date = new Date;
|
351 |
+
new_element_id = "variation_value_"+date.getTime();
|
352 |
+
|
353 |
+
|
354 |
+
old_elements = document.getElementById(container_id).innerHTML;
|
355 |
+
new_element_contents = "";
|
356 |
+
if(value_type == "edit") {
|
357 |
+
new_element_contents += "<input type='text' class='text' name='new_variation_values[]' value='' />";
|
358 |
+
} else {
|
359 |
+
new_element_contents += "<input type='text' class='text' name='variation_values[]' value='' />";
|
360 |
+
}
|
361 |
+
new_element_contents += " <a class='image_link' href='#' onclick='remove_variation_value_field(\""+new_element_id+"\")'><img src='" + WPSC_CORE_IMAGES_URL + "trash.gif' alt='"+TXT_WPSC_DELETE+"' title='"+TXT_WPSC_DELETE+"' /></a><br />";
|
362 |
+
//new_element_contents += "</span>";
|
363 |
+
|
364 |
+
new_element = document.createElement('span');
|
365 |
+
new_element.id = new_element_id;
|
366 |
+
|
367 |
+
document.getElementById(container_id).appendChild(new_element);
|
368 |
+
document.getElementById(new_element_id).innerHTML = new_element_contents;
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
|
372 |
+
function remove_variation_value(element,variation_value) {
|
373 |
+
var delete_variation_value=function(results)
|
374 |
+
{
|
375 |
+
}
|
376 |
+
|
377 |
+
element_count = jQuery("div#edit_variation_values span").size();
|
378 |
+
if(element_count > 1) {
|
379 |
+
ajax.post("index.php",delete_variation_value,"admin=true&ajax=true&remove_variation_value=true&variation_value_id="+variation_value);
|
380 |
+
jQuery(element).parent("span.variation_value").remove();
|
381 |
+
}
|
382 |
+
return false;
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
|
387 |
+
|
388 |
+
function checkimageresize() {
|
389 |
+
document.getElementById('image_resize2').checked = true;
|
390 |
+
}
|
391 |
+
|
392 |
+
function submit_status_form(id) {
|
393 |
+
document.getElementById(id).submit();
|
394 |
+
}
|
395 |
+
|
396 |
+
// pe.{
|
397 |
+
var prevElement = null;
|
398 |
+
var prevOption = null;
|
399 |
+
|
400 |
+
function hideOptionElement(id, option) {
|
401 |
+
if (prevOption == option) {
|
402 |
+
return;
|
403 |
+
}
|
404 |
+
if (prevElement != null) {
|
405 |
+
prevElement.style.display = "none";
|
406 |
+
}
|
407 |
+
|
408 |
+
if (id == null) {
|
409 |
+
prevElement = null;
|
410 |
+
} else {
|
411 |
+
prevElement = document.getElementById(id);
|
412 |
+
jQuery('#'+id).css( 'display','block');
|
413 |
+
}
|
414 |
+
prevOption = option;
|
415 |
+
}
|
416 |
+
|
417 |
+
|
418 |
+
// }.pe
|
419 |
+
|
420 |
+
function toggle_display_options(state) {
|
421 |
+
switch(state) {
|
422 |
+
case 'list':
|
423 |
+
document.getElementById('grid_view_options').style.display = 'none';
|
424 |
+
document.getElementById('list_view_options').style.display = 'block';
|
425 |
+
break;
|
426 |
+
|
427 |
+
case 'grid':
|
428 |
+
document.getElementById('list_view_options').style.display = 'none';
|
429 |
+
document.getElementById('grid_view_options').style.display = 'block';
|
430 |
+
break;
|
431 |
+
|
432 |
+
default:
|
433 |
+
document.getElementById('list_view_options').style.display = 'none';
|
434 |
+
document.getElementById('grid_view_options').style.display = 'none';
|
435 |
+
break;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
function log_submitform(id) {
|
440 |
+
value1 = document.getElementById(id);
|
441 |
+
if (ajax.serialize(value1).search(/value=3/)!=-1) {
|
442 |
+
document.getElementById("track_id_"+id).style.display="block";
|
443 |
+
} else {
|
444 |
+
document.getElementById("track_id_"+id).style.display="none";
|
445 |
+
}
|
446 |
+
var get_log_results=function(results) {
|
447 |
+
eval(results);
|
448 |
+
}
|
449 |
+
frm = document.getElementById(id);
|
450 |
+
ajax.post("index.php?admin=true&ajax=true&log_state=true",get_log_results,ajax.serialize(frm));
|
451 |
+
return false;
|
452 |
+
}
|
453 |
+
|
454 |
+
function save_tracking_id(id) {
|
455 |
+
value1 = document.getElementById('tracking_id_'+id).value;
|
456 |
+
value1 ="id="+id +"&value="+value1;
|
457 |
+
ajax.post("index.php?admin=true&ajax=true&save_tracking_id=true",noresults,value1);
|
458 |
+
return false;
|
459 |
+
}
|
460 |
+
|
461 |
+
var select_min_height = 75;
|
462 |
+
var select_max_height = 50;
|
463 |
+
/*
|
464 |
+
//ToolTip JavaScript
|
465 |
+
jQuery('img').Tooltip(
|
466 |
+
{
|
467 |
+
className: 'inputsTooltip',
|
468 |
+
position: 'mouse',
|
469 |
+
delay: 200
|
470 |
+
}
|
471 |
+
);
|
472 |
+
*/
|
473 |
+
jQuery(window).load( function () {
|
474 |
+
|
475 |
+
jQuery('a.closeEl').bind('click', toggleContent);
|
476 |
+
/*
|
477 |
+
jQuery('div.groupWrapper').sortable( {
|
478 |
+
accept: 'groupItem',
|
479 |
+
helperclass: 'sortHelper',
|
480 |
+
activeclass : 'sortableactive',
|
481 |
+
hoverclass : 'sortablehover',
|
482 |
+
handle: 'div.itemHeader',
|
483 |
+
tolerance: 'pointer',
|
484 |
+
onStart : function() {
|
485 |
+
jQuery.iAutoscroller.start(this, document.getElementsByTagName('body'));
|
486 |
+
},
|
487 |
+
onStop : function() {
|
488 |
+
jQuery.iAutoscroller.stop();
|
489 |
+
},
|
490 |
+
update : function(e,ui) {
|
491 |
+
serial = jQuery('div.groupWrapper').sortable('toArray');
|
492 |
+
category_id = jQuery("input#item_list_category_id").val();
|
493 |
+
|
494 |
+
ajax.post("index.php", noresults, "admin=true&ajax=true&changeorder=true&category_id="+category_id+"&sort1="+serial);
|
495 |
+
}
|
496 |
+
}
|
497 |
+
);
|
498 |
+
*/
|
499 |
+
|
500 |
+
jQuery('a#close_news_box').click( function () {
|
501 |
+
jQuery('div.wpsc_news').css( 'display', 'none' );
|
502 |
+
ajax.post("index.php", noresults, "ajax=true&admin=true&hide_ecom_dashboard=true");
|
503 |
+
return false;
|
504 |
+
});
|
505 |
+
});
|
506 |
+
var toggleContent = function(e)
|
507 |
+
{
|
508 |
+
var targetContent = jQuery('div.itemContent', this.parentNode.parentNode);
|
509 |
+
if (targetContent.css('display') == 'none') {
|
510 |
+
targetContent.slideDown(300);
|
511 |
+
jQuery(this).html('[-]');
|
512 |
+
} else {
|
513 |
+
targetContent.slideUp(300);
|
514 |
+
jQuery(this).html('[+]');
|
515 |
+
}
|
516 |
+
return false;
|
517 |
+
};
|
518 |
+
|
519 |
+
|
520 |
+
function hideelement1(id, item_value)
|
521 |
+
{
|
522 |
+
//alert(value);
|
523 |
+
if(item_value == 5) {
|
524 |
+
jQuery(document.getElementById(id)).css('display', 'block');
|
525 |
+
} else {
|
526 |
+
jQuery(document.getElementById(id)).css('display', 'none');
|
527 |
+
}
|
528 |
+
}
|
529 |
+
|
530 |
+
|
531 |
+
function suspendsubs(user_id)
|
532 |
+
{
|
533 |
+
var comm =jQuery("#suspend_subs"+user_id).attr("checked");
|
534 |
+
//alert(comm);
|
535 |
+
if (comm == true){
|
536 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&log_state=true&suspend=true&value=1&id="+user_id);
|
537 |
+
} else {
|
538 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&log_state=true&suspend=true&value=2&id="+user_id);
|
539 |
+
}
|
540 |
+
return false;
|
541 |
+
}
|
542 |
+
|
543 |
+
function delete_extra_preview(preview_name, prodid) {
|
544 |
+
var preview_name_results=function(results) {
|
545 |
+
filleditform(prodid);
|
546 |
+
}
|
547 |
+
ajax.post("index.php",preview_name_results,"ajax=true&admin=true&prodid="+prodid+"&preview_name="+preview_name);
|
548 |
+
}
|
549 |
+
|
550 |
+
function shipwire_sync() {
|
551 |
+
ajax.post("index.php",noresults,"ajax=true&shipwire_sync=ture");
|
552 |
+
}
|
553 |
+
|
554 |
+
function shipwire_tracking() {
|
555 |
+
ajax.post("index.php",noresults,"ajax=true&shipwire_tracking=ture");
|
556 |
+
}
|
557 |
+
|
558 |
+
function display_settings_button() {
|
559 |
+
jQuery("#settings_button").slideToggle(200);
|
560 |
+
//document.getElementById("settings_button").style.display='block';
|
561 |
+
}
|
562 |
+
|
563 |
+
function submittogoogle(id){
|
564 |
+
value1=document.getElementById("google_command_list_"+id).value;
|
565 |
+
value2=document.getElementById("partial_amount_"+id).value;
|
566 |
+
reason=document.getElementById("cancel_reason_"+id).value;
|
567 |
+
comment=document.getElementById("cancel_comment_"+id).value;
|
568 |
+
message=document.getElementById("message_to_buyer_message_"+id).value;
|
569 |
+
document.getElementById("google_command_indicator").style.display='inline';
|
570 |
+
ajax.post("index.php",submittogoogleresults,"ajax=true&submittogoogle=true&message="+message+"&value="+value1+"&amount="+value2+"&comment="+comment+"&reason="+reason+"&id="+id);
|
571 |
+
return true;
|
572 |
+
}
|
573 |
+
|
574 |
+
var submittogoogleresults=function (results) {
|
575 |
+
window.location.reload(true);
|
576 |
+
}
|
577 |
+
|
578 |
+
function display_partial_box(id){
|
579 |
+
value1=document.getElementById("google_command_list_"+id).value;
|
580 |
+
if ((value1=='Refund') || (value1=='Charge')){
|
581 |
+
document.getElementById("google_partial_radio_"+id).style.display='inline';
|
582 |
+
if (value1=='Refund'){
|
583 |
+
document.getElementById("google_cancel_"+id).style.display='block';
|
584 |
+
document.getElementById("cancel_reason_"+id).style.display='inline';
|
585 |
+
document.getElementById("cancel_div_comment_"+id).style.display='none';
|
586 |
+
}
|
587 |
+
}else if ((value1=='Cancel')||(value1=='Refund')) {
|
588 |
+
document.getElementById("google_cancel_"+id).style.display='block';
|
589 |
+
document.getElementById("cancel_reason_"+id).style.display='inline';
|
590 |
+
}else if (value1=='Send Message') {
|
591 |
+
document.getElementById("message_to_buyer_"+id).style.display='block';
|
592 |
+
} else {
|
593 |
+
document.getElementById("cancel_div_comment_"+id).style.display='none';
|
594 |
+
document.getElementById("google_cancel_"+id).style.display='none';
|
595 |
+
document.getElementById("cancel_reason_"+id).style.display='none';
|
596 |
+
document.getElementById("message_to_buyer_"+id).style.display='none';
|
597 |
+
document.getElementById("google_partial_radio_"+id).style.display='none';
|
598 |
+
document.getElementById("partial_amount_"+id).style.display='none';
|
599 |
+
}
|
600 |
+
}
|
601 |
+
|
602 |
+
function add_more_meta(e) {
|
603 |
+
current_meta_forms = jQuery(e).parent().children("div.product_custom_meta:last"); // grab the form container
|
604 |
+
new_meta_forms = current_meta_forms.clone(true); // clone the form container
|
605 |
+
jQuery("label input", new_meta_forms).val(''); // reset all contained forms to empty
|
606 |
+
current_meta_forms.after(new_meta_forms); // append it after the container of the clicked element
|
607 |
+
return false;
|
608 |
+
}
|
609 |
+
|
610 |
+
function remove_meta(e, meta_id) {
|
611 |
+
current_meta_form = jQuery(e).parent("div.product_custom_meta"); // grab the form container
|
612 |
+
//meta_name = jQuery("input#custom_meta_name_"+meta_id, current_meta_form).val();
|
613 |
+
//meta_value = jQuery("input#custom_meta_value_"+meta_id, current_meta_form).val();
|
614 |
+
returned_value = jQuery.ajax({
|
615 |
+
type: "POST",
|
616 |
+
url: "admin.php?ajax=true",
|
617 |
+
data: "admin=true&remove_meta=true&meta_id="+meta_id+"",
|
618 |
+
success: function(results) {
|
619 |
+
if(results > 0) {
|
620 |
+
jQuery("div#custom_meta_"+meta_id).remove();
|
621 |
+
}
|
622 |
+
}
|
623 |
+
});
|
624 |
+
return false;
|
625 |
+
}
|
626 |
+
|
627 |
+
|
628 |
+
function wpsc_save_postboxes_state(page, container) {
|
629 |
+
var closed = jQuery(container+' .postbox').filter('.closed').map(function() {
|
630 |
+
return this.id;
|
631 |
+
}).get().join(',');
|
632 |
+
jQuery.post(postboxL10n.requestFile, {
|
633 |
+
action: 'closed-postboxes',
|
634 |
+
closed: closed,
|
635 |
+
closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
|
636 |
+
page: page
|
637 |
+
});
|
638 |
+
}
|
639 |
+
|
640 |
+
jQuery(document).ready(function(){
|
641 |
+
|
642 |
+
jQuery('.deleteproducts > button').click(
|
643 |
+
function () {
|
644 |
+
var ids='0';
|
645 |
+
jQuery('.deletecheckbox:checked').each(
|
646 |
+
function () {
|
647 |
+
ids += ","+jQuery(this).val();
|
648 |
+
}
|
649 |
+
);
|
650 |
+
var r=confirm("Please confirm deletion");
|
651 |
+
if (r==true) {
|
652 |
+
ajax.post("index.php",reloadresults,"admin=true&ajax=true&del_prod=true&del_prod_id="+ids);
|
653 |
+
}
|
654 |
+
}
|
655 |
+
);
|
656 |
+
jQuery('#selectall').click(
|
657 |
+
function () {
|
658 |
+
if (this.checked) {
|
659 |
+
jQuery('.deletecheckbox').each(function(){
|
660 |
+
this.checked = true;
|
661 |
+
});
|
662 |
+
} else {
|
663 |
+
jQuery('.deletecheckbox').each(function(){
|
664 |
+
this.checked = false;
|
665 |
+
});
|
666 |
+
}
|
667 |
+
}
|
668 |
+
);
|
669 |
+
|
670 |
+
if (typeof jQuery('.pickdate').datepicker != "undefined") {
|
671 |
+
jQuery('.pickdate').datepicker({
|
672 |
+
dateFormat: 'yy-mm-dd'
|
673 |
+
});
|
674 |
+
}
|
675 |
+
filesizeLimit = 5120000;
|
676 |
+
|
677 |
+
// alert('test 1');
|
678 |
+
if (typeof SWFUpload != "undefined") {
|
679 |
+
var swfu = new SWFUpload({
|
680 |
+
flash_url : WPSC_CORE_JS_URL + '/swfupload.swf',
|
681 |
+
upload_url: base_url+'/?action=wpsc_add_image',
|
682 |
+
button_placeholder_id : "spanButtonPlaceholder",
|
683 |
+
button_width: 103,
|
684 |
+
button_height: 24,
|
685 |
+
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
|
686 |
+
button_cursor: SWFUpload.CURSOR.HAND,
|
687 |
+
post_params: {
|
688 |
+
"prodid" : 0
|
689 |
+
},
|
690 |
+
file_queue_limit : 1,
|
691 |
+
file_size_limit : filesizeLimit+'b',
|
692 |
+
file_types : "*.jpg;*.jpeg;*.png;*.gif;*.JPG;*.JPEG;*.PNG;*.GIF",
|
693 |
+
file_types_description : "Web-compatible Image Files",
|
694 |
+
file_upload_limit : filesizeLimit,
|
695 |
+
custom_settings : {
|
696 |
+
targetHolder : false,
|
697 |
+
progressBar : false,
|
698 |
+
sorting : false
|
699 |
+
},
|
700 |
+
debug: false,
|
701 |
+
|
702 |
+
file_queued_handler : imageFileQueued,
|
703 |
+
file_queue_error_handler : imageFileQueueError,
|
704 |
+
file_dialog_complete_handler : imageFileDialogComplete,
|
705 |
+
upload_start_handler : startImageUpload,
|
706 |
+
upload_progress_handler : imageUploadProgress,
|
707 |
+
upload_error_handler : imageUploadError,
|
708 |
+
upload_success_handler : imageUploadSuccess,
|
709 |
+
upload_complete_handler : imageUploadComplete,
|
710 |
+
queue_complete_handler : imageQueueComplete
|
711 |
+
});
|
712 |
+
}
|
713 |
+
jQuery("#add-product-image").click(function(){
|
714 |
+
swfu.selectFiles();
|
715 |
+
});
|
716 |
+
});
|
717 |
+
|
718 |
+
function addlayer(){
|
719 |
+
jQuery("tr.addlayer").before("<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>");
|
720 |
+
bind_shipping_rate_deletion();
|
721 |
+
}
|
722 |
+
|
723 |
+
function addweightlayer(){
|
724 |
+
jQuery("tr.addlayer").before("<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>");
|
725 |
+
bind_shipping_rate_deletion();
|
726 |
+
}
|
727 |
+
|
728 |
+
function removelayer() {
|
729 |
+
this.parent.parent.innerHTML='';
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* SWFUpload Image Uploading events
|
734 |
+
**/
|
735 |
+
|
736 |
+
function imageFileQueued (file) {
|
737 |
+
|
738 |
+
}
|
739 |
+
|
740 |
+
function imageFileQueueError (file, error, message) {
|
741 |
+
if (error == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
|
742 |
+
alert("You selected too many files to upload at one time. " + (message === 0 ? "You have reached the upload limit." : "You may upload " + (message > 1 ? "up to " + message + " files." : "only one file.")));
|
743 |
+
return;
|
744 |
+
}
|
745 |
+
|
746 |
+
}
|
747 |
+
|
748 |
+
function imageFileDialogComplete (selected, queued) {
|
749 |
+
try {
|
750 |
+
this.startUpload();
|
751 |
+
} catch (ex) {
|
752 |
+
this.debug(ex);
|
753 |
+
}
|
754 |
+
}
|
755 |
+
|
756 |
+
function startImageUpload (file) {
|
757 |
+
// alert('start '+jQuery("div#swfupload_img_indicator").css('display'));
|
758 |
+
jQuery("div#swfupload_img_indicator").css('display', 'block');
|
759 |
+
var cell = jQuery('<li></li>').appendTo(jQuery('#gallery_list'));
|
760 |
+
var sorting = jQuery('<input type="hidden" name="images[]" value="" />').appendTo(cell);
|
761 |
+
var progress = jQuery('<div class="progress"></div>').appendTo(cell);
|
762 |
+
var bar = jQuery('<div class="bar"></div>').appendTo(progress);
|
763 |
+
var art = jQuery('<div class="gloss"></div>').appendTo(progress);
|
764 |
+
this.targetHolder = cell;
|
765 |
+
this.progressBar = bar;
|
766 |
+
this.sorting = sorting;
|
767 |
+
return true;
|
768 |
+
}
|
769 |
+
|
770 |
+
function imageUploadProgress (file, loaded, total) {
|
771 |
+
var progress = Math.ceil((loaded/total)*76);
|
772 |
+
jQuery(this.progressBar).animate({
|
773 |
+
'width':progress+'px'
|
774 |
+
},100);
|
775 |
+
}
|
776 |
+
|
777 |
+
function imageUploadError (file, error, message) {
|
778 |
+
console.log(error+": "+message);
|
779 |
+
}
|
780 |
+
|
781 |
+
function imageUploadSuccess (file, results) {
|
782 |
+
//Don't delete, initiate id is neccesary.
|
783 |
+
var id = null;
|
784 |
+
var pid = null;
|
785 |
+
|
786 |
+
jQuery("span.swfupload_loadingindicator").css('visibility', 'hidden');
|
787 |
+
eval(results);
|
788 |
+
// jQuery(this).css('border', '1px solid red');
|
789 |
+
if(pid >= 1) {
|
790 |
+
context = jQuery("div#productform");
|
791 |
+
} else {
|
792 |
+
context = jQuery("div#additem");
|
793 |
+
}
|
794 |
+
|
795 |
+
if (id == null ) {
|
796 |
+
if(replacement_src != null) {
|
797 |
+
jQuery("li.first div.previewimage a.thickbox", context).attr('href', replacement_src);
|
798 |
+
jQuery("li.first div.previewimage a.thickbox img.previewimage", context).attr('src', replacement_src);
|
799 |
+
} else {
|
800 |
+
if (jQuery('#gold_present', context).val() != '1') {
|
801 |
+
jQuery('#add-product-image', context).remove();
|
802 |
+
}
|
803 |
+
jQuery(this.sorting).attr({
|
804 |
+
'value':src
|
805 |
+
});
|
806 |
+
var img = jQuery('<div class="previewimage" id="'+id+'"><a href="'+WPSC_IMAGE_URL+src+'" rel="product_extra_image_'+id+'" class="thickbox"><img src="'+WPSC_IMAGE_URL+src+'" width="60" height="60" class="previewimage" /></a></div>').appendTo(this.targetHolder).hide();
|
807 |
+
set = jQuery("#gallery_list", context).sortable('toArray');
|
808 |
+
|
809 |
+
jQuery('#gallery_image_0', context).append("<a class='editButton'>Edit <img src='" + WPSC_IMAGE_URL + "pencil.png'/></a>");
|
810 |
+
jQuery('#gallery_image_0', context).parent('li').addClass('first');
|
811 |
+
jQuery('#gallery_image_0', context).parent('li').attr('id', 0);
|
812 |
+
jQuery('#gallery_image_0 img.deleteButton', context).remove();
|
813 |
+
enablebuttons();
|
814 |
+
}
|
815 |
+
} else {
|
816 |
+
//jQuery(this.targetHolder).attr({'id':'image-'+src});
|
817 |
+
jQuery(this.targetHolder).attr({
|
818 |
+
'id':id
|
819 |
+
});
|
820 |
+
div_id = 'gallery_image_'+id;
|
821 |
+
jQuery(this.targetHolder).html('');
|
822 |
+
var img = jQuery('<div class="previewimage" id="'+div_id+'"><input type="hidden" name="images[]" value="'+src+'"><a href="'+WPSC_IMAGE_URL+src+'" rel="product_extra_image_'+id+'" class="thickbox"><img src="'+WPSC_IMAGE_URL+src+'" width="60" height="60" class="previewimage" /></a></div>').appendTo(this.targetHolder).hide();
|
823 |
+
|
824 |
+
jQuery('#gallery_image_0', context).append("<a class='editButton'>Edit <img src='"+WPSC_CORE_IMAGES_URL+"/pencil.png'/></a>");
|
825 |
+
jQuery('#gallery_image_0', context).parent('li').addClass('first');
|
826 |
+
jQuery('#gallery_image_0', context).parent('li').attr('id', 0);
|
827 |
+
jQuery('#gallery_image_0 img.deleteButton', context).remove();
|
828 |
+
|
829 |
+
|
830 |
+
if (jQuery('#gallery_list li', context).size() > 1) {
|
831 |
+
jQuery('#gallery_list', context).sortable('refresh');
|
832 |
+
} else {
|
833 |
+
jQuery('#gallery_list', context).sortable();
|
834 |
+
}
|
835 |
+
set = jQuery("#gallery_list", context).sortable('toArray');
|
836 |
+
order = set.join(',');
|
837 |
+
prodid = jQuery('#prodid', context).val();
|
838 |
+
|
839 |
+
if(prodid == null) {
|
840 |
+
prodid = 0;
|
841 |
+
}
|
842 |
+
|
843 |
+
function imageorderresults(results) {
|
844 |
+
eval(results);
|
845 |
+
jQuery('#gallery_image_'+ser).append(output);
|
846 |
+
enablebuttons();
|
847 |
+
}
|
848 |
+
|
849 |
+
ajax.post("index.php",imageorderresults,"admin=true&ajax=true&prodid="+prodid+"&imageorder=true&order="+order+"");
|
850 |
+
|
851 |
+
|
852 |
+
enablebuttons();
|
853 |
+
|
854 |
+
}
|
855 |
+
jQuery(this.progressBar).animate({
|
856 |
+
'width':'76px'
|
857 |
+
},250,function () {
|
858 |
+
jQuery(this).parent().fadeOut(500,function() {
|
859 |
+
jQuery(this).remove();
|
860 |
+
jQuery(img).fadeIn('500');
|
861 |
+
jQuery(img).append('<img class="deleteButton" src="'+WPSC_CORE_IMAGES_URL+'/cross.png" alt="-" style="display: none;"/>');
|
862 |
+
enablebuttons()
|
863 |
+
//enableDeleteButton(deleteButton);
|
864 |
+
});
|
865 |
+
});
|
866 |
+
}
|
867 |
+
|
868 |
+
function imageUploadComplete (file) {
|
869 |
+
|
870 |
+
jQuery("div#swfupload_img_indicator").css('display', 'none');
|
871 |
+
if (jQuery('#gallery_list li').size() > 1)
|
872 |
+
jQuery('#gallery_list').sortable('refresh');
|
873 |
+
else
|
874 |
+
jQuery('#gallery_list').sortable();
|
875 |
+
}
|
876 |
+
|
877 |
+
function imageQueueComplete (uploads) {
|
878 |
+
|
879 |
+
}
|
880 |
+
|
881 |
+
function enablebuttons(){
|
882 |
+
jQuery("img.deleteButton").click(
|
883 |
+
function(){
|
884 |
+
var r=confirm("Please confirm deletion");
|
885 |
+
if (r==true) {
|
886 |
+
img_id = jQuery(this).parent().parent('li').attr('id');
|
887 |
+
jQuery(this).parent().parent('li').remove();
|
888 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&del_img=true&del_img_id="+img_id);
|
889 |
+
}
|
890 |
+
}
|
891 |
+
);
|
892 |
+
|
893 |
+
jQuery("a.delete_primary_image").click(
|
894 |
+
function(){
|
895 |
+
var r=confirm("Please confirm deletion");
|
896 |
+
if (r==true) {
|
897 |
+
img_id = jQuery(this).parents('li.first').attr('id');
|
898 |
+
//ajax.post("index.php",noresults,"ajax=true&del_img=true&del_img_id="+img_id);
|
899 |
+
jQuery(this).parents('li.first').remove();
|
900 |
+
|
901 |
+
|
902 |
+
|
903 |
+
set = jQuery("#gallery_list").sortable('toArray');
|
904 |
+
jQuery('#gallery_image_'+set[0]).children('img.deleteButton').remove();
|
905 |
+
jQuery('#gallery_image_'+set[0]).append("<a class='editButton'>Edit <img src='"+WPSC_CORE_IMAGES_URL+"/pencil.png'/></a>");
|
906 |
+
jQuery('#gallery_image_'+set[0]).parent('li').addClass('first');
|
907 |
+
jQuery('#gallery_image_'+set[0]).parent('li').attr('id', 0);
|
908 |
+
for(i=1;i<set.length;i++) {
|
909 |
+
jQuery('#gallery_image_'+set[i]).children('a.editButton').remove();
|
910 |
+
jQuery('#gallery_image_'+set[i]).append("<img alt='-' class='deleteButton' src='"+WPSC_CORE_IMAGES_URL+"/cross.png'/>");
|
911 |
+
|
912 |
+
if(element_id == 0) {
|
913 |
+
jQuery('#gallery_image_'+set[i]).parent('li').attr('id', img_id);
|
914 |
+
}
|
915 |
+
}
|
916 |
+
order = set.join(',');
|
917 |
+
prodid = jQuery('#prodid').val();
|
918 |
+
ajax.post("index.php",imageorderresults,"admin=true&ajax=true&prodid="+prodid+"&imageorder=true&order="+order+"&delete_primary=true");
|
919 |
+
|
920 |
+
jQuery(this).parents('li.first').attr('id', '0');
|
921 |
+
}
|
922 |
+
return false;
|
923 |
+
}
|
924 |
+
);
|
925 |
+
|
926 |
+
jQuery("div.previewimage").hover(
|
927 |
+
function () {
|
928 |
+
jQuery(this).children('img.deleteButton').show();
|
929 |
+
if(jQuery('#image_settings_box').css('display')!='block')
|
930 |
+
jQuery(this).children('a.editButton').show();
|
931 |
+
},
|
932 |
+
function () {
|
933 |
+
jQuery(this).children('img.deleteButton').hide();
|
934 |
+
jQuery(this).children('a.editButton').hide();
|
935 |
+
}
|
936 |
+
);
|
937 |
+
|
938 |
+
jQuery("a.editButton").click(
|
939 |
+
function(){
|
940 |
+
jQuery(this).hide();
|
941 |
+
jQuery('#image_settings_box').show('fast');
|
942 |
+
}
|
943 |
+
);
|
944 |
+
|
945 |
+
jQuery("a.closeimagesettings").click(
|
946 |
+
function (e) {
|
947 |
+
jQuery("div#image_settings_box").hide();
|
948 |
+
}
|
949 |
+
);
|
950 |
+
|
951 |
+
function imageorderresults(results) {
|
952 |
+
eval(results);
|
953 |
+
jQuery('#gallery_image_'+ser).append(output);
|
954 |
+
enablebuttons();
|
955 |
+
}
|
956 |
+
|
957 |
+
jQuery("input.limited_stock_checkbox").click( function () {
|
958 |
+
parent_form = jQuery(this).parents('form');
|
959 |
+
if(jQuery(this).is(':checked')) {
|
960 |
+
jQuery("div.edit_stock",parent_form).show();
|
961 |
+
jQuery("th.stock, td.stock", parent_form).show();
|
962 |
+
jQuery(".stock_limit_quantity", parent_form).show();
|
963 |
+
} else {
|
964 |
+
jQuery("div.edit_stock", parent_form).hide();
|
965 |
+
jQuery("th.stock, td.stock", parent_form).hide();
|
966 |
+
jQuery(".stock_limit_quantity", parent_form).hide();
|
967 |
+
}
|
968 |
+
});
|
969 |
+
}
|
970 |
+
|
971 |
+
function reloadresults(){
|
972 |
+
window.location = window.location.href;
|
973 |
+
}
|
974 |
+
|
975 |
+
jQuery(document).ready(function(){
|
976 |
+
jQuery(".wpsc-row-actions").parent().parent("tr").mouseover(
|
977 |
+
function() {
|
978 |
+
jQuery(this).children("td").children(".wpsc-row-actions").css("visibility", "visible");
|
979 |
+
}
|
980 |
+
).mouseout(
|
981 |
+
function() {
|
982 |
+
jQuery(this).children("td").children(".wpsc-row-actions").css("visibility", "hidden");
|
983 |
+
}
|
984 |
+
);
|
985 |
+
/*
|
986 |
+
jQuery(".wpsc-shipping-actions").hide();
|
987 |
+
jQuery("#wpsc_shipping_options").hover(
|
988 |
+
function() {
|
989 |
+
alert('hovering');
|
990 |
+
jQuery(this).children(".wpsc-shipping-actions").css("visibility", "visible");
|
991 |
+
}
|
992 |
+
);
|
993 |
+
*//*
|
994 |
+
.mouseout(
|
995 |
+
function() {
|
996 |
+
jQuery(this).children(".wpsc-shipping-actions").css("visibility", "hidden");
|
997 |
+
}
|
998 |
+
);
|
999 |
+
*/
|
1000 |
+
|
1001 |
+
jQuery("#table_rate_price").click(
|
1002 |
+
function() {
|
1003 |
+
if (this.checked) {
|
1004 |
+
jQuery("#table_rate").slideDown("fast");
|
1005 |
+
} else {
|
1006 |
+
jQuery("#table_rate").slideUp("fast");
|
1007 |
+
}
|
1008 |
+
}
|
1009 |
+
);
|
1010 |
+
jQuery("#add_label").click(
|
1011 |
+
function(){
|
1012 |
+
jQuery("#labels").append("<br><table><tr><td>"+TXT_WPSC_LABEL+" :</td><td><input type='text' name='productmeta_values[labels][]'></td></tr><tr><td>"+TXT_WPSC_LABEL_DESC+" :</td><td><textarea name='productmeta_values[labels_desc][]'></textarea></td></tr><tr><td>"+TXT_WPSC_LIFE_NUMBER+" :</td><td><input type='text' name='productmeta_values[life_number][]'></td></tr><tr><td>"+TXT_WPSC_ITEM_NUMBER+" :</td><td><input type='text' name='productmeta_values[item_number][]'></td></tr><tr><td>"+TXT_WPSC_PRODUCT_CODE+" :</td><td><input type='text' name='productmeta_values[product_code][]'></td></tr><tr><td>"+TXT_WPSC_PDF+" :</td><td><input type='file' name='productmeta_values[product_pdf][]'></td></tr></table>");
|
1013 |
+
}
|
1014 |
+
);
|
1015 |
+
jQuery(".add_level").click(
|
1016 |
+
function() {
|
1017 |
+
added = jQuery(this).parent().children('table').append('<tr><td><input type="text" size="10" value="" name="productmeta_values[table_rate_price][quantity][]"/> and above</td><td><input type="text" size="10" value="" name="productmeta_values[table_rate_price][table_price][]"/></td></tr>');
|
1018 |
+
}
|
1019 |
+
);
|
1020 |
+
|
1021 |
+
jQuery(".file_delete_button").click(
|
1022 |
+
function() {
|
1023 |
+
jQuery(this).parent().remove();
|
1024 |
+
file_hash = jQuery(this).siblings("input").val();
|
1025 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&del_file=true&del_file_hash="+file_hash);
|
1026 |
+
}
|
1027 |
+
);
|
1028 |
+
|
1029 |
+
jQuery("table#itemlist .pricedisplay").each(
|
1030 |
+
function () {
|
1031 |
+
jQuery(this).attr("id",jQuery(this).parent().attr('id'));
|
1032 |
+
}
|
1033 |
+
);
|
1034 |
+
|
1035 |
+
jQuery("#submit_category_select").click(
|
1036 |
+
function() {
|
1037 |
+
new_url = jQuery("#category_select").children("option:selected").val();
|
1038 |
+
window.location = new_url;
|
1039 |
+
}
|
1040 |
+
);
|
1041 |
+
});
|
1042 |
+
|
1043 |
+
|
1044 |
+
|
1045 |
+
function wpsc_upload_switcher(target_state) {
|
1046 |
+
switch(target_state) {
|
1047 |
+
case 'flash':
|
1048 |
+
jQuery("table.browser-image-uploader").css("display","none");
|
1049 |
+
jQuery("table.flash-image-uploader").css("display","block");
|
1050 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&save_image_upload_state=true&image_upload_state=1");
|
1051 |
+
break;
|
1052 |
+
|
1053 |
+
case 'browser':
|
1054 |
+
jQuery("table.flash-image-uploader").css("display","none");
|
1055 |
+
jQuery("table.browser-image-uploader").css("display","block");
|
1056 |
+
ajax.post("index.php",noresults,"admin=true&ajax=true&save_image_upload_state=true&image_upload_state=0");
|
1057 |
+
break;
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
|
1062 |
+
|
1063 |
+
function open_variation_settings(element_id) {
|
1064 |
+
jQuery("tr#"+element_id+" td div.variation_settings").toggle();
|
1065 |
+
return false;
|
1066 |
+
}
|
trunk/wpsc-admin/js/admin.js
ADDED
@@ -0,0 +1,669 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*global ajaxurl, WPSC_Term_List_Levels, validateForm, tb_remove, alert, setUserSetting, wpsc_adminL10n, typenow, adminpage */
|
2 |
+
(function($){
|
3 |
+
/**
|
4 |
+
* Wrapper for $.post. Takes care of the 'wpsc_action' and 'action' data arguments.
|
5 |
+
*
|
6 |
+
* @since 3.8.9
|
7 |
+
* @param {object} data Data to pass to the AJAX destination
|
8 |
+
* @param {function} handler Response handler
|
9 |
+
*/
|
10 |
+
$.wpsc_post = function(data, handler) {
|
11 |
+
data.wpsc_action = data.action;
|
12 |
+
data.action = 'wpsc_ajax';
|
13 |
+
|
14 |
+
return $.post( ajaxurl, data, handler, 'json' );
|
15 |
+
};
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Wrapper for $.get. Takes care of the 'wpsc_action' and 'action' data arguments.
|
19 |
+
*
|
20 |
+
* @since 3.8.9
|
21 |
+
* @param {object} data Data to pass to the AJAX destination
|
22 |
+
* @param {function} handler Response handler
|
23 |
+
*/
|
24 |
+
$.wpsc_get = function(data, handler) {
|
25 |
+
data.wpsc_action = data.action;
|
26 |
+
data.action = 'wpsc_ajax';
|
27 |
+
|
28 |
+
return $.get( ajaxurl, data, handler, 'json' );
|
29 |
+
};
|
30 |
+
|
31 |
+
var pagenow = pagenow || '';
|
32 |
+
|
33 |
+
function category_sort(){
|
34 |
+
var order = $(this).sortable('toArray'),
|
35 |
+
data = {
|
36 |
+
action: 'category_sort_order',
|
37 |
+
sort_order: order,
|
38 |
+
parent_id: 0
|
39 |
+
};
|
40 |
+
|
41 |
+
jQuery.post( ajaxurl, data );
|
42 |
+
}
|
43 |
+
|
44 |
+
var submit_handlers = [];
|
45 |
+
|
46 |
+
var disable_ajax_submit = function() {
|
47 |
+
var t = $('#submit');
|
48 |
+
|
49 |
+
if ( t.data( 'events' ) ) {
|
50 |
+
submit_handlers = t.data('events').click;
|
51 |
+
}
|
52 |
+
|
53 |
+
t.off( 'click' );
|
54 |
+
|
55 |
+
t.on('click', function() {
|
56 |
+
var form = $(this).parents('form');
|
57 |
+
if ( ! validateForm( form ) ) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
});
|
61 |
+
};
|
62 |
+
|
63 |
+
var restore_ajax_submit = function() {
|
64 |
+
var t = $('#submit');
|
65 |
+
t.off('click');
|
66 |
+
$.each(submit_handlers, function(index, obj) {
|
67 |
+
t.on('click', obj.handler);
|
68 |
+
});
|
69 |
+
};
|
70 |
+
|
71 |
+
$(function(){
|
72 |
+
|
73 |
+
if ( 'undefined' === typeof WPSC_Term_List_Levels || pagenow !== 'edit-wpsc_product_category' ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
var table = $('body.edit-tags-php .wp-list-table');
|
78 |
+
table.find('tbody tr').each(function(){
|
79 |
+
var t = $(this),
|
80 |
+
id = t.attr('id').replace(/[^0-9]+/g, '');
|
81 |
+
t.data('level', WPSC_Term_List_Levels[id]);
|
82 |
+
t.data('id', id);
|
83 |
+
});
|
84 |
+
table.wpsc_sortable_table({
|
85 |
+
stop : category_sort
|
86 |
+
});
|
87 |
+
|
88 |
+
$('#edittag').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data');
|
89 |
+
$('.edit-tags-php form').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data');
|
90 |
+
|
91 |
+
$('[name="image"]').on('change', function() {
|
92 |
+
var t = $(this);
|
93 |
+
|
94 |
+
if ( t.val() ) {
|
95 |
+
disable_ajax_submit();
|
96 |
+
} else {
|
97 |
+
restore_ajax_submit();
|
98 |
+
}
|
99 |
+
});
|
100 |
+
});
|
101 |
+
|
102 |
+
$(function() {
|
103 |
+
$('.wpsc_select_all').click(function(){
|
104 |
+
$('input:checkbox', $(this).parent().siblings('.multiple-select') ).each(function(){ this.checked = true; });
|
105 |
+
return false;
|
106 |
+
});
|
107 |
+
$('.wpsc_select_none').click(function(){
|
108 |
+
$('input:checkbox', $(this).parent().siblings('.multiple-select') ).each(function(){ this.checked = false; });
|
109 |
+
return false;
|
110 |
+
});
|
111 |
+
});
|
112 |
+
|
113 |
+
$(document).on( 'click', 'form input.prdfil', function(){
|
114 |
+
var t = $(this);
|
115 |
+
var post_data = {
|
116 |
+
'select_product_file[]' : [],
|
117 |
+
product_id : t.parent('form.product_upload').find('input#hidden_id').val(),
|
118 |
+
nonce : t.data('nonce'),
|
119 |
+
action : 'upload_product_file'
|
120 |
+
};
|
121 |
+
|
122 |
+
var products = jQuery(this).parent( 'form.product_upload' ).find( 'input' ).serializeArray();
|
123 |
+
|
124 |
+
for (var index in products) {
|
125 |
+
post_data['select_product_file[]'].push(products[index].value);
|
126 |
+
}
|
127 |
+
|
128 |
+
jQuery.wpsc_post(post_data, function(response){
|
129 |
+
tb_remove();
|
130 |
+
if (! response.is_successful) {
|
131 |
+
alert(response.error.messages.join( ' ' ));
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
jQuery('#wpsc_product_download_forms .select_product_file tbody').append(response.obj.content).
|
135 |
+
find('p.no-item').hide().end().
|
136 |
+
find('p:even').removeClass('alt').end().
|
137 |
+
find('p:odd').addClass('alt');
|
138 |
+
});
|
139 |
+
return false;
|
140 |
+
});
|
141 |
+
|
142 |
+
// delete upload
|
143 |
+
$(document).on( 'click', '.file_delete_button', function(){
|
144 |
+
var t = $(this),
|
145 |
+
post_values = {
|
146 |
+
action : 'delete_file',
|
147 |
+
file_name : t.data('file-name'),
|
148 |
+
product_id : t.data('product-id'),
|
149 |
+
nonce : t.data('nonce')
|
150 |
+
},
|
151 |
+
response_handler = function(response) {
|
152 |
+
if (! response.is_successful) {
|
153 |
+
alert(response.error.messages.join( ' ' ));
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
+
t.closest('.wpsc_product_download_row').fadeOut('fast', function() {
|
158 |
+
$('div.select_product_file p:even').removeClass('alt');
|
159 |
+
$('div.select_product_file p:odd').addClass('alt');
|
160 |
+
$(this).remove();
|
161 |
+
});
|
162 |
+
};
|
163 |
+
|
164 |
+
$.wpsc_post( post_values, response_handler);
|
165 |
+
|
166 |
+
return false;
|
167 |
+
});
|
168 |
+
}(jQuery));
|
169 |
+
|
170 |
+
jQuery(document).ready(function($){
|
171 |
+
|
172 |
+
$('.ui-sortable li .list_gallery_image').mouseover(function(){
|
173 |
+
$('.product_gallery_image_delete_button', $(this).parent()).show();
|
174 |
+
}).mouseout(function(){
|
175 |
+
$('.product_gallery_image_delete_button', $(this).parent()).hide();
|
176 |
+
});
|
177 |
+
|
178 |
+
$('.product_gallery_image_delete_button').click(function(){
|
179 |
+
var product_gallery_image_data = {
|
180 |
+
action: 'product_gallery_image_delete',
|
181 |
+
product_gallery_image_id: $(this).parent().parent().find('.product_gallery_image_id').val(),
|
182 |
+
product_gallery_post_id: $(this).parent().parent().find('.product_gallery_post_id').val(),
|
183 |
+
wpsc_gallery_nonce_check: $('.nonce_class').val()
|
184 |
+
};
|
185 |
+
$.post(ajaxurl, product_gallery_image_data, function(){});
|
186 |
+
$(this).parent().parent().fadeOut( 'slow' );
|
187 |
+
});
|
188 |
+
|
189 |
+
$( document ).on( 'wp-collapse-menu', function() {
|
190 |
+
|
191 |
+
if ( $( 'body' ).hasClass( 'folded' ) ) {
|
192 |
+
$( 'body' ).removeClass( 'folded' );
|
193 |
+
setUserSetting('mfold', 'o');
|
194 |
+
} else {
|
195 |
+
$( 'body' ).addClass( 'folded' );
|
196 |
+
setUserSetting('mfold', 'f');
|
197 |
+
}
|
198 |
+
} );
|
199 |
+
|
200 |
+
$( '#wpsc_price' ).on( 'change', wpsc_update_price_live_preview );
|
201 |
+
$( '#wpsc_sale_price' ).on( 'change', wpsc_update_price_live_preview );
|
202 |
+
|
203 |
+
jQuery('td.hidden_alerts img').each(function(){
|
204 |
+
var t = jQuery(this);
|
205 |
+
t.appendTo(t.parents('tr').find('td.column-title strong'));
|
206 |
+
});
|
207 |
+
|
208 |
+
|
209 |
+
jQuery( '#stock_limit_quantity' ).change( function(){
|
210 |
+
wpsc_push_v2t( '#stock_limit_quantity', '#wpsc_product_stock_metabox_live_title > p > span' );
|
211 |
+
});
|
212 |
+
|
213 |
+
jQuery( 'em.wpsc_metabox_live_title' ).each( function() {
|
214 |
+
var $em = jQuery( this ), $parent = $em.parents( 'div.postbox' ), $h3 = $parent.find( 'h3' );
|
215 |
+
$em.appendTo( $h3 );
|
216 |
+
|
217 |
+
});
|
218 |
+
|
219 |
+
/* Coupon edit functionality */
|
220 |
+
jQuery('.modify_coupon').hide();
|
221 |
+
jQuery('.wpsc_edit_coupon').click(function(){
|
222 |
+
var id;
|
223 |
+
id = jQuery(this).attr('rel');
|
224 |
+
id = 'coupon_box_'+id;
|
225 |
+
if(jQuery('#'+id).hasClass('displaynone')){
|
226 |
+
jQuery('#'+id).show();
|
227 |
+
jQuery('#'+id).removeClass('displaynone');
|
228 |
+
}else{
|
229 |
+
jQuery('#'+id).addClass('displaynone');
|
230 |
+
jQuery('#'+id).hide();
|
231 |
+
}
|
232 |
+
|
233 |
+
});
|
234 |
+
jQuery('form[name="add_coupon"]').submit(function() {
|
235 |
+
var title = jQuery('form[name="add_coupon"] input[name="add_coupon_code"]').val();
|
236 |
+
if ( title === '' ) {
|
237 |
+
jQuery('<div id="notice" class="error"><p>' + wpsc_adminL10n.empty_coupon + '</p></div>').insertAfter('div.wrap > h2').delay(2500).hide(350);
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
});
|
241 |
+
|
242 |
+
/*
|
243 |
+
Alternative Currencies
|
244 |
+
Trigger and handle UI events for adding and removing currency layers.
|
245 |
+
*/
|
246 |
+
|
247 |
+
var currencyRowTemplate = jQuery( '.wpsc-currency-layers tr.template' ).remove().removeClass( 'template hidden' ).removeAttr( 'id' );
|
248 |
+
|
249 |
+
// Hide table if empty
|
250 |
+
if ( jQuery( '.wpsc-currency-layers tbody tr' ).length === 0 ) {
|
251 |
+
jQuery( '.wpsc-currency-layers table' ).hide();
|
252 |
+
}
|
253 |
+
|
254 |
+
// Add new currency layer
|
255 |
+
jQuery( '.wpsc-currency-layers' ).on( 'click', 'a.wpsc_add_new_currency', function( e ) {
|
256 |
+
jQuery( this ).siblings( 'table' ).show();
|
257 |
+
jQuery( '.wpsc-currency-layers tbody' ).append( currencyRowTemplate.clone() );
|
258 |
+
e.preventDefault();
|
259 |
+
});
|
260 |
+
|
261 |
+
// Delete currency layer in admin product page
|
262 |
+
jQuery( '.wpsc-currency-layers' ).on( 'click', 'a.wpsc_delete_currency_layer', function( e ) {
|
263 |
+
var currencyRow = jQuery( this ).closest( 'tr' );
|
264 |
+
currencyRow.find( 'input' ).val( '' );
|
265 |
+
currencyRow.find( 'select' ).val( '' );
|
266 |
+
if ( currencyRow.siblings().length === 0 ) {
|
267 |
+
currencyRow.closest( 'table' ).hide();
|
268 |
+
}
|
269 |
+
currencyRow.remove();
|
270 |
+
e.preventDefault();
|
271 |
+
});
|
272 |
+
|
273 |
+
/*
|
274 |
+
Quantity Discounts
|
275 |
+
Trigger and handle UI events for adding and removing quantity dicounts.
|
276 |
+
*/
|
277 |
+
|
278 |
+
var qtyRowTemplate = jQuery( '.wpsc-quantity-discounts tr.template' ).remove().removeClass( 'template hidden' ).removeAttr( 'id' );
|
279 |
+
|
280 |
+
// Hide table if empty
|
281 |
+
if ( jQuery( '.wpsc-quantity-discounts tbody tr' ).length === 0 ) {
|
282 |
+
jQuery( '.wpsc-quantity-discounts table' ).hide();
|
283 |
+
}
|
284 |
+
|
285 |
+
// Add new row to rate table
|
286 |
+
jQuery( '.wpsc-quantity-discounts' ).on( 'click', '.add_level', function( e ) {
|
287 |
+
jQuery( this ).siblings( 'table' ).show();
|
288 |
+
jQuery( '.wpsc-quantity-discounts tbody' ).append( qtyRowTemplate.clone() );
|
289 |
+
e.preventDefault();
|
290 |
+
});
|
291 |
+
|
292 |
+
// Remove a row from rate table
|
293 |
+
jQuery( '.wpsc-quantity-discounts' ).on( 'click', '.remove_line', function( e ) {
|
294 |
+
var qtyRow = jQuery( this ).closest( 'tr' );
|
295 |
+
qtyRow.find( 'input' ).val( '' );
|
296 |
+
if ( qtyRow.siblings().length === 0 ) {
|
297 |
+
qtyRow.closest( 'table' ).hide();
|
298 |
+
}
|
299 |
+
qtyRow.remove();
|
300 |
+
e.preventDefault();
|
301 |
+
});
|
302 |
+
|
303 |
+
/*
|
304 |
+
As far as I can tell, WP provides no good way of unsetting elements in the bulk edit area...
|
305 |
+
tricky jQuery action will do for now....not ideal whatsoever, nor eternally stable.
|
306 |
+
*/
|
307 |
+
var pagenow = pagenow || '';
|
308 |
+
|
309 |
+
if( pagenow === 'edit-wpsc-product' ) {
|
310 |
+
jQuery('.inline-edit-password-input').closest('.inline-edit-group').css('display', 'none');
|
311 |
+
var vcl = jQuery('.inline-edit-col input[name="tax_input[wpsc-variation][]"]').css('display', 'none');
|
312 |
+
vcl.each(function(){
|
313 |
+
jQuery(this).prev().css('display', 'none');
|
314 |
+
jQuery(this).next().css('display', 'none');
|
315 |
+
jQuery(this).css('display', 'none');
|
316 |
+
});
|
317 |
+
jQuery('#bulk-edit select[name=post_parent]').closest('fieldset').css('display', 'none');
|
318 |
+
jQuery('.inline-edit-col select[name=post_parent]').parent().css('display', 'none');
|
319 |
+
jQuery('.inline-edit-status').parent().css('display', 'none');
|
320 |
+
}
|
321 |
+
if ( wpsc_adminL10n.dragndrop_set === 'true' && typenow === 'wpsc-product' && adminpage === 'edit-php' ) {
|
322 |
+
// this makes the product list table sortable
|
323 |
+
jQuery('table.widefat:not(.tags)').sortable({
|
324 |
+
update: function() {
|
325 |
+
var category_id = jQuery('select#wpsc_product_category option:selected').val(),
|
326 |
+
product_order = jQuery('table.widefat').sortable( 'toArray' ),
|
327 |
+
post_data = {
|
328 |
+
action : 'save_product_order',
|
329 |
+
'category_id' : category_id,
|
330 |
+
'post[]' : product_order,
|
331 |
+
nonce : wpsc_adminL10n.save_product_order_nonce
|
332 |
+
};
|
333 |
+
jQuery.wpsc_post(post_data, function(response) {
|
334 |
+
if (! response.is_successful) {
|
335 |
+
alert(response.error.messages.join( ' ' ));
|
336 |
+
}
|
337 |
+
});
|
338 |
+
},
|
339 |
+
items: 'tbody tr',
|
340 |
+
axis: 'y',
|
341 |
+
containment: 'table.widefat tbody',
|
342 |
+
placeholder: 'product-placeholder',
|
343 |
+
cursor: 'move',
|
344 |
+
cancel: 'tr.inline-edit-wpsc-product'
|
345 |
+
});
|
346 |
+
}
|
347 |
+
|
348 |
+
var limited_stock_checkbox = jQuery('input.limited_stock_checkbox');
|
349 |
+
var toggle_stock_fields = function(checked) {
|
350 |
+
jQuery('div.edit_stock').toggle(checked);
|
351 |
+
jQuery('th.column-stock input, td.stock input').each(function(){
|
352 |
+
this.disabled = ! checked;
|
353 |
+
});
|
354 |
+
};
|
355 |
+
|
356 |
+
if (limited_stock_checkbox.size() > 0) {
|
357 |
+
toggle_stock_fields(limited_stock_checkbox.is(':checked'));
|
358 |
+
}
|
359 |
+
|
360 |
+
// show or hide the stock input forms
|
361 |
+
limited_stock_checkbox.on('click', function () {
|
362 |
+
toggle_stock_fields(limited_stock_checkbox.is(':checked'));
|
363 |
+
});
|
364 |
+
|
365 |
+
jQuery( '#custom_tax_checkbox' ).on( 'click', function(){
|
366 |
+
if (this.checked) {
|
367 |
+
jQuery('#custom_tax').show();
|
368 |
+
} else {
|
369 |
+
jQuery('#custom_tax input').val('');
|
370 |
+
jQuery('#custom_tax').hide();
|
371 |
+
}
|
372 |
+
});
|
373 |
+
|
374 |
+
jQuery( '.wpsc_featured_product_toggle' ).on( 'click', function(){
|
375 |
+
var post_values = {
|
376 |
+
product_id : jQuery( this ).parents( 'tr' ).attr( 'id' ).replace( 'post-', '' ),
|
377 |
+
action : 'update_featured_product'
|
378 |
+
};
|
379 |
+
|
380 |
+
jQuery.post( ajaxurl, post_values, function( response ) {
|
381 |
+
jQuery( '.featured_toggle_' + response.product_id ).html( '<img class="' + response.color + '" src="' + response.image + '" alt="' + response.text + '" title="' + response.text + '" />' );
|
382 |
+
}, 'json' );
|
383 |
+
|
384 |
+
return false;
|
385 |
+
});
|
386 |
+
|
387 |
+
jQuery( 'div.coupon-condition' ).each( function() {
|
388 |
+
if( jQuery( 'select[name="rules[operator][]"]', jQuery( this ) ).length !== 0 ) {
|
389 |
+
var margin = jQuery( 'select.ruleprops', jQuery( this ) ).offset().left - jQuery( this ).offset().left;
|
390 |
+
margin = parseInt( margin, 10 ) - 1;
|
391 |
+
jQuery( 'select[name="rules[operator][]"]', jQuery( this ) ).css( 'margin-left', '-' + margin + 'px' );
|
392 |
+
}
|
393 |
+
});
|
394 |
+
|
395 |
+
jQuery( '.coupon-conditions' ).on( 'click', '.wpsc-button-plus', function() {
|
396 |
+
var parent = jQuery( this ).closest( '.coupon-condition' ),
|
397 |
+
prototype = parent.clone(),
|
398 |
+
operator_box = jQuery('<select/>',{name:'rules[operator][]'});
|
399 |
+
|
400 |
+
if ( jQuery( 'select[name="rules[operator][]"]', prototype ).length === 0 ) {
|
401 |
+
operator_box.append('<option value="and">' + wpsc_adminL10n.coupons_compare_and + '</option>');
|
402 |
+
operator_box.append('<option value="or">' + wpsc_adminL10n.coupons_compare_or + '</option>');
|
403 |
+
prototype.prepend(operator_box);
|
404 |
+
}
|
405 |
+
|
406 |
+
prototype.find('select').val('');
|
407 |
+
prototype.find('input').val('');
|
408 |
+
prototype.css( { 'opacity' : '0' } );
|
409 |
+
prototype.insertAfter(parent);
|
410 |
+
|
411 |
+
var margin = jQuery( 'select.ruleprops', prototype ).offset().left - prototype.offset().left;
|
412 |
+
margin = parseInt( margin, 10 ) - 1;
|
413 |
+
prototype.find('input').focus();
|
414 |
+
|
415 |
+
prototype.animate( { opacity: 1, 'margin-left': '-' + margin + 'px', height: 'show' }, 150 );
|
416 |
+
|
417 |
+
return false;
|
418 |
+
});
|
419 |
+
|
420 |
+
jQuery('.coupon-conditions').on( 'click', '.wpsc-button-minus', function() {
|
421 |
+
var parent = jQuery(this).closest('.coupon-condition'),
|
422 |
+
conditions_count = jQuery('.coupon-condition').size(),
|
423 |
+
prototype;
|
424 |
+
|
425 |
+
if ( jQuery( this ).index( jQuery( '.wpsc-button-minus' ) ) === 0 ) {
|
426 |
+
return false;
|
427 |
+
}
|
428 |
+
|
429 |
+
if ( conditions_count === 1 ) {
|
430 |
+
prototype = parent.clone();
|
431 |
+
prototype.find('select').val('');
|
432 |
+
prototype.find('input').val('');
|
433 |
+
prototype.hide();
|
434 |
+
jQuery('.coupon-conditions').find('td').prepend(prototype);
|
435 |
+
parent.slideUp(150, function(){
|
436 |
+
prototype.slideDown(150);
|
437 |
+
parent.remove();
|
438 |
+
});
|
439 |
+
|
440 |
+
return false;
|
441 |
+
}
|
442 |
+
|
443 |
+
parent.slideUp(150, function(){
|
444 |
+
parent.remove();
|
445 |
+
});
|
446 |
+
|
447 |
+
return false;
|
448 |
+
});
|
449 |
+
|
450 |
+
jQuery( '#wpsc_product_details_forms .category-tabs a, #wpsc_product_delivery_forms .category-tabs a' ).click(function(event){
|
451 |
+
var $this = jQuery(this), href = $this.attr('href');
|
452 |
+
|
453 |
+
$this.closest('ul').find('li').removeClass('tabs');
|
454 |
+
$this.closest('li').addClass('tabs');
|
455 |
+
$this.closest('div').find('.tabs-panel').hide();
|
456 |
+
jQuery(href).show();
|
457 |
+
event.preventDefault();
|
458 |
+
});
|
459 |
+
|
460 |
+
// Meta table
|
461 |
+
var meta_inp_tem = jQuery('#wpsc_new_meta_template').remove().removeAttr('id');
|
462 |
+
|
463 |
+
jQuery('#wpsc_add_custom_meta').click(function(){
|
464 |
+
if ( jQuery( 'tr.no-meta' ).is( ':visible' ) ) {
|
465 |
+
jQuery( 'tr.no-meta' ).hide();
|
466 |
+
}
|
467 |
+
|
468 |
+
jQuery('#wpsc_product_meta_table tbody').append(meta_inp_tem.clone());
|
469 |
+
event.preventDefault();
|
470 |
+
});
|
471 |
+
|
472 |
+
// Init delivery metabox live title
|
473 |
+
if (jQuery('#wpsc_product_delivery_forms').length > 0){
|
474 |
+
jQuery('#wpsc_product_delivery_forms input, #wpsc_product_delivery_forms select').change(wpsc_update_delivery_metabox_live_title);
|
475 |
+
wpsc_update_delivery_metabox_live_title();
|
476 |
+
}
|
477 |
+
|
478 |
+
// Init product details metabox live title
|
479 |
+
if (jQuery('#wpsc_product_details_forms').length > 0){
|
480 |
+
jQuery('#wpsc_product_details_forms a').click(wpsc_update_product_details_metabox_live_title);
|
481 |
+
wpsc_update_product_details_metabox_live_title();
|
482 |
+
}
|
483 |
+
|
484 |
+
wpsc_update_price_live_preview();
|
485 |
+
});
|
486 |
+
|
487 |
+
|
488 |
+
// Remove new/empty custom meta input row
|
489 |
+
function wpsc_remove_empty_meta( caller ) {
|
490 |
+
jQuery(caller).closest('tr').remove();
|
491 |
+
|
492 |
+
wpsc_update_product_details_metabox_live_title();
|
493 |
+
|
494 |
+
if ( ! jQuery( '#wpsc_product_meta_table tbody tr' ).not( '.no-meta' ).length ) {
|
495 |
+
jQuery( 'tr.no-meta' ).show();
|
496 |
+
}
|
497 |
+
|
498 |
+
event.preventDefault();
|
499 |
+
}
|
500 |
+
|
501 |
+
// function for removing custom meta
|
502 |
+
function wpsc_remove_custom_meta(caller, meta_id) {
|
503 |
+
var post_data = {
|
504 |
+
action : 'remove_product_meta',
|
505 |
+
'meta_id' : meta_id,
|
506 |
+
nonce : jQuery(caller).data('nonce')
|
507 |
+
};
|
508 |
+
|
509 |
+
var response_handler = function(response) {
|
510 |
+
if (! response.is_successful) {
|
511 |
+
alert(response.error.messages.join( ' ' ));
|
512 |
+
return;
|
513 |
+
}
|
514 |
+
jQuery(caller).closest('tr').remove();
|
515 |
+
};
|
516 |
+
|
517 |
+
jQuery.wpsc_post(post_data, response_handler);
|
518 |
+
wpsc_update_product_details_metabox_live_title();
|
519 |
+
|
520 |
+
if ( ! jQuery( '#wpsc_product_meta_table tbody tr' ).not( '.no-meta' ).length ) {
|
521 |
+
jQuery( 'tr.no-meta' ).show();
|
522 |
+
}
|
523 |
+
|
524 |
+
event.preventDefault();
|
525 |
+
}
|
526 |
+
|
527 |
+
// Copy value of caller to target text
|
528 |
+
function wpsc_push_v2t(caller, target_slt){
|
529 |
+
jQuery(target_slt).text(jQuery(caller).val());
|
530 |
+
}
|
531 |
+
|
532 |
+
function wpsc_update_price_live_preview(){
|
533 |
+
var price = jQuery('#wpsc_price').val();
|
534 |
+
var sale_price = jQuery('#wpsc_sale_price').val();
|
535 |
+
|
536 |
+
if (sale_price > 0){
|
537 |
+
jQuery('#wpsc_product_price_metabox_live_title>p>span').text(sale_price);
|
538 |
+
jQuery('#wpsc_product_price_metabox_live_title>del>span').text(price);
|
539 |
+
jQuery('#wpsc_product_price_metabox_live_title>del').show();
|
540 |
+
} else {
|
541 |
+
jQuery('#wpsc_product_price_metabox_live_title>p>span').text(price);
|
542 |
+
jQuery('#wpsc_product_price_metabox_live_title>del').hide();
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
// Compose and update live title for shipping metabox
|
547 |
+
function wpsc_update_delivery_metabox_live_title(){
|
548 |
+
|
549 |
+
if ( ! jQuery('#wpsc_product_delivery_forms').length ) {
|
550 |
+
return;
|
551 |
+
}
|
552 |
+
|
553 |
+
var weight = jQuery('#wpsc-product-shipping-weight').val();
|
554 |
+
var weight_unit = jQuery('#wpsc-product-shipping-weight-unit').val();
|
555 |
+
var length = jQuery('#wpsc-product-shipping-length').val();
|
556 |
+
var width = jQuery('#wpsc-product-shipping-width').val();
|
557 |
+
var height = jQuery('#wpsc-product-shipping-height').val();
|
558 |
+
var dimensions_unit = jQuery('#wpsc-product-shipping-dimensions-unit').val();
|
559 |
+
var number_of_downloads = jQuery('.wpsc_product_download_row').length;
|
560 |
+
|
561 |
+
var vol = Math.round( ( length * width * height ) * 100) / 100; // Round up to two decimal
|
562 |
+
var downloads_name = ( number_of_downloads !== 1 ) ? wpsc_adminL10n.meta_downloads_plural : wpsc_adminL10n.meta_downloads_singular;
|
563 |
+
var output = '';
|
564 |
+
|
565 |
+
if ( jQuery( '.wpsc-product-shipping-section' ).length ) {
|
566 |
+
output += weight + ' ' + weight_unit + ', ' + vol + ' ' + dimensions_unit + '<sup>3</sup>, ';
|
567 |
+
}
|
568 |
+
|
569 |
+
output += number_of_downloads + downloads_name;
|
570 |
+
|
571 |
+
jQuery( '#wpsc_product_delivery_metabox_live_title > p' ).html( output );
|
572 |
+
}
|
573 |
+
|
574 |
+
function wpsc_update_product_details_metabox_live_title(){
|
575 |
+
if ( jQuery('#wpsc_product_details_forms').length <= 0 ){
|
576 |
+
return;
|
577 |
+
}
|
578 |
+
|
579 |
+
var number_of_photos = jQuery('#wpsc_product_gallery img').length;
|
580 |
+
var number_of_meta = jQuery('#wpsc_product_meta_table tbody tr').not('.no-meta').length;
|
581 |
+
|
582 |
+
var output = number_of_photos + ' images, ';
|
583 |
+
output += number_of_meta + ' metadata';
|
584 |
+
|
585 |
+
jQuery('#wpsc_product_details_metabox_live_title>p').html(output);
|
586 |
+
}
|
587 |
+
|
588 |
+
function wpsc_update_product_gallery_tab(obj){
|
589 |
+
var output, url;
|
590 |
+
|
591 |
+
output = '<div id="wpsc_product_gallery">';
|
592 |
+
output += '<ul>';
|
593 |
+
|
594 |
+
for (var i = 0; i < obj.length; i++) {
|
595 |
+
|
596 |
+
if ( 'undefined' !== typeof obj[i].sizes.thumbnail ) {
|
597 |
+
url = obj[i].sizes.thumbnail.url;
|
598 |
+
} else {
|
599 |
+
url = obj[i].sizes.full.url;
|
600 |
+
}
|
601 |
+
|
602 |
+
output += '<li>';
|
603 |
+
output += '<img src="' + url + '">';
|
604 |
+
output += '<input type="hidden" name="wpsc-product-gallery-imgs[]" value="' + obj[i].id + '">';
|
605 |
+
|
606 |
+
output += '</li>';
|
607 |
+
}
|
608 |
+
|
609 |
+
output += '</ul>';
|
610 |
+
output += '<div class="clear"></div>';
|
611 |
+
output += '</div>';
|
612 |
+
|
613 |
+
jQuery('#wpsc_product_gallery').replaceWith(output);
|
614 |
+
wpsc_update_product_details_metabox_live_title();
|
615 |
+
}
|
616 |
+
|
617 |
+
var prevElement = null;
|
618 |
+
var prevOption = null;
|
619 |
+
|
620 |
+
function hideOptionElement(id, option) {
|
621 |
+
if (prevOption === option) {
|
622 |
+
return;
|
623 |
+
}
|
624 |
+
if (prevElement !== null) {
|
625 |
+
prevElement.style.display = 'none';
|
626 |
+
}
|
627 |
+
|
628 |
+
if (id === null) {
|
629 |
+
prevElement = null;
|
630 |
+
} else {
|
631 |
+
prevElement = document.getElementById(id);
|
632 |
+
jQuery('#'+id).css( 'display','block');
|
633 |
+
}
|
634 |
+
prevOption = option;
|
635 |
+
}
|
636 |
+
|
637 |
+
function hideelement(id) {
|
638 |
+
var state = document.getElementById(id).style.display;
|
639 |
+
if(state !== 'block') {
|
640 |
+
document.getElementById(id).style.display = 'block';
|
641 |
+
} else {
|
642 |
+
document.getElementById(id).style.display = 'none';
|
643 |
+
}
|
644 |
+
}
|
645 |
+
|
646 |
+
function getcurrency() {
|
647 |
+
//ajax.post("index.php",gercurrency,"wpsc_admin_action=change_currency¤cyid="+id);
|
648 |
+
}
|
649 |
+
|
650 |
+
function hideelement1(id, item_value) {
|
651 |
+
if(item_value === 5) {
|
652 |
+
jQuery(document.getElementById(id)).css('display', 'block');
|
653 |
+
} else {
|
654 |
+
jQuery(document.getElementById(id)).css('display', 'none');
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
function show_status_box(id,image_id) {
|
659 |
+
var state;
|
660 |
+
state = document.getElementById(id).style.display;
|
661 |
+
if(state !== 'block') {
|
662 |
+
document.getElementById(id).style.display = 'block';
|
663 |
+
document.getElementById(image_id).src = wpsc_adminL10n.wpsc_core_images_url + '/icon_window_collapse.gif';
|
664 |
+
} else {
|
665 |
+
document.getElementById(id).style.display = 'none';
|
666 |
+
document.getElementById(image_id).src = wpsc_adminL10n.wpsc_core_images_url + '/icon_window_expand.gif';
|
667 |
+
}
|
668 |
+
return false;
|
669 |
+
}
|
trunk/wpsc-admin/js/media.js
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*global _, WPSC_Media, Backbone, alert, WPSC, wp, wpsc_refresh_variation_iframe, wpsc_set_variation_product_thumbnail, jQuery, WPRemoveThumbnail */
|
2 |
+
(function($) {
|
3 |
+
"use strict";
|
4 |
+
window.WPSC = window.WPSC || {};
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Inspired by Cocktail (https://github.com/onsi/cocktail/) but with some
|
8 |
+
* important modifications.
|
9 |
+
*
|
10 |
+
* Mixing an object into a class' prototype will make sure that object is
|
11 |
+
* extended from previous Mixins / oroginal prototype.
|
12 |
+
*
|
13 |
+
* Primitive values can also be mixed in.
|
14 |
+
*
|
15 |
+
* @param {Object} object The original object
|
16 |
+
* @param {...Object} mixins Mixins
|
17 |
+
*/
|
18 |
+
window.WPSC.mixin = function( clss ) {
|
19 |
+
var modules = _.rest( arguments );
|
20 |
+
var chain = {};
|
21 |
+
|
22 |
+
_.each( modules, function( module ) {
|
23 |
+
var override = module._mixin_override || [];
|
24 |
+
module = _.omit( module, [ '_mixin_override'] );
|
25 |
+
|
26 |
+
_.each( module, function( value, key ) {
|
27 |
+
if ( _.contains( override, key ) ) {
|
28 |
+
chain[key] = [value];
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
if ( _.isFunction( value ) ) {
|
33 |
+
if ( clss.prototype[key] )
|
34 |
+
chain[key] = [clss.prototype[key]];
|
35 |
+
|
36 |
+
chain[key].push( value );
|
37 |
+
} else if ( _.isObject( value ) ) {
|
38 |
+
chain[key] = chain[key] || [{}];
|
39 |
+
if ( clss.prototype[key] )
|
40 |
+
chain[key] = [clss.prototype[key]];
|
41 |
+
|
42 |
+
chain[key].push( _.extend( {}, chain[key][0], value ) );
|
43 |
+
} else {
|
44 |
+
chain[key] = chain[key] || [];
|
45 |
+
chain[key].push( value );
|
46 |
+
}
|
47 |
+
} );
|
48 |
+
} );
|
49 |
+
|
50 |
+
_.each( chain, function( values, key ) {
|
51 |
+
var last = _.last( values );
|
52 |
+
|
53 |
+
if ( ! _.isFunction( last ) ) {
|
54 |
+
clss.prototype[key] = last;
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
clss.prototype[key] = function() {
|
59 |
+
var ret, args = arguments, that = this;
|
60 |
+
_.each( values, function( fn ) {
|
61 |
+
var fnRet = fn.apply( that, args );
|
62 |
+
ret =
|
63 |
+
_.isUndefined( fnRet ) ?
|
64 |
+
ret :
|
65 |
+
fnRet;
|
66 |
+
});
|
67 |
+
|
68 |
+
return ret;
|
69 |
+
};
|
70 |
+
} );
|
71 |
+
};
|
72 |
+
|
73 |
+
var media = window.wp.media;
|
74 |
+
|
75 |
+
var backup = _.clone( media.view.settings.post );
|
76 |
+
|
77 |
+
media.controller.wpsc = {
|
78 |
+
ProductGallery: media.controller.Library.extend({
|
79 |
+
defaults: _.defaults({
|
80 |
+
id : 'wpsc-product-gallery',
|
81 |
+
filterable : 'uploaded',
|
82 |
+
multiple : 'add',
|
83 |
+
toolbar : 'wpsc-save-gallery',
|
84 |
+
title : WPSC_Media.l10n.productMediaTitle,
|
85 |
+
priority : 50,
|
86 |
+
library : media.query( { type: 'image' } ),
|
87 |
+
syncSelection: false
|
88 |
+
}, media.controller.Library.prototype.defaults ),
|
89 |
+
|
90 |
+
initialize: function( options ) {
|
91 |
+
options = options || {};
|
92 |
+
var selection = new media.model.wpsc.ProductGallerySelection(
|
93 |
+
[],
|
94 |
+
{
|
95 |
+
postId: media.model.settings.post.id,
|
96 |
+
multiple: this.get( 'multiple' ),
|
97 |
+
updateNonce: options.updateNonce || WPSC_Media.updateGalleryNonce,
|
98 |
+
getNonce: options.getNonce || WPSC_Media.getGalleryNonce
|
99 |
+
}
|
100 |
+
);
|
101 |
+
this.set(
|
102 |
+
'selection',
|
103 |
+
selection
|
104 |
+
);
|
105 |
+
|
106 |
+
var models = options.models || WPSC_Media.gallery;
|
107 |
+
|
108 |
+
// work around for backbone.js 0.9.2
|
109 |
+
if ( _.isUndefined( Backbone.Collection.prototype.set ) ) {
|
110 |
+
// force parse the response
|
111 |
+
models = selection.parse( models );
|
112 |
+
selection.reset( models );
|
113 |
+
} else {
|
114 |
+
selection.set( models, { parse: true } );
|
115 |
+
}
|
116 |
+
|
117 |
+
media.controller.Library.prototype.initialize.apply( this, arguments );
|
118 |
+
|
119 |
+
this.on( 'select', function() {
|
120 |
+
selection.save_gallery();
|
121 |
+
} );
|
122 |
+
|
123 |
+
this.on( 'reset', function() {
|
124 |
+
selection.get_gallery();
|
125 |
+
}) ;
|
126 |
+
|
127 |
+
this.get( 'library' ).observe( selection );
|
128 |
+
}
|
129 |
+
})
|
130 |
+
};
|
131 |
+
|
132 |
+
media.model.wpsc = {
|
133 |
+
ProductGallerySelection: media.model.Selection.extend( {
|
134 |
+
initialize: function( models, options ) {
|
135 |
+
media.model.Selection.prototype.initialize.apply( this, [models, options] );
|
136 |
+
this.postId = options && options.postId;
|
137 |
+
this.updateNonce = options.updateNonce || WPSC_Media.updateGalleryNonce;
|
138 |
+
this.getNonce = options.getNonce || WPSC_Media.getGalleryNonce;
|
139 |
+
},
|
140 |
+
|
141 |
+
save_gallery: function( options ) {
|
142 |
+
options = _.extend( options || {}, {
|
143 |
+
data: {
|
144 |
+
items: this.pluck( 'id' )
|
145 |
+
},
|
146 |
+
success: function( resp, status, xhr ) {
|
147 |
+
// in case of backbone 0.9.2
|
148 |
+
if ( _.isUndefined( this.set ) ) {
|
149 |
+
// force parse the response
|
150 |
+
resp.obj = this.parse( resp.obj, xhr );
|
151 |
+
this.reset( resp.obj );
|
152 |
+
} else {
|
153 |
+
this.set( resp.obj, { parse: true } );
|
154 |
+
}
|
155 |
+
|
156 |
+
wpsc_update_product_gallery_tab(resp.obj);
|
157 |
+
},
|
158 |
+
error: function( resp ) {
|
159 |
+
alert( resp.error.messages.join( "\n" ) );
|
160 |
+
}
|
161 |
+
} );
|
162 |
+
this.sync( 'update', this, options );
|
163 |
+
},
|
164 |
+
|
165 |
+
get_gallery: function( options ) {
|
166 |
+
options = _.extend( options || {}, {
|
167 |
+
success: function( resp, status, xhr ) {
|
168 |
+
// in case of backbone 0.9.2
|
169 |
+
if ( _.isUndefined( this.set ) ) {
|
170 |
+
// force parse the response
|
171 |
+
resp.obj = this.parse( resp.obj, xhr );
|
172 |
+
this.reset( resp.obj );
|
173 |
+
} else {
|
174 |
+
this.set( resp.obj, { parse: true } );
|
175 |
+
}
|
176 |
+
wpsc_refresh_variation_iframe();
|
177 |
+
},
|
178 |
+
error: function( resp ) {
|
179 |
+
alert( resp.error.messages.join( "\n" ) );
|
180 |
+
}
|
181 |
+
} );
|
182 |
+
this.sync( 'read', this, options );
|
183 |
+
},
|
184 |
+
|
185 |
+
sync: function( method, collection, options ) {
|
186 |
+
|
187 |
+
var data;
|
188 |
+
options = options ? _.clone( options ) : {};
|
189 |
+
|
190 |
+
options.success = _.bind( options.success, this );
|
191 |
+
options.error = _.bind( options.error, this );
|
192 |
+
|
193 |
+
switch (method) {
|
194 |
+
case 'read':
|
195 |
+
options.data = options.data || {};
|
196 |
+
data = _.defaults( {
|
197 |
+
action: 'get_product_gallery',
|
198 |
+
nonce : this.getNonce,
|
199 |
+
postId: this.postId
|
200 |
+
}, options.data );
|
201 |
+
break;
|
202 |
+
|
203 |
+
case 'update':
|
204 |
+
options.data = options.data || {};
|
205 |
+
data = _.defaults( {
|
206 |
+
action: 'save_product_gallery',
|
207 |
+
nonce : this.updateNonce,
|
208 |
+
items : this.pluck( 'id' ),
|
209 |
+
postId: this.postId
|
210 |
+
}, options.data );
|
211 |
+
|
212 |
+
break;
|
213 |
+
|
214 |
+
case 'create':
|
215 |
+
case 'delete':
|
216 |
+
// do nothing for now
|
217 |
+
break;
|
218 |
+
}
|
219 |
+
|
220 |
+
$.wpsc_post( data ).done( function( resp, status, xhr ) {
|
221 |
+
if ( resp.is_successful ) {
|
222 |
+
options.success( resp, status, xhr );
|
223 |
+
} else {
|
224 |
+
options.error( resp, status, xhr );
|
225 |
+
}
|
226 |
+
} );
|
227 |
+
}
|
228 |
+
} )
|
229 |
+
};
|
230 |
+
|
231 |
+
media.view.wpsc = {
|
232 |
+
};
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Extend the MediaFrame.Post class so that we can inject a custom tab
|
236 |
+
* dynamically using JavaScript.
|
237 |
+
*/
|
238 |
+
WPSC.mixin(
|
239 |
+
media.view.MediaFrame.Post,
|
240 |
+
{
|
241 |
+
wpsc: {
|
242 |
+
saveGalleryStatusBar: function( view ) {
|
243 |
+
this.selectionStatusToolbar(view);
|
244 |
+
},
|
245 |
+
saveGalleryToolbar: function( toolbar ) {
|
246 |
+
this.createSelectToolbar( toolbar, {
|
247 |
+
text : WPSC_Media.l10n.saveGallery,
|
248 |
+
state: this.options.state,
|
249 |
+
reset: false
|
250 |
+
} );
|
251 |
+
},
|
252 |
+
createStates: function() {
|
253 |
+
this.states.add( new media.controller.wpsc.ProductGallery( { models: this.options.models, updateNonce: this.options.updateNonce, getNonce: this.options.getNonce } ) );
|
254 |
+
},
|
255 |
+
bindHandlers: function() {
|
256 |
+
this.on( 'toolbar:create:wpsc-save-gallery', this.wpsc.saveGalleryToolbar, this );
|
257 |
+
this.on( 'toolbar:render:wpsc-save-gallery', this.wpsc.saveGalleryStatusBar, this );
|
258 |
+
}
|
259 |
+
},
|
260 |
+
|
261 |
+
initialize: function() {
|
262 |
+
if ( ! this.options.models )
|
263 |
+
this.options.models = WPSC_Media.gallery;
|
264 |
+
|
265 |
+
if ( ! this.options.updateNonce )
|
266 |
+
this.options.updateNonce = WPSC_Media.updateGalleryNonce;
|
267 |
+
|
268 |
+
if ( ! this.options.getNonce )
|
269 |
+
this.options.getNonce = WPSC_Media.getGalleryNonce;
|
270 |
+
|
271 |
+
this.wpsc.createStates.apply( this );
|
272 |
+
this.wpsc.bindHandlers.apply( this );
|
273 |
+
}
|
274 |
+
}
|
275 |
+
);
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Extend media.view.Attachment
|
279 |
+
*/
|
280 |
+
WPSC.mixin(
|
281 |
+
media.view.Attachment,
|
282 |
+
{
|
283 |
+
render: function() {
|
284 |
+
if ( this.controller.state().id != 'wpsc-product-gallery' )
|
285 |
+
return;
|
286 |
+
|
287 |
+
if ( this.model.id != media.view.settings.post.featuredImageId )
|
288 |
+
return;
|
289 |
+
|
290 |
+
this.$el.find( '.thumbnail' ).append('<span class="wpsc-featured-label">featured</span>');
|
291 |
+
}
|
292 |
+
}
|
293 |
+
);
|
294 |
+
|
295 |
+
WPSC_Media.open = function( options ) {
|
296 |
+
var workflow;
|
297 |
+
|
298 |
+
media.view.settings.post.id = options.id;
|
299 |
+
media.view.settings.post.featuredImageId = options.featuredId;
|
300 |
+
media.view.settings.post.nonce = options.featuredNonce;
|
301 |
+
media.model.settings.post = media.view.settings.post;
|
302 |
+
media.editor.remove( 'wpsc-variation-media' );
|
303 |
+
media.editor.add( 'wpsc-variation-media', {
|
304 |
+
models: options.models,
|
305 |
+
updateNonce: options.galleryUpdateNonce,
|
306 |
+
getNonce: options.galleryGetNonce
|
307 |
+
});
|
308 |
+
workflow = media.editor.open( 'wpsc-variation-media' );
|
309 |
+
};
|
310 |
+
|
311 |
+
var oldEditorOpen = media.editor.open;
|
312 |
+
media.editor.open = function( id ) {
|
313 |
+
if ( id == 'content' ) {
|
314 |
+
if ( media.view.settings.post.id == backup.id ) {
|
315 |
+
// always make sure the backup copy is up to date
|
316 |
+
backup = _.clone( media.view.settings.post );
|
317 |
+
} else {
|
318 |
+
// if the frame was opened for a variation previously, this time
|
319 |
+
// restore the globals from the backup
|
320 |
+
media.view.settings.post = _.clone( backup );
|
321 |
+
media.model.settings.post = media.view.settings.post;
|
322 |
+
}
|
323 |
+
}
|
324 |
+
return oldEditorOpen.apply( this, arguments );
|
325 |
+
};
|
326 |
+
|
327 |
+
// hack the set featured image function
|
328 |
+
wp.media.featuredImage.set = function( id ) {
|
329 |
+
var settings = wp.media.view.settings;
|
330 |
+
var currentId = settings.post.id;
|
331 |
+
|
332 |
+
settings.post.featuredImageId = id;
|
333 |
+
|
334 |
+
wp.media.post( 'set-post-thumbnail', {
|
335 |
+
json: true,
|
336 |
+
post_id: settings.post.id,
|
337 |
+
thumbnail_id: settings.post.featuredImageId,
|
338 |
+
_wpnonce: settings.post.nonce
|
339 |
+
}).done( function( html ) {
|
340 |
+
if ( currentId == backup.id ) {
|
341 |
+
wpsc_refresh_variation_iframe();
|
342 |
+
$( '.inside', '#postimagediv' ).html( html );
|
343 |
+
} else {
|
344 |
+
wpsc_set_variation_product_thumbnail( currentId, $( html ).find( 'img' ).attr( 'src' ), id );
|
345 |
+
}
|
346 |
+
});
|
347 |
+
};
|
348 |
+
|
349 |
+
// hack the Remove thumbnail link so that it refreshes the variation iframe
|
350 |
+
// after the AJAX request is processed
|
351 |
+
WPRemoveThumbnail = function(nonce){
|
352 |
+
$.post( ajaxurl, {
|
353 |
+
action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
|
354 |
+
}, function(str){
|
355 |
+
if ( str == '0' ) {
|
356 |
+
alert( setPostThumbnailL10n.error );
|
357 |
+
} else {
|
358 |
+
WPSetThumbnailHTML(str);
|
359 |
+
wpsc_refresh_variation_iframe();
|
360 |
+
}
|
361 |
+
}
|
362 |
+
);
|
363 |
+
};
|
364 |
+
|
365 |
+
|
366 |
+
$(function() {
|
367 |
+
$('#wpsc-manage-product-gallery').on('click', function( e ) {
|
368 |
+
var frame;
|
369 |
+
|
370 |
+
e.preventDefault();
|
371 |
+
e.stopPropagation();
|
372 |
+
|
373 |
+
frame = wp.media({
|
374 |
+
state: 'wpsc-product-gallery',
|
375 |
+
states: [ new wp.media.controller.wpsc.ProductGallery() ]
|
376 |
+
});
|
377 |
+
|
378 |
+
frame.on( 'toolbar:create:wpsc-save-gallery', function(toolbar) {
|
379 |
+
this.createSelectToolbar( toolbar, {
|
380 |
+
text : WPSC_Media.l10n.saveGallery,
|
381 |
+
state: this.options.state
|
382 |
+
} );
|
383 |
+
}, frame );
|
384 |
+
frame.on( 'toolbar:render:wpsc-save-gallery', function( view ) {
|
385 |
+
view.set( 'selection', new media.view.Selection({
|
386 |
+
controller: this,
|
387 |
+
collection: this.state().get( 'selection' ),
|
388 |
+
priority: -40,
|
389 |
+
editable: this.state().get('editable')
|
390 |
+
}).render());
|
391 |
+
}, frame );
|
392 |
+
|
393 |
+
frame.open();
|
394 |
+
});
|
395 |
+
// make our gallery sortable
|
396 |
+
$( 'div#wpsc_product_gallery' ).find( 'ul' ).sortable({
|
397 |
+
cursor: 'move',
|
398 |
+
revert: 300,
|
399 |
+
}).disableSelection();
|
400 |
+
});
|
401 |
+
}(jQuery));
|
trunk/wpsc-admin/js/product-variations.js
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global WPSC_Product_Variations, alert */
|
2 |
+
(function($){
|
3 |
+
var resize_iframe = function() {
|
4 |
+
if (typeof window.parent.wpsc_resize_iframe !== 'undefined') {
|
5 |
+
window.parent.wpsc_resize_iframe();
|
6 |
+
}
|
7 |
+
};
|
8 |
+
|
9 |
+
$(function(){
|
10 |
+
resize_iframe();
|
11 |
+
|
12 |
+
$('.wpsc-variation-stock-editor-link').click( function( event ) {
|
13 |
+
var parent = $(this).closest('tr'),
|
14 |
+
target_row = parent.next('.wpsc-stock-editor-row');
|
15 |
+
|
16 |
+
event.preventDefault();
|
17 |
+
|
18 |
+
target_row.toggle( 100 );
|
19 |
+
parent.toggleClass('active');
|
20 |
+
resize_iframe();
|
21 |
+
|
22 |
+
return false;
|
23 |
+
});
|
24 |
+
});
|
25 |
+
|
26 |
+
$(function(){
|
27 |
+
$('.variation_checkboxes').on( 'click', '.variation-set', event_toggle_checkboxes );
|
28 |
+
$('.variation_checkboxes').on( 'click', 'a.expand', event_toggle_children );
|
29 |
+
$('.variation_checkboxes').on( 'click', '.selectit input:checkbox', event_display_apply_variations );
|
30 |
+
$('.variation_checkboxes').on( 'click', '.children input:checkbox', event_toggle_parent );
|
31 |
+
|
32 |
+
$('a.add_variation_set_action').on( 'click', event_add_new_variation_set );
|
33 |
+
$('#add-new-variation-set .button').on( 'click', event_variation_set_add );
|
34 |
+
$('#add-new-variation-set input[type="text"]').on( 'keypress', event_variation_set_inputs_keypress );
|
35 |
+
$('#add-new-variation-set input[type="text"]').on( 'focus', event_variation_set_inputs_focus );
|
36 |
+
$('#add-new-variation-set input[type="text"]').on( 'blur', event_variation_set_inputs_blur );
|
37 |
+
|
38 |
+
$('.wpsc-product-variation-thumbnail a').on( 'click', event_variation_thumbnail_click );
|
39 |
+
$('.wpsc-bulk-edit').on( 'change', 'input.wpsc-bulk-edit-fields', event_bulk_edit_checkboxes_changed );
|
40 |
+
$('.wpsc-bulk-edit').on( 'keyup', 'input[type="text"]', event_bulk_edit_textboxes_keyup );
|
41 |
+
});
|
42 |
+
|
43 |
+
var event_bulk_edit_textboxes_keyup = function() {
|
44 |
+
var t = $(this),
|
45 |
+
checkbox = t.siblings('input.wpsc-bulk-edit-fields')[0];
|
46 |
+
|
47 |
+
if ($.trim(t.val()) !== '') {
|
48 |
+
checkbox.checked = true;
|
49 |
+
}
|
50 |
+
};
|
51 |
+
|
52 |
+
var event_bulk_edit_checkboxes_changed = function() {
|
53 |
+
var t = $(this);
|
54 |
+
if (t[0].checked) {
|
55 |
+
t.siblings('input[type="text"]').focus();
|
56 |
+
}
|
57 |
+
};
|
58 |
+
|
59 |
+
var event_variation_thumbnail_click = function() {
|
60 |
+
var t = $( this ), postId = t.data( 'id' ), nonce = t.data( 'nonce' );
|
61 |
+
|
62 |
+
$.wpsc_post(
|
63 |
+
{
|
64 |
+
action: 'get_variation_gallery',
|
65 |
+
nonce: nonce,
|
66 |
+
id: postId
|
67 |
+
},
|
68 |
+
function( response ) {
|
69 |
+
if ( ! response.is_successful ) {
|
70 |
+
alert( response.error.messages.join( '\n' ) );
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
|
74 |
+
window.parent.WPSC_Media.open({
|
75 |
+
id: postId,
|
76 |
+
featuredId: response.obj.featuredId,
|
77 |
+
models: response.obj.models,
|
78 |
+
galleryUpdateNonce: t.data( 'save-gallery-nonce' ),
|
79 |
+
galleryGetNonce: t.data( 'get-gallery-nonce' ),
|
80 |
+
featuredNonce: t.data( 'featured-nonce' )
|
81 |
+
});
|
82 |
+
}
|
83 |
+
);
|
84 |
+
|
85 |
+
return false;
|
86 |
+
};
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Save new variation set using AJAX
|
90 |
+
* @since 3.8.8
|
91 |
+
*/
|
92 |
+
var event_variation_set_add = function() {
|
93 |
+
var form = $('#add-new-variation-set');
|
94 |
+
|
95 |
+
form.find('.error').removeClass('error');
|
96 |
+
|
97 |
+
form.find('input[type="text"]').each(function(){
|
98 |
+
var t = $(this);
|
99 |
+
if (t.val() === '') {
|
100 |
+
t.parent().addClass('error');
|
101 |
+
}
|
102 |
+
});
|
103 |
+
|
104 |
+
if (form.find('.error').size() === 0) {
|
105 |
+
var spinner = $(this).siblings('.ajax-feedback'),
|
106 |
+
post_data = {
|
107 |
+
action : 'add_variation_set',
|
108 |
+
variation_set : $('#new-variation-set-name').val(),
|
109 |
+
variants : $('#new-variants').val(),
|
110 |
+
post_id : WPSC_Product_Variations.product_id,
|
111 |
+
nonce : WPSC_Product_Variations.add_variation_set_nonce
|
112 |
+
},
|
113 |
+
ajax_callback = function(response) {
|
114 |
+
var checklist, color, set_id, existing_set, content;
|
115 |
+
if (response.is_successful) {
|
116 |
+
checklist = $('.variation_checkboxes');
|
117 |
+
content = $(response.obj.content);
|
118 |
+
set_id = content.attr('id');
|
119 |
+
existing_set = checklist.find('#' + set_id);
|
120 |
+
if (existing_set.size() > 0) {
|
121 |
+
existing_set.find('.children').append(content.find('.children .ajax'));
|
122 |
+
} else {
|
123 |
+
checklist.append(content);
|
124 |
+
}
|
125 |
+
|
126 |
+
color = checklist.find('li').css('backgroundColor') || '#FFFFFF';
|
127 |
+
checklist.find('.ajax').
|
128 |
+
animate({ backgroundColor: '#FFFF33' }, 'fast').
|
129 |
+
animate({ backgroundColor: color }, 'fast', function(){
|
130 |
+
$(this).css('backgroundColor', 'transparent');
|
131 |
+
}).
|
132 |
+
removeClass('ajax');
|
133 |
+
} else {
|
134 |
+
alert(response.error.messages.join('\n'));
|
135 |
+
}
|
136 |
+
form.hide().find('input:text').val('');
|
137 |
+
form.find('label').show().css('opacity', '1');
|
138 |
+
spinner.toggleClass('ajax-feedback-active');
|
139 |
+
};
|
140 |
+
|
141 |
+
spinner.toggleClass('ajax-feedback-active');
|
142 |
+
$.wpsc_post(post_data, ajax_callback);
|
143 |
+
}
|
144 |
+
|
145 |
+
return false;
|
146 |
+
};
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Dim the new variation set inputs' labels when focused.
|
150 |
+
* @since 3.8.8
|
151 |
+
*/
|
152 |
+
var event_variation_set_inputs_focus = function() {
|
153 |
+
$(this).siblings('label').animate({opacity:0.5}, 150);
|
154 |
+
};
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Restore opacity to the "new variation set" inputs' labels when blurred.
|
158 |
+
* @since 3.8.8
|
159 |
+
*/
|
160 |
+
var event_variation_set_inputs_blur = function() {
|
161 |
+
var t = $(this);
|
162 |
+
if (t.val() === '') {
|
163 |
+
t.siblings('label').show().animate({opacity:1}, 150);
|
164 |
+
}
|
165 |
+
};
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Remove class "error" when something is typed into the new variation set textboxes
|
169 |
+
* @since 3.8.8
|
170 |
+
*/
|
171 |
+
var event_variation_set_inputs_keypress = function(e) {
|
172 |
+
var code = e.keyCode ? e.keyCode : e.which;
|
173 |
+
if (code === 13) {
|
174 |
+
$('#add-new-variation-set .button').trigger('click');
|
175 |
+
e.preventDefault();
|
176 |
+
} else {
|
177 |
+
$(this).siblings('label').hide().removeClass('error');
|
178 |
+
}
|
179 |
+
};
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Show the Add Variation Set form and focus on the first text field
|
183 |
+
* @since 3.8.8
|
184 |
+
*/
|
185 |
+
var event_add_new_variation_set = function() {
|
186 |
+
$('#add-new-variation-set').show().find('#new-variation-set-name').focus();
|
187 |
+
window.parent.wpsc_resize_iframe();
|
188 |
+
};
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Deselect or Select all children variations when variation set is ticked.
|
192 |
+
* @since 3.8.8
|
193 |
+
*/
|
194 |
+
var event_toggle_checkboxes = function() {
|
195 |
+
var t = $(this), checked;
|
196 |
+
|
197 |
+
if (t.is(':checked')) {
|
198 |
+
checked = true;
|
199 |
+
} else {
|
200 |
+
checked = false;
|
201 |
+
}
|
202 |
+
|
203 |
+
t.closest('li').find('.children input:checkbox').each(function(){
|
204 |
+
this.checked = checked;
|
205 |
+
});
|
206 |
+
|
207 |
+
if (checked !== t.closest('li').hasClass('expanded')) {
|
208 |
+
t.parent().siblings('.expand').trigger('click');
|
209 |
+
}
|
210 |
+
};
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Show children variant checkboxes when the triangle is clicked.
|
214 |
+
* @since 3.8.8
|
215 |
+
*/
|
216 |
+
var event_toggle_children = function() {
|
217 |
+
var t = $(this);
|
218 |
+
t.siblings('ul').toggle();
|
219 |
+
resize_iframe();
|
220 |
+
t.closest('li').toggleClass('expanded');
|
221 |
+
return false;
|
222 |
+
};
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Show the update variation button.
|
226 |
+
* @since 3.8.8
|
227 |
+
*/
|
228 |
+
var event_display_apply_variations = function() {
|
229 |
+
$('.update-variations').fadeIn(150);
|
230 |
+
};
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Deselect the variation set if none of its variants are selected.
|
234 |
+
* Or select the variation set when at least one of its variants is selected.
|
235 |
+
* @since 3.8.8
|
236 |
+
*/
|
237 |
+
var event_toggle_parent = function() {
|
238 |
+
var t = $(this),
|
239 |
+
parent = t.closest('.children').parent(),
|
240 |
+
parent_checkbox = parent.find('.variation-set');
|
241 |
+
|
242 |
+
if (this.checked) {
|
243 |
+
parent_checkbox[0].checked = true;
|
244 |
+
} else if (parent.find('.children input:checked').size() === 0) {
|
245 |
+
parent_checkbox[0].checked = false;
|
246 |
+
parent.find('.expand').trigger('click');
|
247 |
+
}
|
248 |
+
};
|
249 |
+
})(jQuery);
|
trunk/wpsc-admin/js/purchase-log-action-links.js
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global WPSC_Purchase_Log_Action_Links, alert */
|
2 |
+
( function( $ ) {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Purchase Log Action Links
|
6 |
+
*/
|
7 |
+
$.extend( WPSC_Purchase_Log_Action_Links, {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Setup purchase log action links and event handlers.
|
11 |
+
*
|
12 |
+
* @since 3.9.0
|
13 |
+
*/
|
14 |
+
init : function() {
|
15 |
+
|
16 |
+
$( function() {
|
17 |
+
var wrapper = $( '#wpsc_purchlogitems_links ul' );
|
18 |
+
|
19 |
+
// Add spinners to AJAX links
|
20 |
+
wrapper.find( 'a.wpsc-purchlog-action-link.is-ajax' ).each( function() {
|
21 |
+
$( this ).prepend( $( '<span class="spinner is-active" />' ) );
|
22 |
+
} );
|
23 |
+
|
24 |
+
wrapper.on( 'click', 'a.wpsc-purchlog-action-link.is-ajax', WPSC_Purchase_Log_Action_Links.event_ajax_link_clicked );
|
25 |
+
} );
|
26 |
+
|
27 |
+
},
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Handle purchase log action link click.
|
31 |
+
*
|
32 |
+
* @since 3.9.0
|
33 |
+
*/
|
34 |
+
event_ajax_link_clicked : function( e ) {
|
35 |
+
|
36 |
+
var action = $( this ).data( 'purchase-log-action' );
|
37 |
+
var nonce = $( this ).data( 'nonce' );
|
38 |
+
|
39 |
+
if ( action ) {
|
40 |
+
|
41 |
+
// Only do AJAX request if not already doing it.
|
42 |
+
if ( ! $( this ).hasClass( 'doing' ) ) {
|
43 |
+
|
44 |
+
var post_data = {
|
45 |
+
'action' : 'purchase_log_action_link',
|
46 |
+
'purchase_log_action_link' : action,
|
47 |
+
'purchase_log_action_nonce' : nonce,
|
48 |
+
'log_id' : WPSC_Purchase_Log_Action_Links.log_id,
|
49 |
+
'nonce' : WPSC_Purchase_Log_Action_Links.purchase_log_action_link_nonce
|
50 |
+
};
|
51 |
+
|
52 |
+
$( this ).addClass( 'doing' );
|
53 |
+
$.wpsc_post( post_data, WPSC_Purchase_Log_Action_Links.ajax_callback );
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
e.preventDefault();
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
},
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Handle purchase log action AJAX response.
|
65 |
+
*
|
66 |
+
* @since 3.9.0
|
67 |
+
*/
|
68 |
+
ajax_callback : function( response ) {
|
69 |
+
var dashicon, dashicon_class;
|
70 |
+
|
71 |
+
// If AJAX successful and purchase log action successful.
|
72 |
+
if ( response.is_successful && response.obj.success ) {
|
73 |
+
|
74 |
+
dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link-' + response.obj.purchase_log_action_link + ' .dashicons' );
|
75 |
+
dashicon_class = dashicon.attr( 'class' );
|
76 |
+
|
77 |
+
// Successful notification.
|
78 |
+
dashicon.removeClass().addClass( 'dashicons dashicons-yes' );
|
79 |
+
setTimeout( function() {
|
80 |
+
dashicon.removeClass().addClass( dashicon_class );
|
81 |
+
}, 3000 );
|
82 |
+
|
83 |
+
// Remove spinner
|
84 |
+
$( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing' ).removeClass( 'doing' );
|
85 |
+
|
86 |
+
} else {
|
87 |
+
|
88 |
+
// Ideally we'd always like to know which link was clicked, but we don't
|
89 |
+
// so just clear all spinners and only clear specific spinner if AJAX response was processed.
|
90 |
+
|
91 |
+
dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing .dashicons' );
|
92 |
+
|
93 |
+
if ( response.is_successful ) {
|
94 |
+
dashicon = $( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link-' + response.obj.purchase_log_action_link + ' .dashicons' );
|
95 |
+
}
|
96 |
+
dashicon_class = dashicon.attr( 'class' );
|
97 |
+
|
98 |
+
if ( response.obj.success != null ) {
|
99 |
+
|
100 |
+
// Failure notification.
|
101 |
+
dashicon.removeClass().addClass( 'dashicons dashicons-no' );
|
102 |
+
setTimeout( function() {
|
103 |
+
dashicon.removeClass().addClass( dashicon_class );
|
104 |
+
}, 3000 );
|
105 |
+
|
106 |
+
} else {
|
107 |
+
dashicon.removeClass().addClass( dashicon_class );
|
108 |
+
}
|
109 |
+
|
110 |
+
// Remove spinner.
|
111 |
+
$( '#wpsc_purchlogitems_links ul a.wpsc-purchlog-action-link.doing' ).removeClass( 'doing' );
|
112 |
+
|
113 |
+
// Show error message.
|
114 |
+
if ( typeof response.error !== 'undefined' ) {
|
115 |
+
alert( response.error.messages.join( "\n" ) );
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
} );
|
123 |
+
|
124 |
+
} )( jQuery );
|
125 |
+
|
126 |
+
WPSC_Purchase_Log_Action_Links.init();
|
trunk/wpsc-admin/js/purchase-logs.js
ADDED
@@ -0,0 +1,660 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
window.WPSC_Purchase_Logs_Admin = window.WPSC_Purchase_Logs_Admin || {};
|
2 |
+
|
3 |
+
( function( window, document, $, wpsc, undefined ) {
|
4 |
+
'use strict';
|
5 |
+
var ENTER = 13;
|
6 |
+
var ESCAPE = 27;
|
7 |
+
var BR = "\n";
|
8 |
+
var $c = {};
|
9 |
+
var $id = function( id ) {
|
10 |
+
return $( document.getElementById( id ) );
|
11 |
+
};
|
12 |
+
|
13 |
+
var admin = {
|
14 |
+
blur_timeout : null,
|
15 |
+
reset_textbox_width : true,
|
16 |
+
$ : $c
|
17 |
+
};
|
18 |
+
|
19 |
+
admin.cache = function() {
|
20 |
+
$c.body = $( document.body );
|
21 |
+
$c.wrapper = $( 'table.purchase-logs' );
|
22 |
+
$c.details = $( '.log-details-box' );
|
23 |
+
$c.editDetails = $id( 'edit-shipping-billing' );
|
24 |
+
$c.editActions = $c.editDetails.find( '.wpsc-form-actions' );
|
25 |
+
$c.log = $id( 'wpsc_items_ordered' );
|
26 |
+
$c.discount_data = $id( 'wpsc_discount_data' );
|
27 |
+
$c.total_taxes = $id( 'wpsc_total_taxes' );
|
28 |
+
$c.total_shipping = $id( 'wpsc_total_shipping' );
|
29 |
+
$c.final_total = $id( 'wpsc_final_total' );
|
30 |
+
$c.spinner = $c.final_total.find( 'td:last .spinner' );
|
31 |
+
$c.billingForm = $id( 'wpsc-checkout-form-billing' );
|
32 |
+
$c.shippingForm = $id( 'wpsc-checkout-form-shipping' );
|
33 |
+
$c.copyForm = $id( 'wpsc-terms-and-conditions-control' );
|
34 |
+
$c.notes = $id( 'purchlogs_notes' );
|
35 |
+
};
|
36 |
+
|
37 |
+
admin.init = function() {
|
38 |
+
admin.cache();
|
39 |
+
|
40 |
+
if ( $c.wrapper.length ) {
|
41 |
+
$c.wrapper.on( 'change' , '.wpsc-purchase-log-status' , admin.event_log_status_change );
|
42 |
+
$c.wrapper.on( 'focus' , '.wpsc-purchase-log-tracking-id', admin.event_tracking_id_focused );
|
43 |
+
$c.wrapper.on( 'click' , '.column-tracking a.add' , admin.event_button_add_clicked );
|
44 |
+
$c.wrapper.on( 'blur' , '.wpsc-purchase-log-tracking-id', admin.event_tracking_id_blurred );
|
45 |
+
$c.wrapper.on( 'click' , '.column-tracking a.save' , admin.event_button_save_clicked );
|
46 |
+
$c.wrapper.on( 'click' , '.column-tracking .send-email a', admin.event_button_send_email_clicked );
|
47 |
+
$c.wrapper.on( 'keypress' , '.wpsc-purchase-log-tracking-id', admin.event_enter_key_pressed );
|
48 |
+
$c.wrapper.on( 'mousedown', '.column-tracking a.save' , admin.event_disable_textbox_resize );
|
49 |
+
$c.wrapper.on( 'focus' , '.column-tracking a.save' , admin.event_disable_textbox_resize );
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( $c.log.length ) {
|
53 |
+
|
54 |
+
admin.product_search = admin.init_search_view();
|
55 |
+
|
56 |
+
$c.log
|
57 |
+
.on( 'click', '.wpsc-remove-item-button', admin.remove_item )
|
58 |
+
.on( 'keypress', '.wpsc_item_qty', admin.maybe_update_qty )
|
59 |
+
.on( 'change', '.wpsc_item_qty', admin.update_qty )
|
60 |
+
.on( 'click', '.wpsc-add-item-button', function() { admin.product_search.trigger( 'open' ); } )
|
61 |
+
.on( 'click', '.refund-items', admin.toggleRefundsUI )
|
62 |
+
.on( 'click', 'button.do-api-refund, button.do-manual-refund', admin.refundItem );
|
63 |
+
$c.body.on( 'click', '.ui-find-overlay', function() { admin.product_search.trigger( 'close' ); } );
|
64 |
+
|
65 |
+
$c.editDetails
|
66 |
+
.on( 'submit', 'form', admin.handleEditDetails )
|
67 |
+
.on( 'click', '.button-secondary', admin.toggleEditDetails );
|
68 |
+
|
69 |
+
$c.details
|
70 |
+
.on( 'click', '.edit-log-details', admin.toggleEditDetails );
|
71 |
+
|
72 |
+
$c.notes
|
73 |
+
.on( 'submit' , '#note-submit-form' , admin.addNote )
|
74 |
+
.on( 'keydown', '#note-submit-form' , admin.commandEnterAddNote )
|
75 |
+
.on( 'click' , '.wpsc-remove-note-button', admin.deleteNote );
|
76 |
+
|
77 |
+
window.postboxes.add_postbox_toggles( window.pagenow );
|
78 |
+
|
79 |
+
$c.editActions.prepend( '<button type="button" class="button-secondary">'+ wpsc.strings.cancel_btn +'</button>' );
|
80 |
+
}
|
81 |
+
|
82 |
+
};
|
83 |
+
|
84 |
+
admin.toggleRefundsUI = function() {
|
85 |
+
$( '.wpsc-refund-ui' ).toggle();
|
86 |
+
};
|
87 |
+
|
88 |
+
admin.refundItem = function() {
|
89 |
+
var $this = $( this );
|
90 |
+
var $spinner = $this.siblings('.ajax-feedback');
|
91 |
+
var api_refund = $this.is( '.do-api-refund' );
|
92 |
+
var refund_string = api_refund ? wpsc.strings.confirm_refund_order : wpsc.strings.confirm_refund_order_manually;
|
93 |
+
|
94 |
+
if ( ! window.confirm( refund_string ) ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
var refund_reason = $( 'input#refund_reason' ).val();
|
99 |
+
var refund_amount = $( 'input#refund_amount' ).val();
|
100 |
+
|
101 |
+
var data = {
|
102 |
+
action : 'purchase_log_refund_items',
|
103 |
+
order_id : wpsc.log_id,
|
104 |
+
refund_reason : refund_reason,
|
105 |
+
refund_amount : refund_amount,
|
106 |
+
api_refund : api_refund,
|
107 |
+
nonce : wpsc.purchase_log_refund_items_nonce
|
108 |
+
};
|
109 |
+
|
110 |
+
var ajax_callback = function( response ) {
|
111 |
+
$spinner.toggleClass( 'ajax-feedback-active' );
|
112 |
+
|
113 |
+
if ( ! response.is_successful ) {
|
114 |
+
if ( response.error ) {
|
115 |
+
window.alert( response.error.messages.join( BR ) );
|
116 |
+
}
|
117 |
+
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
window.location.href = window.location.href;
|
121 |
+
};
|
122 |
+
|
123 |
+
$spinner.toggleClass( 'ajax-feedback-active' );
|
124 |
+
|
125 |
+
$.wpsc_post( data, ajax_callback );
|
126 |
+
};
|
127 |
+
|
128 |
+
admin.event_enter_key_pressed = function(evt) {
|
129 |
+
var code = evt.keyCode ? evt.keyCode : evt.which;
|
130 |
+
if ( ENTER === code ) {
|
131 |
+
$(this).siblings('.save').click();
|
132 |
+
evt.preventDefault();
|
133 |
+
}
|
134 |
+
};
|
135 |
+
|
136 |
+
admin.event_button_send_email_clicked = function() {
|
137 |
+
var $this = $(this);
|
138 |
+
|
139 |
+
var post_data = {
|
140 |
+
action : 'purchase_log_send_tracking_email',
|
141 |
+
log_id : $this.closest('div').data('log-id'),
|
142 |
+
nonce : wpsc.purchase_log_send_tracking_email_nonce
|
143 |
+
};
|
144 |
+
|
145 |
+
var ajax_callback = function(response) {
|
146 |
+
if (! response.is_successful) {
|
147 |
+
window.alert(response.error.messages.join(BR));
|
148 |
+
$this.show().siblings('em').remove();
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
$this.siblings('em').addClass('sent').text(wpsc.sent_message);
|
152 |
+
$this.remove();
|
153 |
+
};
|
154 |
+
|
155 |
+
$this.hide().after('<em>' + wpsc.sending_message + '</em>');
|
156 |
+
$.wpsc_post(post_data, ajax_callback);
|
157 |
+
|
158 |
+
return false;
|
159 |
+
};
|
160 |
+
|
161 |
+
admin.event_button_save_clicked = function() {
|
162 |
+
var $this = $(this);
|
163 |
+
var $textbox = $this.siblings('.wpsc-purchase-log-tracking-id');
|
164 |
+
var $spinner = $this.siblings('.ajax-feedback');
|
165 |
+
|
166 |
+
var post_data = {
|
167 |
+
action : 'purchase_log_save_tracking_id',
|
168 |
+
value : $textbox.val(),
|
169 |
+
log_id : $this.parent().data('log-id'),
|
170 |
+
nonce : wpsc.purchase_log_save_tracking_id_nonce
|
171 |
+
};
|
172 |
+
|
173 |
+
var ajax_callback = function(response) {
|
174 |
+
$spinner.toggleClass('ajax-feedback-active');
|
175 |
+
$textbox.blur();
|
176 |
+
if (! response.is_successful) {
|
177 |
+
window.alert(response.error.messages.join(BR));
|
178 |
+
return;
|
179 |
+
}
|
180 |
+
$this.parent().removeClass('empty');
|
181 |
+
admin.reset_tracking_id_width($this.siblings('.wpsc-purchase-log-tracking-id'));
|
182 |
+
};
|
183 |
+
|
184 |
+
$this.hide();
|
185 |
+
$spinner.toggleClass('ajax-feedback-active');
|
186 |
+
$textbox.width(160);
|
187 |
+
|
188 |
+
$.wpsc_post(post_data, ajax_callback);
|
189 |
+
|
190 |
+
return false;
|
191 |
+
};
|
192 |
+
|
193 |
+
admin.event_disable_textbox_resize = function() {
|
194 |
+
admin.reset_textbox_width = false;
|
195 |
+
};
|
196 |
+
|
197 |
+
admin.event_button_add_clicked = function() {
|
198 |
+
$(this).siblings('.wpsc-purchase-log-tracking-id').trigger('focus');
|
199 |
+
return false;
|
200 |
+
};
|
201 |
+
|
202 |
+
admin.reset_tracking_id_width = function($obj) {
|
203 |
+
var reset_width = function() {
|
204 |
+
if (admin.reset_textbox_width) {
|
205 |
+
$obj.siblings('a.save').hide();
|
206 |
+
$obj.width('');
|
207 |
+
if ($obj.val() === '') {
|
208 |
+
$obj.siblings('.add').show();
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
admin.reset_textbox_width = true;
|
213 |
+
};
|
214 |
+
|
215 |
+
admin.blur_timeout = setTimeout(reset_width, 100);
|
216 |
+
};
|
217 |
+
|
218 |
+
admin.event_tracking_id_blurred = function() {
|
219 |
+
admin.reset_tracking_id_width( $(this) );
|
220 |
+
};
|
221 |
+
|
222 |
+
admin.event_tracking_id_focused = function() {
|
223 |
+
var $this = $(this);
|
224 |
+
$this.width(128);
|
225 |
+
$this.siblings('a.save').show();
|
226 |
+
$this.siblings('a.add').hide();
|
227 |
+
};
|
228 |
+
|
229 |
+
admin.event_log_status_change = function() {
|
230 |
+
var $this = $(this);
|
231 |
+
var post_data = {
|
232 |
+
nonce : wpsc.change_purchase_log_status_nonce,
|
233 |
+
action : 'change_purchase_log_status',
|
234 |
+
id : $this.data('log-id'),
|
235 |
+
new_status : $this.val(),
|
236 |
+
m : wpsc.current_filter,
|
237 |
+
status : wpsc.current_view,
|
238 |
+
paged : wpsc.current_page,
|
239 |
+
_wp_http_referer : window.location.href
|
240 |
+
};
|
241 |
+
var spinner = $this.siblings('.ajax-feedback');
|
242 |
+
spinner.addClass('ajax-feedback-active');
|
243 |
+
var ajax_callback = function(response) {
|
244 |
+
if (! response.is_successful) {
|
245 |
+
window.alert(response.error.messages.join(BR));
|
246 |
+
return;
|
247 |
+
}
|
248 |
+
spinner.removeClass('ajax-feedback-active');
|
249 |
+
$('ul.subsubsub').replaceWith(response.obj.views);
|
250 |
+
$('.tablenav.top').replaceWith(response.obj.tablenav_top);
|
251 |
+
$('.tablenav.bottom').replaceWith(response.obj.tablenav_bottom);
|
252 |
+
};
|
253 |
+
|
254 |
+
$.wpsc_post(post_data, ajax_callback);
|
255 |
+
};
|
256 |
+
|
257 |
+
admin.remove_item = function() {
|
258 |
+
if ( ! window.confirm( wpsc.strings.confirm_delete_item ) ) {
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
|
262 |
+
var $this = $( this );
|
263 |
+
var $row = $this.parents( '.purchase-log-line-item' );
|
264 |
+
var args = {
|
265 |
+
action : 'remove_log_item',
|
266 |
+
log_id : wpsc.log_id,
|
267 |
+
item_id : $row.data( 'id' ),
|
268 |
+
nonce : wpsc.remove_log_item_nonce
|
269 |
+
};
|
270 |
+
|
271 |
+
var ajax_callback = function(response) {
|
272 |
+
if ( ! response.is_successful ) {
|
273 |
+
if ( response.error ) {
|
274 |
+
window.alert( response.error.messages.join( BR ) );
|
275 |
+
}
|
276 |
+
|
277 |
+
return;
|
278 |
+
}
|
279 |
+
|
280 |
+
admin.update_totals( response.obj );
|
281 |
+
|
282 |
+
$row.fadeOut( 600, function() {
|
283 |
+
$( this ).remove();
|
284 |
+
} );
|
285 |
+
};
|
286 |
+
|
287 |
+
$c.spinner.addClass( 'is-active' );
|
288 |
+
|
289 |
+
$.wpsc_post( args, ajax_callback );
|
290 |
+
};
|
291 |
+
|
292 |
+
admin.maybe_update_qty = function( evt ) {
|
293 |
+
var code = evt.keyCode ? evt.keyCode : evt.which;
|
294 |
+
if ( ENTER === code ) {
|
295 |
+
evt.preventDefault();
|
296 |
+
admin.update_qty.call( this, evt );
|
297 |
+
}
|
298 |
+
};
|
299 |
+
|
300 |
+
admin.update_qty = function( evt ) {
|
301 |
+
if ( 'keypress' === evt.type ) {
|
302 |
+
admin.update_qty.disable_change = true;
|
303 |
+
}
|
304 |
+
|
305 |
+
if ( 'change' === evt.type && true === admin.update_qty.disable_change ) {
|
306 |
+
admin.update_qty.disable_change = false;
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
var $this = $( this );
|
311 |
+
var $row = $this.parents( '.purchase-log-line-item' );
|
312 |
+
var args = {
|
313 |
+
action : 'update_log_item_qty',
|
314 |
+
log_id : wpsc.log_id,
|
315 |
+
item_id : $row.data( 'id' ),
|
316 |
+
qty : $this.val(),
|
317 |
+
nonce : wpsc.update_log_item_qty_nonce
|
318 |
+
};
|
319 |
+
|
320 |
+
if ( 0 === parseInt( args.qty, 10 ) ) {
|
321 |
+
return $row.find( '.wpsc-remove-item-button' ).trigger( 'click' );
|
322 |
+
}
|
323 |
+
|
324 |
+
var ajax_callback = function(response) {
|
325 |
+
if ( ! response.is_successful ) {
|
326 |
+
if ( response.error ) {
|
327 |
+
window.alert( response.error.messages.join( BR ) );
|
328 |
+
}
|
329 |
+
|
330 |
+
return;
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( response.obj.final_total ) {
|
334 |
+
admin.update_totals( response.obj );
|
335 |
+
}
|
336 |
+
};
|
337 |
+
|
338 |
+
$c.spinner.addClass( 'is-active' );
|
339 |
+
$.wpsc_post( args, ajax_callback );
|
340 |
+
};
|
341 |
+
|
342 |
+
admin.update_totals = function( data ) {
|
343 |
+
$c.discount_data.find( 'td' ).first().html( data.discount_data );
|
344 |
+
$c.discount_data.find( 'td' ).last().html( data.discount );
|
345 |
+
|
346 |
+
if ( $c.total_taxes.length ) {
|
347 |
+
$c.total_taxes.find( 'td' ).last().html( data.total_taxes );
|
348 |
+
}
|
349 |
+
|
350 |
+
$c.total_shipping.find( 'td' ).last().html( data.total_shipping );
|
351 |
+
$c.final_total.find( 'td:last span' ).html( data.final_total );
|
352 |
+
|
353 |
+
$c.spinner.removeClass( 'is-active' );
|
354 |
+
|
355 |
+
$.each( data.quantities, function( id, qty ) {
|
356 |
+
qty = parseInt( qty, 10 );
|
357 |
+
var $input = $c.log.find( '#purchase-log-item-' + id + ' .wpsc_item_qty' );
|
358 |
+
var val = $input.val();
|
359 |
+
var $price, $new_price;
|
360 |
+
|
361 |
+
if ( parseInt( val, 10 ) !== parseInt( qty, 10 ) ) {
|
362 |
+
$input.val( qty );
|
363 |
+
}
|
364 |
+
|
365 |
+
$price = $c.log.find( '#purchase-log-item-' + id + ' .amount .pricedisplay' );
|
366 |
+
$new_price = $( data.htmls[ id ] ).find( '.amount .pricedisplay' );
|
367 |
+
if ( $price.length && $new_price.length ) {
|
368 |
+
$price.text( $new_price.text() );
|
369 |
+
}
|
370 |
+
} );
|
371 |
+
};
|
372 |
+
|
373 |
+
admin.toggleEditDetails = function( evt ) {
|
374 |
+
evt.preventDefault();
|
375 |
+
|
376 |
+
var strings = window.WPSC.copyBilling.strings;
|
377 |
+
|
378 |
+
$c.editDetails.slideToggle( 400, function() {
|
379 |
+
if ( $( evt.target ).hasClass( 'edit-shipping-details' ) ) {
|
380 |
+
$c.billingForm.find( 'h2' ).replaceWith( strings.billing );
|
381 |
+
$c.shippingForm.removeClass( 'ui-helper-hidden' );
|
382 |
+
|
383 |
+
} else if ( $c.copyForm.is( ':checked' ) ) {
|
384 |
+
$c.billingForm.find( 'h2' ).replaceWith( strings.billing_and_shipping );
|
385 |
+
$c.shippingForm.addClass( 'ui-helper-hidden' );
|
386 |
+
}
|
387 |
+
} );
|
388 |
+
};
|
389 |
+
|
390 |
+
admin.handleEditDetails = function( evt ) {
|
391 |
+
evt.preventDefault();
|
392 |
+
|
393 |
+
var args = {
|
394 |
+
action : 'edit_contact_details',
|
395 |
+
log_id : wpsc.log_id,
|
396 |
+
nonce : wpsc.edit_contact_details_nonce,
|
397 |
+
fields : $c.editDetails.find( 'form' ).serialize()
|
398 |
+
};
|
399 |
+
|
400 |
+
var ajax_callback = function( response ) {
|
401 |
+
$c.editActions.find( '.spinner' ).remove();
|
402 |
+
|
403 |
+
if ( ! response.is_successful ) {
|
404 |
+
if ( response.error ) {
|
405 |
+
window.alert( response.error.messages.join( BR ) );
|
406 |
+
}
|
407 |
+
|
408 |
+
return;
|
409 |
+
}
|
410 |
+
|
411 |
+
$id( 'wpsc-shipping-details' ).html( response.obj.shipping );
|
412 |
+
$id( 'wpsc-billing-details' ).html( response.obj.billing );
|
413 |
+
$id( 'wpsc-payment-details' ).html( response.obj.payment );
|
414 |
+
|
415 |
+
// Trigger the edit form to slide closed.
|
416 |
+
admin.toggleEditDetails( evt );
|
417 |
+
};
|
418 |
+
|
419 |
+
$c.editActions.prepend( '<div class="spinner is-active"></div>' );
|
420 |
+
|
421 |
+
$.wpsc_post( args, ajax_callback );
|
422 |
+
};
|
423 |
+
|
424 |
+
admin.commandEnterAddNote = function( evt ) {
|
425 |
+
if ( ( evt.metaKey || evt.ctrlKey ) && evt.keyCode === ENTER ) {
|
426 |
+
admin.addNote( evt );
|
427 |
+
}
|
428 |
+
};
|
429 |
+
|
430 |
+
admin.addNote = function( evt ) {
|
431 |
+
evt.preventDefault();
|
432 |
+
|
433 |
+
$c.notesText = $c.notesText || $id( 'purchlog_notes' );
|
434 |
+
var args = {
|
435 |
+
action : 'add_note',
|
436 |
+
log_id : wpsc.log_id,
|
437 |
+
nonce : wpsc.add_note_nonce,
|
438 |
+
note : $c.notesText.val()
|
439 |
+
};
|
440 |
+
|
441 |
+
var ajax_callback = function(response) {
|
442 |
+
$c.notes.find( '.spinner' ).removeClass( 'is-active' );
|
443 |
+
|
444 |
+
if ( ! response.is_successful ) {
|
445 |
+
if ( response.error ) {
|
446 |
+
window.alert( response.error.messages.join( BR ) );
|
447 |
+
}
|
448 |
+
|
449 |
+
return;
|
450 |
+
}
|
451 |
+
|
452 |
+
$c.notes.find( '.wpsc-notes' ).prepend( response.obj );
|
453 |
+
$c.notesText.val( '' );
|
454 |
+
};
|
455 |
+
|
456 |
+
$c.notes.find( '.spinner' ).addClass( 'is-active' );
|
457 |
+
|
458 |
+
$.wpsc_post( args, ajax_callback );
|
459 |
+
};
|
460 |
+
|
461 |
+
admin.deleteNote = function( evt ) {
|
462 |
+
evt.preventDefault();
|
463 |
+
|
464 |
+
if ( ! window.confirm( wpsc.strings.confirm_delete_note ) ) {
|
465 |
+
return;
|
466 |
+
}
|
467 |
+
|
468 |
+
var $this = $( this );
|
469 |
+
var $row = $this.parents( '.wpsc-note' );
|
470 |
+
var args = {
|
471 |
+
action : 'delete_note',
|
472 |
+
log_id : wpsc.log_id,
|
473 |
+
nonce : wpsc.delete_note_nonce,
|
474 |
+
note : $row.data( 'id' )
|
475 |
+
};
|
476 |
+
|
477 |
+
var ajax_callback = function(response) {
|
478 |
+
if ( ! response.is_successful ) {
|
479 |
+
if ( response.error ) {
|
480 |
+
$this.find( '.spinner' ).remove();
|
481 |
+
window.alert( response.error.messages.join( BR ) );
|
482 |
+
}
|
483 |
+
|
484 |
+
return;
|
485 |
+
}
|
486 |
+
|
487 |
+
$row.slideUp( 600, function() {
|
488 |
+
$( this ).remove();
|
489 |
+
} );
|
490 |
+
};
|
491 |
+
|
492 |
+
$this.prepend( '<div class="spinner is-active"></div>' );
|
493 |
+
|
494 |
+
$.wpsc_post( args, ajax_callback );
|
495 |
+
};
|
496 |
+
|
497 |
+
admin.init_search_view = function() {
|
498 |
+
var SearchView = window.Backbone.View.extend( {
|
499 |
+
el : '#find-posts',
|
500 |
+
overlaySet : false,
|
501 |
+
$overlay : false,
|
502 |
+
$checked : false,
|
503 |
+
$table : false,
|
504 |
+
template : wp.template( 'wpsc-found-product-rows' ),
|
505 |
+
|
506 |
+
events : {
|
507 |
+
'keypress .find-box-search :input' : 'maybeStartSearch',
|
508 |
+
'keyup #find-posts-input' : 'escClose',
|
509 |
+
'click #find-posts-submit' : 'selectPost',
|
510 |
+
'click #find-posts-search' : 'send',
|
511 |
+
'click #find-posts-close' : 'close'
|
512 |
+
},
|
513 |
+
|
514 |
+
initialize: function() {
|
515 |
+
this.$spinner = this.$el.find( '.find-box-search .spinner' );
|
516 |
+
this.$input = this.$el.find( '#find-posts-input' );
|
517 |
+
this.$response = this.$el.find( '#find-posts-response' );
|
518 |
+
this.$overlay = $( '.ui-find-overlay' );
|
519 |
+
this.$table = $( $id( 'tmpl-wpsc-found-products' ).html() );
|
520 |
+
|
521 |
+
this.listenTo( this, 'open', this.open );
|
522 |
+
this.listenTo( this, 'close', this.close );
|
523 |
+
},
|
524 |
+
|
525 |
+
escClose: function( evt ) {
|
526 |
+
var code = evt.keyCode ? evt.keyCode : evt.which;
|
527 |
+
if ( ESCAPE === code ) {
|
528 |
+
this.close();
|
529 |
+
}
|
530 |
+
},
|
531 |
+
|
532 |
+
close: function() {
|
533 |
+
this.$overlay.hide();
|
534 |
+
this.$el.hide();
|
535 |
+
},
|
536 |
+
|
537 |
+
open: function() {
|
538 |
+
this.$response.html('');
|
539 |
+
|
540 |
+
// WP, why you gotta be like that? (why isn't text in its own dom node?)
|
541 |
+
this.$el.show().find( '#find-posts-head' ).html( wpsc.strings.search_head + '<div id="find-posts-close"></div>' );
|
542 |
+
|
543 |
+
this.$input.focus();
|
544 |
+
|
545 |
+
if ( ! this.$overlay.length ) {
|
546 |
+
$( 'body' ).append( '<div class="ui-find-overlay"></div>' );
|
547 |
+
this.$overlay = $( '.ui-find-overlay' );
|
548 |
+
}
|
549 |
+
|
550 |
+
this.$overlay.show();
|
551 |
+
|
552 |
+
// Pull some results up by default
|
553 |
+
this.send();
|
554 |
+
|
555 |
+
return false;
|
556 |
+
},
|
557 |
+
|
558 |
+
maybeStartSearch: function( evt ) {
|
559 |
+
var code = evt.keyCode ? evt.keyCode : evt.which;
|
560 |
+
if ( ENTER === code ) {
|
561 |
+
this.send();
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
},
|
565 |
+
|
566 |
+
send: function() {
|
567 |
+
|
568 |
+
var that = this;
|
569 |
+
that.$spinner.addClass( 'is-active' );
|
570 |
+
|
571 |
+
var args = {
|
572 |
+
action : 'search_products',
|
573 |
+
search : that.$input.val(),
|
574 |
+
nonce : wpsc.search_products_nonce
|
575 |
+
};
|
576 |
+
|
577 |
+
$.wpsc_post( args )
|
578 |
+
.always( function() {
|
579 |
+
|
580 |
+
that.$spinner.removeClass('is-active');
|
581 |
+
|
582 |
+
} ).done( function( response ) {
|
583 |
+
|
584 |
+
if ( ! response.is_successful ) {
|
585 |
+
if ( response.error ) {
|
586 |
+
that.$response.text( response.error.messages.join( BR ) );
|
587 |
+
}
|
588 |
+
return;
|
589 |
+
}
|
590 |
+
|
591 |
+
that.$table.children( 'tbody' ).html( that.template( { posts : response.obj } ) );
|
592 |
+
that.$response.html( that.$table );
|
593 |
+
|
594 |
+
} ).fail( function() {
|
595 |
+
that.$response.text( that.errortxt );
|
596 |
+
} );
|
597 |
+
},
|
598 |
+
|
599 |
+
selectPost: function( evt ) {
|
600 |
+
evt.preventDefault();
|
601 |
+
|
602 |
+
this.$checked = $( '#find-posts-response input[type="checkbox"]:checked' );
|
603 |
+
|
604 |
+
var checked = this.$checked.map(function() { return this.value; }).get();
|
605 |
+
|
606 |
+
if ( ! checked.length ) {
|
607 |
+
this.close();
|
608 |
+
return;
|
609 |
+
}
|
610 |
+
|
611 |
+
this.handleSelected( checked );
|
612 |
+
},
|
613 |
+
|
614 |
+
handleSelected: function( checked ) {
|
615 |
+
var that = this;
|
616 |
+
|
617 |
+
var existing = $c.log.find( '[data-productid]' ).map( function() {
|
618 |
+
return $( this ).data( 'productid' );
|
619 |
+
} ).get();
|
620 |
+
|
621 |
+
var args = {
|
622 |
+
action : 'add_log_item',
|
623 |
+
product_ids : checked,
|
624 |
+
existing : existing,
|
625 |
+
log_id : wpsc.log_id,
|
626 |
+
nonce : wpsc.add_log_item_nonce
|
627 |
+
};
|
628 |
+
|
629 |
+
var ajax_callback = function(response) {
|
630 |
+
if ( ! response.is_successful ) {
|
631 |
+
if ( response.error ) {
|
632 |
+
window.alert( response.error.messages.join( BR ) );
|
633 |
+
}
|
634 |
+
|
635 |
+
return;
|
636 |
+
}
|
637 |
+
|
638 |
+
$c.log.find( '.wpsc_purchaselog_add_product' ).before( response.obj.html );
|
639 |
+
|
640 |
+
admin.update_totals( response.obj );
|
641 |
+
|
642 |
+
that.close();
|
643 |
+
};
|
644 |
+
|
645 |
+
$c.spinner.addClass( 'is-active' );
|
646 |
+
|
647 |
+
$.wpsc_post( args, ajax_callback );
|
648 |
+
}
|
649 |
+
|
650 |
+
} );
|
651 |
+
|
652 |
+
return new SearchView();
|
653 |
+
};
|
654 |
+
|
655 |
+
|
656 |
+
$.extend( wpsc, admin );
|
657 |
+
|
658 |
+
$( wpsc.init );
|
659 |
+
|
660 |
+
} )( window, document, jQuery, window.WPSC_Purchase_Logs_Admin );
|
trunk/wpsc-admin/js/quick-edit.js
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($) {
|
2 |
+
|
3 |
+
// we create a copy of the WP inline edit post function
|
4 |
+
var $wp_inline_edit = inlineEditPost.edit;
|
5 |
+
|
6 |
+
// and then we overwrite the function with our own code
|
7 |
+
inlineEditPost.edit = function( id ) {
|
8 |
+
|
9 |
+
// "call" the original WP edit function
|
10 |
+
// we don't want to leave WordPress hanging
|
11 |
+
$wp_inline_edit.apply( this, arguments );
|
12 |
+
|
13 |
+
// now we take care of our business
|
14 |
+
|
15 |
+
// get the post ID
|
16 |
+
var $post_id = 0;
|
17 |
+
if ( typeof( id ) == 'object' )
|
18 |
+
$post_id = parseInt( this.getId( id ) );
|
19 |
+
|
20 |
+
if ( $post_id > 0 ) {
|
21 |
+
|
22 |
+
// define the edit row
|
23 |
+
var $edit_row = $( '#edit-' + $post_id );
|
24 |
+
|
25 |
+
// get the data
|
26 |
+
var $stock = $( '#inline_' + $post_id + '_stock' ).text();
|
27 |
+
var $sku = $( '#inline_' + $post_id + '_sku' ).text();
|
28 |
+
var $price = $( '#inline_' + $post_id + '_price' ).text();
|
29 |
+
var $sale_price = $( '#inline_' + $post_id + '_sale_price' ).text();
|
30 |
+
var $weight = $( '#inline_' + $post_id + '_weight' ).text();
|
31 |
+
|
32 |
+
// assign data to quick edit fields
|
33 |
+
$edit_row.find( 'input[name="stock"]' ).val( $stock );
|
34 |
+
$edit_row.find( 'input[name="sku"]' ).val( $sku );
|
35 |
+
$edit_row.find( 'input[name="price"]' ).val( $price );
|
36 |
+
$edit_row.find( 'input[name="sale_price"]' ).val( $sale_price );
|
37 |
+
$edit_row.find( 'input[name="weight"]' ).val( $weight );
|
38 |
+
}
|
39 |
+
};
|
40 |
+
})(jQuery);
|
trunk/wpsc-admin/js/set-post-thumbnail.js
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*global WPSC_Set_Post_Thumbnail, post_id, alert */
|
2 |
+
function WPSetAsThumbnail(id, nonce){
|
3 |
+
var $link = jQuery('a#wp-post-thumbnail-' + id);
|
4 |
+
|
5 |
+
|