Version Description
- (12 Nov 2013) Bulk discount is not applied if coupon code is used.
- HTML markup is allowed in information about the bulk discount offer in Product Description.
- Bulk Discount can be disabled more easily in the Product Options page.
- There are further settings for applying bulk discount to product variations.
Download this release
Release Info
Developer | Rene Puchinger |
Plugin | WooCommerce Bulk Discount |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.12 to 2.1
- lang/wc_bulk_discount-en_GB.mo +0 -0
- lang/wc_bulk_discount-en_GB.po +71 -42
- readme.txt +23 -4
- woocommerce-bulk-discount.php +142 -68
lang/wc_bulk_discount-en_GB.mo
CHANGED
Binary file
|
lang/wc_bulk_discount-en_GB.po
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WooCommerce Bulk Discount\n"
|
4 |
-
"POT-Creation-Date: 2013-
|
5 |
-
"PO-Revision-Date: 2013-
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: Rene Puchinger <info@renepuchinger.com>\n"
|
8 |
"MIME-Version: 1.0\n"
|
@@ -14,32 +14,40 @@ msgstr ""
|
|
14 |
"X-Poedit-SearchPath-0: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-"
|
15 |
"discount\n"
|
16 |
|
17 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
18 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
19 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
20 |
msgid "Bulk Discount"
|
21 |
msgstr "Bulk Discount"
|
22 |
|
23 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
24 |
msgid "Settings"
|
25 |
msgstr "Settings"
|
26 |
|
27 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
28 |
#, php-format
|
29 |
msgid "%s%% bulk discount applied!"
|
30 |
msgstr "%s%% bulk discount applied!"
|
31 |
|
32 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
33 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
34 |
#, php-format
|
35 |
msgid "Incl. %s discount"
|
36 |
msgstr "Incl. %s discount"
|
37 |
|
38 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
39 |
-
msgid "
|
40 |
-
msgstr "
|
41 |
|
42 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
msgid ""
|
44 |
"Optionally enter bulk discount information that will be visible on the "
|
45 |
"product page."
|
@@ -47,37 +55,46 @@ msgstr ""
|
|
47 |
"Optionally enter bulk discount information that will be visible on the "
|
48 |
"product page."
|
49 |
|
50 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
msgid "Quantity (min.)"
|
52 |
msgstr "Quantity (min.)"
|
53 |
|
54 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
55 |
msgid "Enter the minimal quantity for which the discount applies."
|
56 |
msgstr "Enter the minimal quantity for which the discount applies."
|
57 |
|
58 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
59 |
#, php-format
|
60 |
msgid "Discount (%s)"
|
61 |
msgstr "Discount (%s)"
|
62 |
|
63 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
64 |
#, php-format
|
65 |
msgid "Enter the flat discount in %s."
|
66 |
msgstr "Enter the flat discount in %s."
|
67 |
|
68 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
69 |
msgid "Discount (%)"
|
70 |
msgstr "Discount (%)"
|
71 |
|
72 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
73 |
msgid "Enter the discount in percents (Allowed values: 0 to 100)."
|
74 |
msgstr "Enter the discount in percents (Allowed values: 0 to 100)."
|
75 |
|
76 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
77 |
msgid "The following options are specific to product bulk discount."
|
78 |
msgstr "The following options are specific to product bulk discount."
|
79 |
|
80 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
81 |
msgid ""
|
82 |
"After changing the settings, it is recommended to clear all sessions in "
|
83 |
"WooCommerce > System Status > Tools."
|
@@ -85,15 +102,15 @@ msgstr ""
|
|
85 |
"After changing the settings, it is recommended to clear all sessions in "
|
86 |
"WooCommerce > System Status > Tools."
|
87 |
|
88 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
89 |
-
msgid "Bulk Discount enabled"
|
90 |
-
msgstr "Bulk Discount enabled"
|
91 |
|
92 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
93 |
msgid "Discount Type"
|
94 |
msgstr "Discount Type"
|
95 |
|
96 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
97 |
#, php-format
|
98 |
msgid ""
|
99 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
@@ -102,54 +119,66 @@ msgstr ""
|
|
102 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
103 |
"price while Flat Discount deducts fixed amount in %s"
|
104 |
|
105 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
106 |
msgid "Percentage Discount"
|
107 |
msgstr "Percentage Discount"
|
108 |
|
109 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
110 |
msgid "Flat Discount"
|
111 |
msgstr "Flat Discount"
|
112 |
|
113 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
114 |
msgid "Treat product variations separately"
|
115 |
msgstr "Treat product variations separately"
|
116 |
|
117 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
msgid ""
|
119 |
-
"You need to have this option
|
120 |
-
"
|
121 |
msgstr ""
|
122 |
-
"You need to have this option
|
123 |
-
"
|
124 |
|
125 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
126 |
msgid "Show discount information next to cart item price"
|
127 |
msgstr "Show discount information next to cart item price"
|
128 |
|
129 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
130 |
msgid "Applies only to percentage discount."
|
131 |
msgstr "Applies only to percentage discount."
|
132 |
|
133 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
134 |
msgid "Show discount information next to item subtotal price"
|
135 |
msgstr "Show discount information next to item subtotal price"
|
136 |
|
137 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
138 |
msgid "Show discount information next to item subtotal price in order history"
|
139 |
msgstr "Show discount information next to item subtotal price in order history"
|
140 |
|
141 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
142 |
msgid "Includes showing discount in order e-mails and invoices."
|
143 |
msgstr "Includes showing discount in order e-mails and invoices."
|
144 |
|
145 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
146 |
msgid "Optionally enter information about discounts visible on cart page."
|
147 |
msgstr "Optionally enter information about discounts visible on cart page."
|
148 |
|
149 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
150 |
msgid "Optionally change the CSS for old price on cart before discounting."
|
151 |
msgstr "Optionally change the CSS for old price on cart before discounting."
|
152 |
|
153 |
-
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:
|
154 |
msgid "Optionally change the CSS for new price on cart after discounting."
|
155 |
msgstr "Optionally change the CSS for new price on cart after discounting."
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: WooCommerce Bulk Discount\n"
|
4 |
+
"POT-Creation-Date: 2013-11-12 19:12+0100\n"
|
5 |
+
"PO-Revision-Date: 2013-11-12 19:13+0100\n"
|
6 |
"Last-Translator: \n"
|
7 |
"Language-Team: Rene Puchinger <info@renepuchinger.com>\n"
|
8 |
"MIME-Version: 1.0\n"
|
14 |
"X-Poedit-SearchPath-0: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-"
|
15 |
"discount\n"
|
16 |
|
17 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:45
|
18 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:427
|
19 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:681
|
20 |
msgid "Bulk Discount"
|
21 |
msgstr "Bulk Discount"
|
22 |
|
23 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:95
|
24 |
msgid "Settings"
|
25 |
msgstr "Settings"
|
26 |
|
27 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:166
|
28 |
#, php-format
|
29 |
msgid "%s%% bulk discount applied!"
|
30 |
msgstr "%s%% bulk discount applied!"
|
31 |
|
32 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:202
|
33 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:278
|
34 |
#, php-format
|
35 |
msgid "Incl. %s discount"
|
36 |
msgstr "Incl. %s discount"
|
37 |
|
38 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:464
|
39 |
+
msgid "Please fill in the current line before adding new line."
|
40 |
+
msgstr "Please fill in the current line before adding new line."
|
41 |
|
42 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:513
|
43 |
+
msgid "Bulk Discount enabled"
|
44 |
+
msgstr "Bulk Discount enabled"
|
45 |
+
|
46 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:514
|
47 |
+
msgid "Bulk discount special offer text in product description"
|
48 |
+
msgstr "Bulk discount special offer text in product description"
|
49 |
+
|
50 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:514
|
51 |
msgid ""
|
52 |
"Optionally enter bulk discount information that will be visible on the "
|
53 |
"product page."
|
55 |
"Optionally enter bulk discount information that will be visible on the "
|
56 |
"product page."
|
57 |
|
58 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:526
|
59 |
+
msgid "Add discount line"
|
60 |
+
msgstr "Add discount line"
|
61 |
+
|
62 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:528
|
63 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:558
|
64 |
+
msgid "Remove last discount line"
|
65 |
+
msgstr "Remove last discount line"
|
66 |
+
|
67 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:532
|
68 |
msgid "Quantity (min.)"
|
69 |
msgstr "Quantity (min.)"
|
70 |
|
71 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:532
|
72 |
msgid "Enter the minimal quantity for which the discount applies."
|
73 |
msgstr "Enter the minimal quantity for which the discount applies."
|
74 |
|
75 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:537
|
76 |
#, php-format
|
77 |
msgid "Discount (%s)"
|
78 |
msgstr "Discount (%s)"
|
79 |
|
80 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:537
|
81 |
#, php-format
|
82 |
msgid "Enter the flat discount in %s."
|
83 |
msgstr "Enter the flat discount in %s."
|
84 |
|
85 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:542
|
86 |
msgid "Discount (%)"
|
87 |
msgstr "Discount (%)"
|
88 |
|
89 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:542
|
90 |
msgid "Enter the discount in percents (Allowed values: 0 to 100)."
|
91 |
msgstr "Enter the discount in percents (Allowed values: 0 to 100)."
|
92 |
|
93 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:681
|
94 |
msgid "The following options are specific to product bulk discount."
|
95 |
msgstr "The following options are specific to product bulk discount."
|
96 |
|
97 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:681
|
98 |
msgid ""
|
99 |
"After changing the settings, it is recommended to clear all sessions in "
|
100 |
"WooCommerce > System Status > Tools."
|
102 |
"After changing the settings, it is recommended to clear all sessions in "
|
103 |
"WooCommerce > System Status > Tools."
|
104 |
|
105 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:684
|
106 |
+
msgid "Bulk Discount globally enabled"
|
107 |
+
msgstr "Bulk Discount globally enabled"
|
108 |
|
109 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:693
|
110 |
msgid "Discount Type"
|
111 |
msgstr "Discount Type"
|
112 |
|
113 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:695
|
114 |
#, php-format
|
115 |
msgid ""
|
116 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
119 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
120 |
"price while Flat Discount deducts fixed amount in %s"
|
121 |
|
122 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:702
|
123 |
msgid "Percentage Discount"
|
124 |
msgstr "Percentage Discount"
|
125 |
|
126 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:703
|
127 |
msgid "Flat Discount"
|
128 |
msgstr "Flat Discount"
|
129 |
|
130 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:708
|
131 |
msgid "Treat product variations separately"
|
132 |
msgstr "Treat product variations separately"
|
133 |
|
134 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:710
|
135 |
+
msgid ""
|
136 |
+
"You need to have this option unchecked to apply discounts to variations by "
|
137 |
+
"shared quantity."
|
138 |
+
msgstr ""
|
139 |
+
"You need to have this option unchecked to apply discounts to variations by "
|
140 |
+
"shared quantity."
|
141 |
+
|
142 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:717
|
143 |
+
msgid "Treat product variations as one product"
|
144 |
+
msgstr "Treat product variations as one product"
|
145 |
+
|
146 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:719
|
147 |
msgid ""
|
148 |
+
"You need to have this option checked to apply discounts to variations as if "
|
149 |
+
"they were one product. Applies only if Flat Discount Type is selected."
|
150 |
msgstr ""
|
151 |
+
"You need to have this option checked to apply discounts to variations as if "
|
152 |
+
"they were one product. Applies only if Flat Discount Type is selected."
|
153 |
|
154 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:726
|
155 |
msgid "Show discount information next to cart item price"
|
156 |
msgstr "Show discount information next to cart item price"
|
157 |
|
158 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:728
|
159 |
msgid "Applies only to percentage discount."
|
160 |
msgstr "Applies only to percentage discount."
|
161 |
|
162 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:735
|
163 |
msgid "Show discount information next to item subtotal price"
|
164 |
msgstr "Show discount information next to item subtotal price"
|
165 |
|
166 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:743
|
167 |
msgid "Show discount information next to item subtotal price in order history"
|
168 |
msgstr "Show discount information next to item subtotal price in order history"
|
169 |
|
170 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:745
|
171 |
msgid "Includes showing discount in order e-mails and invoices."
|
172 |
msgstr "Includes showing discount in order e-mails and invoices."
|
173 |
|
174 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:752
|
175 |
msgid "Optionally enter information about discounts visible on cart page."
|
176 |
msgstr "Optionally enter information about discounts visible on cart page."
|
177 |
|
178 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:759
|
179 |
msgid "Optionally change the CSS for old price on cart before discounting."
|
180 |
msgstr "Optionally change the CSS for old price on cart before discounting."
|
181 |
|
182 |
+
#: c:/DEVELOP/www/wp-content/plugins/woocommerce-bulk-discount/woocommerce-bulk-discount.php:767
|
183 |
msgid "Optionally change the CSS for new price on cart after discounting."
|
184 |
msgstr "Optionally change the CSS for new price on cart after discounting."
|
readme.txt
CHANGED
@@ -4,11 +4,11 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_butt
|
|
4 |
Tags: woocommerce, bulk, discount
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.6.1
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
11 |
-
Apply fine-grained bulk discounts to items in the shopping cart with this WooCommerce extension. Enjoy version 2.
|
12 |
|
13 |
== Description ==
|
14 |
|
@@ -38,13 +38,16 @@ policies to be adopted in your store.
|
|
38 |
Here is the list of the main features:
|
39 |
|
40 |
* Possibility of setting percentage bulk discount or flat (fixed) bulk discount in currency units.
|
41 |
-
* Bulk discounts for product variations is supported to treat them separately or as
|
42 |
* Discount is better visible and is available on several locations (see below).
|
43 |
* Discount is visible on the Checkout page
|
44 |
* Discount is visible on the Order Details page
|
45 |
* Discount is visible in WooCommerce order e-mails and invoices as well.
|
46 |
* Showing the applied discount when hovering over the item price in the cart.
|
47 |
* Possibility of easily changing the CSS of the price before and after discount.
|
|
|
|
|
|
|
48 |
|
49 |
WooCommerce Bulk Discount has been localised to these languages:
|
50 |
|
@@ -72,13 +75,19 @@ modify the CSS styles for the old value and the new value which is displayed in
|
|
72 |
Save the settings.
|
73 |
|
74 |
2. Navigate to Products and choose a product for which you want to create a discount policy.
|
75 |
-
In the Product Data panel, click Bulk
|
76 |
which will be visible in the product description.
|
77 |
|
78 |
3. Click "Add discount line" button to create a policy. Quantity (min.) means minimal
|
79 |
number of ordered items so that the (second textbox) Discount applies. It is possible to
|
80 |
add up to five discount lines to fine-tune the discount setting.
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
== Frequently Asked Questions ==
|
83 |
|
84 |
= Are multiple discounts supported? How many levels of discounting may be applied? =
|
@@ -135,6 +144,13 @@ Setting bulk discounts couldn't have been easier.
|
|
135 |
|
136 |
== Changelog ==
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
= 2.0.12 =
|
139 |
* (23 Oct 2013) Added Swedish translation.
|
140 |
|
@@ -213,6 +229,9 @@ Setting bulk discounts couldn't have been easier.
|
|
213 |
|
214 |
== Upgrade Notice ==
|
215 |
|
|
|
|
|
|
|
216 |
= 2.0.12 =
|
217 |
Language translation release.
|
218 |
|
4 |
Tags: woocommerce, bulk, discount
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.6.1
|
7 |
+
Stable tag: 2.1
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
11 |
+
Apply fine-grained bulk discounts to items in the shopping cart with this WooCommerce extension. Enjoy version 2.1 with new features!
|
12 |
|
13 |
== Description ==
|
14 |
|
38 |
Here is the list of the main features:
|
39 |
|
40 |
* Possibility of setting percentage bulk discount or flat (fixed) bulk discount in currency units.
|
41 |
+
* Bulk discounts for product variations is supported to treat them separately or as one product when discounting. **Updated in 2.1**
|
42 |
* Discount is better visible and is available on several locations (see below).
|
43 |
* Discount is visible on the Checkout page
|
44 |
* Discount is visible on the Order Details page
|
45 |
* Discount is visible in WooCommerce order e-mails and invoices as well.
|
46 |
* Showing the applied discount when hovering over the item price in the cart.
|
47 |
* Possibility of easily changing the CSS of the price before and after discount.
|
48 |
+
* Bulk discount is not applied if coupon code is used. **New in 2.1**
|
49 |
+
* HTML markup is allowed in information about the bulk discount offer in Product Description. **New in 2.1**
|
50 |
+
* Bulk Discount can be disabled more easily in the Product Options page. **New in 2.1**
|
51 |
|
52 |
WooCommerce Bulk Discount has been localised to these languages:
|
53 |
|
75 |
Save the settings.
|
76 |
|
77 |
2. Navigate to Products and choose a product for which you want to create a discount policy.
|
78 |
+
In the Product Data panel, click Bulk Discount and optionally fill information about the discount
|
79 |
which will be visible in the product description.
|
80 |
|
81 |
3. Click "Add discount line" button to create a policy. Quantity (min.) means minimal
|
82 |
number of ordered items so that the (second textbox) Discount applies. It is possible to
|
83 |
add up to five discount lines to fine-tune the discount setting.
|
84 |
|
85 |
+
**Notice about upgrading to Bulk Discount version 2.1**
|
86 |
+
|
87 |
+
Due to a new feature of more explicit activation of bulk discounts to products, you need
|
88 |
+
to manually click "Bulk Discount enabled" on all product setting pages under the Bulk Discount tab
|
89 |
+
(for products which have bulk discount data already set).
|
90 |
+
|
91 |
== Frequently Asked Questions ==
|
92 |
|
93 |
= Are multiple discounts supported? How many levels of discounting may be applied? =
|
144 |
|
145 |
== Changelog ==
|
146 |
|
147 |
+
= 2.1 =
|
148 |
+
* (12 Nov 2013) Bulk discount is not applied if coupon code is used.
|
149 |
+
* HTML markup is allowed in information about the bulk discount offer in Product Description.
|
150 |
+
* Bulk Discount can be disabled more easily in the Product Options page.
|
151 |
+
* There are further settings for applying bulk discount to product variations.
|
152 |
+
|
153 |
+
|
154 |
= 2.0.12 =
|
155 |
* (23 Oct 2013) Added Swedish translation.
|
156 |
|
229 |
|
230 |
== Upgrade Notice ==
|
231 |
|
232 |
+
= 2.1 =
|
233 |
+
Release with new features.
|
234 |
+
|
235 |
= 2.0.12 =
|
236 |
Language translation release.
|
237 |
|
woocommerce-bulk-discount.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WooCommerce Bulk Discount
|
|
4 |
Plugin URI: http://www.renepuchinger.com
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
-
Version: 2.
|
8 |
Author URI: http://www.renepuchinger.com
|
9 |
License: GPL3
|
10 |
|
@@ -45,40 +45,40 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
45 |
'bulk_discount' => __( 'Bulk Discount', 'wc_bulk_discount' )
|
46 |
);
|
47 |
|
48 |
-
add_action( 'admin_enqueue_scripts', array($this, 'action_enqueue_dependencies_admin') );
|
49 |
-
add_action( 'wp_head', array($this, 'action_enqueue_dependencies') );
|
50 |
|
51 |
-
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'action_links') );
|
52 |
|
53 |
-
add_action( 'woocommerce_settings_tabs', array($this, 'add_tab'), 10 );
|
54 |
|
55 |
// Run these actions when generating the settings tabs.
|
56 |
foreach ( $this->settings_tabs as $name => $label ) {
|
57 |
-
add_action( 'woocommerce_settings_tabs_' . $name, array($this, 'settings_tab_action'), 10 );
|
58 |
-
add_action( 'woocommerce_update_options_' . $name, array($this, 'save_settings'), 10 );
|
59 |
}
|
60 |
|
61 |
// Add the settings fields to each tab.
|
62 |
-
add_action( 'woocommerce_bulk_discount_settings', array($this, 'add_settings_fields'), 10 );
|
63 |
|
64 |
if ( get_option( 'woocommerce_t4m_enable_bulk_discounts', 'yes' ) == 'yes' ) {
|
65 |
-
add_action( 'woocommerce_before_calculate_totals', array($this, 'action_before_calculate'), 10, 1 );
|
66 |
-
add_action( 'woocommerce_calculate_totals', array($this, 'action_after_calculate'), 10, 1 );
|
67 |
-
add_action( 'woocommerce_before_cart_table', array($this, 'before_cart_table') );
|
68 |
-
add_action( 'woocommerce_single_product_summary', array($this, 'single_product_summary'), 45 );
|
69 |
if ( class_exists( 'WC_Inline_Javascript_Helper' ) ) { // is WooCommerce 2.1 installed?
|
70 |
-
add_filter( 'woocommerce_cart_item_price', array($this, 'filter_item_price'), 10, 2 );
|
71 |
} else {
|
72 |
-
add_filter( 'woocommerce_cart_item_price_html', array($this, 'filter_item_price'), 10, 2 );
|
73 |
}
|
74 |
-
add_filter( 'woocommerce_cart_item_subtotal', array($this, 'filter_subtotal_price'), 10, 2 );
|
75 |
-
add_filter( 'woocommerce_checkout_item_subtotal', array($this, 'filter_subtotal_price'), 10, 2 );
|
76 |
-
add_filter( 'woocommerce_order_formatted_line_subtotal', array($this, 'filter_subtotal_order_price'), 10, 3 );
|
77 |
-
add_filter( 'woocommerce_product_write_panel_tabs', array($this, 'action_product_write_panel_tabs') );
|
78 |
-
add_filter( 'woocommerce_product_write_panels', array($this, 'action_product_write_panels') );
|
79 |
-
add_action( 'woocommerce_process_product_meta', array($this, 'action_process_meta') );
|
80 |
-
add_filter( 'woocommerce_cart_product_subtotal', array($this, 'filter_cart_product_subtotal'), 10, 3 );
|
81 |
-
add_action( 'woocommerce_checkout_update_order_meta', array($this, 'order_update_meta') );
|
82 |
}
|
83 |
|
84 |
}
|
@@ -107,8 +107,8 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
107 |
* @return float
|
108 |
*/
|
109 |
protected function get_discounted_coeff( $product_id, $quantity ) {
|
110 |
-
$q = array(0.0);
|
111 |
-
$d = array(0.0);
|
112 |
/* Find the appropriate discount coefficient by looping through up to the five discount settings */
|
113 |
for ( $i = 1; $i <= 5; $i++ ) {
|
114 |
array_push( $q, get_post_meta( $product_id, "_bulkdiscount_quantity_$i", true ) );
|
@@ -134,17 +134,22 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
134 |
* @return string
|
135 |
*/
|
136 |
public function filter_item_price( $price, $values ) {
|
137 |
-
global $woocommerce;
|
138 |
if ( !$values || @!$values['data'] ) {
|
139 |
return $price;
|
140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
if ( ( get_option( 'woocommerce_t4m_show_on_item', 'yes' ) == 'no' ) ) {
|
142 |
return $price;
|
143 |
}
|
144 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
145 |
return $price; // for flat discount this filter has no meaning
|
146 |
}
|
147 |
-
$_product = $values['data'];
|
148 |
if ( empty( $this->discount_coeffs ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )] )
|
149 |
|| !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] )
|
150 |
) {
|
@@ -171,14 +176,19 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
171 |
* @return string
|
172 |
*/
|
173 |
public function filter_subtotal_price( $price, $values ) {
|
174 |
-
global $woocommerce;
|
175 |
if ( !$values || !$values['data'] ) {
|
176 |
return $price;
|
177 |
}
|
178 |
-
if ( (
|
179 |
return $price;
|
180 |
}
|
181 |
$_product = $values['data'];
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
if ( empty( $this->discount_coeffs ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )] )
|
183 |
|| !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] )
|
184 |
) {
|
@@ -188,8 +198,6 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
188 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' && $coeff == 0 ) || ( get_option( 'woocommerce_t4m_discount_type', '' ) == '' && $coeff == 1.0 ) ) {
|
189 |
return $price; // no price modification
|
190 |
}
|
191 |
-
$oldprice = woocommerce_price( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] );
|
192 |
-
$old_css = esc_attr( get_option( 'woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;' ) );
|
193 |
$new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
|
194 |
$bulk_info = sprintf( __( 'Incl. %s discount', 'wc_bulk_discount' ), ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ? get_woocommerce_currency_symbol() . $coeff : ( round( ( 1 - $coeff ) * 100, 2 ) . "%" ) ) );
|
195 |
return "<span class='discount-info' title='$bulk_info'>" .
|
@@ -204,11 +212,13 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
204 |
global $woocommerce;
|
205 |
$cart = $woocommerce->cart;
|
206 |
$this->discount_coeffs = array();
|
|
|
207 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
208 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
209 |
$_product = $values['data'];
|
210 |
$quantity = 0;
|
211 |
if ( get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'no' && $_product instanceof WC_Product_Variation && $_product->parent ) {
|
|
|
212 |
$parent = $_product->parent;
|
213 |
foreach ( $cart->cart_contents as $valuesInner ) {
|
214 |
$p = $valuesInner['data'];
|
@@ -220,7 +230,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
220 |
} else {
|
221 |
$quantity = $values['quantity'];
|
222 |
}
|
223 |
-
|
|
|
|
|
|
|
|
|
224 |
$this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] = $_product->get_price();
|
225 |
}
|
226 |
}
|
@@ -234,14 +248,19 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
234 |
* @return string
|
235 |
*/
|
236 |
public function filter_subtotal_order_price( $price, $values, $order ) {
|
237 |
-
global $woocommerce;
|
238 |
if ( !$values || !$order ) {
|
239 |
return $price;
|
240 |
}
|
241 |
-
if ( (
|
242 |
return $price;
|
243 |
}
|
244 |
$_product = get_product( $values['product_id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
$actual_id = $values['product_id'];
|
246 |
if ( $_product && $_product instanceof WC_Product_Variable && $values['variation_id'] ) {
|
247 |
$actual_id = $values['variation_id'];
|
@@ -255,8 +274,6 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
255 |
if ( ( $discount_type == 'flat' && $coeff == 0 ) || ( $discount_type == '' && $coeff == 1.0 ) ) {
|
256 |
return $price; // no price modification
|
257 |
}
|
258 |
-
$oldprice = woocommerce_price( $discount_coeffs[$actual_id]['orig_price'] );
|
259 |
-
$old_css = esc_attr( get_option( 'woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;' ) );
|
260 |
$new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
|
261 |
$bulk_info = sprintf( __( 'Incl. %s discount', 'wc_bulk_discount' ), ( $discount_type == 'flat' ? get_woocommerce_currency_symbol() . $coeff : ( round( ( 1 - $coeff ) * 100, 2 ) . "%" ) ) );
|
262 |
return "<span class='discount-info' title='$bulk_info'>" .
|
@@ -286,11 +303,18 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
286 |
*/
|
287 |
public function action_before_calculate( WC_Cart $cart ) {
|
288 |
|
|
|
|
|
|
|
|
|
289 |
$this->gather_discount_coeffs();
|
290 |
|
291 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
292 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
293 |
$_product = $values['data'];
|
|
|
|
|
|
|
294 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
295 |
$row_base_price = max( 0, $_product->get_price() - ( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] / $values['quantity'] ) );
|
296 |
} else {
|
@@ -302,6 +326,10 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
302 |
}
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
305 |
protected function get_actual_id( $product ) {
|
306 |
if ( $product instanceof WC_Product_Variation ) {
|
307 |
return $product->variation_id;
|
@@ -316,9 +344,17 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
316 |
* @param WC_Cart $cart
|
317 |
*/
|
318 |
public function action_after_calculate( WC_Cart $cart ) {
|
|
|
|
|
|
|
|
|
|
|
319 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
320 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
321 |
$_product = $values['data'];
|
|
|
|
|
|
|
322 |
$values['data']->set_price( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] );
|
323 |
}
|
324 |
}
|
@@ -328,9 +364,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
328 |
* Show discount info in cart.
|
329 |
*/
|
330 |
public function before_cart_table() {
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
334 |
}
|
335 |
|
336 |
/**
|
@@ -346,6 +384,12 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
346 |
if ( !$_product || !$quantity ) {
|
347 |
return $subtotal;
|
348 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
$coeff = $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'];
|
350 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
351 |
$newsubtotal = woocommerce_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
|
@@ -356,7 +400,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
-
* Store discount info
|
360 |
*
|
361 |
* @param $order_id
|
362 |
*/
|
@@ -403,8 +447,8 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
403 |
if (<?php echo $i; ?> == 1 || ( e.find('#_bulkdiscount_quantity_<?php echo max($i-1, 1); ?>').val() != '' &&
|
404 |
<?php if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) : ?>
|
405 |
e.find('#_bulkdiscount_discount_flat_<?php echo max($i-1, 1); ?>').val() != ''
|
406 |
-
|
407 |
-
|
408 |
<?php endif; ?>
|
409 |
) )
|
410 |
{
|
@@ -466,7 +510,8 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
466 |
|
467 |
<div class="options_group">
|
468 |
<?php
|
469 |
-
|
|
|
470 |
?>
|
471 |
</div>
|
472 |
|
@@ -482,23 +527,23 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
482 |
<a id="delete_discount_line<?php echo $i; ?>" class="button-secondary"
|
483 |
href="#block<?php echo $i; ?>"><?php _e( 'Remove last discount line', 'wc_bulk_discount' ); ?></a>
|
484 |
|
485 |
-
<div class="block<?php echo $i; ?> <?php echo ($i % 2 == 0) ? 'even' : 'odd' ?>">
|
486 |
<?php
|
487 |
-
woocommerce_wp_text_input( array('id' => "_bulkdiscount_quantity_$i", 'label' => __( 'Quantity (min.)', 'wc_bulk_discount' ), 'type' => 'number', 'description' => __( 'Enter the minimal quantity for which the discount applies.', 'wc_bulk_discount' ), 'custom_attributes' => array(
|
488 |
'step' => '1',
|
489 |
'min' => '1'
|
490 |
-
)) );
|
491 |
if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) {
|
492 |
-
woocommerce_wp_text_input( array('id' => "_bulkdiscount_discount_flat_$i", 'type' => 'number', 'label' => sprintf( __( 'Discount (%s)', 'wc_bulk_discount' ), get_woocommerce_currency_symbol() ), 'description' => sprintf( __( 'Enter the flat discount in %s.', 'wc_bulk_discount' ), get_woocommerce_currency_symbol() ), 'custom_attributes' => array(
|
493 |
'step' => 'any',
|
494 |
'min' => '0'
|
495 |
-
)) );
|
496 |
} else {
|
497 |
-
woocommerce_wp_text_input( array('id' => "_bulkdiscount_discount_$i", 'type' => 'number', 'label' => __( 'Discount (%)', 'wc_bulk_discount' ), 'description' => __( 'Enter the discount in percents (Allowed values: 0 to 100).', 'wc_bulk_discount' ), 'custom_attributes' => array(
|
498 |
'step' => 'any',
|
499 |
'min' => '0',
|
500 |
'max' => '100'
|
501 |
-
)) );
|
502 |
}
|
503 |
?>
|
504 |
</div>
|
@@ -544,7 +589,12 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
544 |
* @param $post_id
|
545 |
*/
|
546 |
public function action_process_meta( $post_id ) {
|
547 |
-
if ( isset( $_POST['_bulkdiscount_text_info'] ) ) update_post_meta( $post_id, '_bulkdiscount_text_info',
|
|
|
|
|
|
|
|
|
|
|
548 |
for ( $i = 1; $i <= 5; $i++ ) {
|
549 |
if ( isset( $_POST["_bulkdiscount_quantity_$i"] ) ) update_post_meta( $post_id, "_bulkdiscount_quantity_$i", stripslashes( $_POST["_bulkdiscount_quantity_$i"] ) );
|
550 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
@@ -578,7 +628,6 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
578 |
// Determine the current tab in effect.
|
579 |
$current_tab = $this->get_tab_in_view( current_filter(), 'woocommerce_settings_tabs_' );
|
580 |
|
581 |
-
// Hook onto this from another function to keep things clean.
|
582 |
do_action( 'woocommerce_bulk_discount_settings' );
|
583 |
|
584 |
// Display settings for this tab (make sure to add the settings to the tab).
|
@@ -629,10 +678,10 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
629 |
// Define settings
|
630 |
$this->fields['bulk_discount'] = apply_filters( 'woocommerce_bulk_discount_settings_fields', array(
|
631 |
|
632 |
-
array('name' => __( 'Bulk Discount', 'wc_bulk_discount' ), 'type' => 'title', 'desc' => __( 'The following options are specific to product bulk discount.', 'wc_bulk_discount' ) . '<br /><br/><strong><i>' . __( 'After changing the settings, it is recommended to clear all sessions in WooCommerce > System Status > Tools.', 'wc_bulk_discount' ) . '</i></strong>', 'id' => 't4m_bulk_discounts_options'),
|
633 |
|
634 |
array(
|
635 |
-
'name' => __( 'Bulk Discount enabled', 'wc_bulk_discount' ),
|
636 |
'id' => 'woocommerce_t4m_enable_bulk_discounts',
|
637 |
'desc' => __( '', 'wc_bulk_discount' ),
|
638 |
'std' => 'yes',
|
@@ -658,12 +707,21 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
658 |
array(
|
659 |
'name' => __( 'Treat product variations separately', 'wc_bulk_discount' ),
|
660 |
'id' => 'woocommerce_t4m_variations_separate',
|
661 |
-
'desc' => __( 'You need to have this option unchecked to
|
662 |
'std' => 'yes',
|
663 |
'type' => 'checkbox',
|
664 |
'default' => 'yes'
|
665 |
),
|
666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
array(
|
668 |
'name' => __( 'Show discount information next to cart item price', 'wc_bulk_discount' ),
|
669 |
'id' => 'woocommerce_t4m_show_on_item',
|
@@ -713,26 +771,19 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
713 |
'default' => 'color: #4AB915; font-weight: bold;'
|
714 |
),
|
715 |
|
716 |
-
array('type' => 'sectionend', 'id' => 't4m_bulk_discounts_options')
|
717 |
-
|
718 |
-
array(
|
719 |
-
'desc' => '<b>If you find WooCommerce Bulk Discount useful, please rate the plugin at <a target="_blank" href="http://wordpress.org/plugins/woocommerce-bulk-discount/">http://wordpress.org/plugins/woocommerce-bulk-discount/</a> or kindly consider small donation to support further development.</b>',
|
720 |
-
'id' => 'woocommerce_t4m_begging_text',
|
721 |
-
'type' => 'title'
|
722 |
-
),
|
723 |
-
|
724 |
-
array('type' => 'sectionend', 'id' => 'woocommerce_t4m_begging_text'),
|
725 |
|
726 |
) ); // End settings
|
727 |
|
728 |
$js = "
|
729 |
-
jQuery('#woocommerce_t4m_enable_bulk_discounts').change(function(){
|
730 |
|
731 |
-
jQuery('#woocommerce_t4m_cart_info, #woocommerce_t4m_variations_separate, #woocommerce_t4m_discount_type, #woocommerce_t4m_css_old_price, #woocommerce_t4m_css_new_price, #woocommerce_t4m_show_on_item, #woocommerce_t4m_show_on_subtotal, #woocommerce_t4m_show_on_order_subtotal').closest('tr').hide();
|
732 |
|
733 |
if ( jQuery(this).attr('checked') ) {
|
734 |
jQuery('#woocommerce_t4m_cart_info').closest('tr').show();
|
735 |
jQuery('#woocommerce_t4m_variations_separate').closest('tr').show();
|
|
|
736 |
jQuery('#woocommerce_t4m_discount_type').closest('tr').show();
|
737 |
jQuery('#woocommerce_t4m_css_old_price').closest('tr').show();
|
738 |
jQuery('#woocommerce_t4m_css_new_price').closest('tr').show();
|
@@ -743,18 +794,41 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
743 |
|
744 |
}).change();
|
745 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
";
|
747 |
|
748 |
-
|
749 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
750 |
} else {
|
751 |
$woocommerce->add_inline_js( $js );
|
752 |
}
|
|
|
753 |
|
|
|
|
|
|
|
754 |
}
|
755 |
|
756 |
}
|
757 |
|
758 |
-
|
759 |
|
760 |
}
|
4 |
Plugin URI: http://www.renepuchinger.com
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
+
Version: 2.1
|
8 |
Author URI: http://www.renepuchinger.com
|
9 |
License: GPL3
|
10 |
|
45 |
'bulk_discount' => __( 'Bulk Discount', 'wc_bulk_discount' )
|
46 |
);
|
47 |
|
48 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'action_enqueue_dependencies_admin' ) );
|
49 |
+
add_action( 'wp_head', array( $this, 'action_enqueue_dependencies' ) );
|
50 |
|
51 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
|
52 |
|
53 |
+
add_action( 'woocommerce_settings_tabs', array( $this, 'add_tab' ), 10 );
|
54 |
|
55 |
// Run these actions when generating the settings tabs.
|
56 |
foreach ( $this->settings_tabs as $name => $label ) {
|
57 |
+
add_action( 'woocommerce_settings_tabs_' . $name, array( $this, 'settings_tab_action' ), 10 );
|
58 |
+
add_action( 'woocommerce_update_options_' . $name, array( $this, 'save_settings' ), 10 );
|
59 |
}
|
60 |
|
61 |
// Add the settings fields to each tab.
|
62 |
+
add_action( 'woocommerce_bulk_discount_settings', array( $this, 'add_settings_fields' ), 10 );
|
63 |
|
64 |
if ( get_option( 'woocommerce_t4m_enable_bulk_discounts', 'yes' ) == 'yes' ) {
|
65 |
+
add_action( 'woocommerce_before_calculate_totals', array( $this, 'action_before_calculate' ), 10, 1 );
|
66 |
+
add_action( 'woocommerce_calculate_totals', array( $this, 'action_after_calculate' ), 10, 1 );
|
67 |
+
add_action( 'woocommerce_before_cart_table', array( $this, 'before_cart_table' ) );
|
68 |
+
add_action( 'woocommerce_single_product_summary', array( $this, 'single_product_summary' ), 45 );
|
69 |
if ( class_exists( 'WC_Inline_Javascript_Helper' ) ) { // is WooCommerce 2.1 installed?
|
70 |
+
add_filter( 'woocommerce_cart_item_price', array( $this, 'filter_item_price' ), 10, 2 );
|
71 |
} else {
|
72 |
+
add_filter( 'woocommerce_cart_item_price_html', array( $this, 'filter_item_price' ), 10, 2 );
|
73 |
}
|
74 |
+
add_filter( 'woocommerce_cart_item_subtotal', array( $this, 'filter_subtotal_price' ), 10, 2 );
|
75 |
+
add_filter( 'woocommerce_checkout_item_subtotal', array( $this, 'filter_subtotal_price' ), 10, 2 );
|
76 |
+
add_filter( 'woocommerce_order_formatted_line_subtotal', array( $this, 'filter_subtotal_order_price' ), 10, 3 );
|
77 |
+
add_filter( 'woocommerce_product_write_panel_tabs', array( $this, 'action_product_write_panel_tabs' ) );
|
78 |
+
add_filter( 'woocommerce_product_write_panels', array( $this, 'action_product_write_panels' ) );
|
79 |
+
add_action( 'woocommerce_process_product_meta', array( $this, 'action_process_meta' ) );
|
80 |
+
add_filter( 'woocommerce_cart_product_subtotal', array( $this, 'filter_cart_product_subtotal' ), 10, 3 );
|
81 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'order_update_meta' ) );
|
82 |
}
|
83 |
|
84 |
}
|
107 |
* @return float
|
108 |
*/
|
109 |
protected function get_discounted_coeff( $product_id, $quantity ) {
|
110 |
+
$q = array( 0.0 );
|
111 |
+
$d = array( 0.0 );
|
112 |
/* Find the appropriate discount coefficient by looping through up to the five discount settings */
|
113 |
for ( $i = 1; $i <= 5; $i++ ) {
|
114 |
array_push( $q, get_post_meta( $product_id, "_bulkdiscount_quantity_$i", true ) );
|
134 |
* @return string
|
135 |
*/
|
136 |
public function filter_item_price( $price, $values ) {
|
|
|
137 |
if ( !$values || @!$values['data'] ) {
|
138 |
return $price;
|
139 |
}
|
140 |
+
if ( $this->is_coupon_applied() ) {
|
141 |
+
return $price;
|
142 |
+
}
|
143 |
+
$_product = $values['data'];
|
144 |
+
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != 'yes' ) {
|
145 |
+
return $price;
|
146 |
+
}
|
147 |
if ( ( get_option( 'woocommerce_t4m_show_on_item', 'yes' ) == 'no' ) ) {
|
148 |
return $price;
|
149 |
}
|
150 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
151 |
return $price; // for flat discount this filter has no meaning
|
152 |
}
|
|
|
153 |
if ( empty( $this->discount_coeffs ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )] )
|
154 |
|| !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] )
|
155 |
) {
|
176 |
* @return string
|
177 |
*/
|
178 |
public function filter_subtotal_price( $price, $values ) {
|
|
|
179 |
if ( !$values || !$values['data'] ) {
|
180 |
return $price;
|
181 |
}
|
182 |
+
if ( $this->is_coupon_applied() ) {
|
183 |
return $price;
|
184 |
}
|
185 |
$_product = $values['data'];
|
186 |
+
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != 'yes' ) {
|
187 |
+
return $price;
|
188 |
+
}
|
189 |
+
if ( ( get_option( 'woocommerce_t4m_show_on_subtotal', 'yes' ) == 'no' ) ) {
|
190 |
+
return $price;
|
191 |
+
}
|
192 |
if ( empty( $this->discount_coeffs ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )] )
|
193 |
|| !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] ) || !isset( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] )
|
194 |
) {
|
198 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' && $coeff == 0 ) || ( get_option( 'woocommerce_t4m_discount_type', '' ) == '' && $coeff == 1.0 ) ) {
|
199 |
return $price; // no price modification
|
200 |
}
|
|
|
|
|
201 |
$new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
|
202 |
$bulk_info = sprintf( __( 'Incl. %s discount', 'wc_bulk_discount' ), ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ? get_woocommerce_currency_symbol() . $coeff : ( round( ( 1 - $coeff ) * 100, 2 ) . "%" ) ) );
|
203 |
return "<span class='discount-info' title='$bulk_info'>" .
|
212 |
global $woocommerce;
|
213 |
$cart = $woocommerce->cart;
|
214 |
$this->discount_coeffs = array();
|
215 |
+
$var_cnt = 0;
|
216 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
217 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
218 |
$_product = $values['data'];
|
219 |
$quantity = 0;
|
220 |
if ( get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'no' && $_product instanceof WC_Product_Variation && $_product->parent ) {
|
221 |
+
$var_cnt++;
|
222 |
$parent = $_product->parent;
|
223 |
foreach ( $cart->cart_contents as $valuesInner ) {
|
224 |
$p = $valuesInner['data'];
|
230 |
} else {
|
231 |
$quantity = $values['quantity'];
|
232 |
}
|
233 |
+
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == '' || get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'yes' || ( !( $_product instanceof WC_Product_Variation && $_product->parent && get_option( 'woocommerce_t4m_variations_as_one', 'no' ) == 'yes' && $var_cnt != 1 ) ) ) ) {
|
234 |
+
$this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] = $this->get_discounted_coeff( $_product->id, $quantity );
|
235 |
+
} else {
|
236 |
+
$this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] = 0;
|
237 |
+
}
|
238 |
$this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] = $_product->get_price();
|
239 |
}
|
240 |
}
|
248 |
* @return string
|
249 |
*/
|
250 |
public function filter_subtotal_order_price( $price, $values, $order ) {
|
|
|
251 |
if ( !$values || !$order ) {
|
252 |
return $price;
|
253 |
}
|
254 |
+
if ( $this->is_coupon_applied() ) {
|
255 |
return $price;
|
256 |
}
|
257 |
$_product = get_product( $values['product_id'] );
|
258 |
+
if ( get_post_meta( $values['product_id'], "_bulkdiscount_enabled", true ) != 'yes' ) {
|
259 |
+
return $price;
|
260 |
+
}
|
261 |
+
if ( ( get_option( 'woocommerce_t4m_show_on_order_subtotal', 'yes' ) == 'no' ) ) {
|
262 |
+
return $price;
|
263 |
+
}
|
264 |
$actual_id = $values['product_id'];
|
265 |
if ( $_product && $_product instanceof WC_Product_Variable && $values['variation_id'] ) {
|
266 |
$actual_id = $values['variation_id'];
|
274 |
if ( ( $discount_type == 'flat' && $coeff == 0 ) || ( $discount_type == '' && $coeff == 1.0 ) ) {
|
275 |
return $price; // no price modification
|
276 |
}
|
|
|
|
|
277 |
$new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
|
278 |
$bulk_info = sprintf( __( 'Incl. %s discount', 'wc_bulk_discount' ), ( $discount_type == 'flat' ? get_woocommerce_currency_symbol() . $coeff : ( round( ( 1 - $coeff ) * 100, 2 ) . "%" ) ) );
|
279 |
return "<span class='discount-info' title='$bulk_info'>" .
|
303 |
*/
|
304 |
public function action_before_calculate( WC_Cart $cart ) {
|
305 |
|
306 |
+
if ( $this->is_coupon_applied() ) {
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
$this->gather_discount_coeffs();
|
311 |
|
312 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
313 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
314 |
$_product = $values['data'];
|
315 |
+
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != 'yes' ) {
|
316 |
+
continue;
|
317 |
+
}
|
318 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
319 |
$row_base_price = max( 0, $_product->get_price() - ( $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] / $values['quantity'] ) );
|
320 |
} else {
|
326 |
}
|
327 |
}
|
328 |
|
329 |
+
/**
|
330 |
+
* @param $product
|
331 |
+
* @return int
|
332 |
+
*/
|
333 |
protected function get_actual_id( $product ) {
|
334 |
if ( $product instanceof WC_Product_Variation ) {
|
335 |
return $product->variation_id;
|
344 |
* @param WC_Cart $cart
|
345 |
*/
|
346 |
public function action_after_calculate( WC_Cart $cart ) {
|
347 |
+
|
348 |
+
if ( $this->is_coupon_applied() ) {
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
|
352 |
if ( sizeof( $cart->cart_contents ) > 0 ) {
|
353 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
354 |
$_product = $values['data'];
|
355 |
+
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != 'yes' ) {
|
356 |
+
continue;
|
357 |
+
}
|
358 |
$values['data']->set_price( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] );
|
359 |
}
|
360 |
}
|
364 |
* Show discount info in cart.
|
365 |
*/
|
366 |
public function before_cart_table() {
|
367 |
+
if ( get_option( 'woocommerce_t4m_cart_info' ) != '' ) {
|
368 |
+
echo "<div class='cart-show-discounts'>";
|
369 |
+
echo get_option( 'woocommerce_t4m_cart_info' );
|
370 |
+
echo "</div>";
|
371 |
+
}
|
372 |
}
|
373 |
|
374 |
/**
|
384 |
if ( !$_product || !$quantity ) {
|
385 |
return $subtotal;
|
386 |
}
|
387 |
+
if ( $this->is_coupon_applied() ) {
|
388 |
+
return $subtotal;
|
389 |
+
}
|
390 |
+
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != 'yes' ) {
|
391 |
+
return $subtotal;
|
392 |
+
}
|
393 |
$coeff = $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'];
|
394 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
395 |
$newsubtotal = woocommerce_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
|
400 |
}
|
401 |
|
402 |
/**
|
403 |
+
* Store discount info in order as well
|
404 |
*
|
405 |
* @param $order_id
|
406 |
*/
|
447 |
if (<?php echo $i; ?> == 1 || ( e.find('#_bulkdiscount_quantity_<?php echo max($i-1, 1); ?>').val() != '' &&
|
448 |
<?php if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) : ?>
|
449 |
e.find('#_bulkdiscount_discount_flat_<?php echo max($i-1, 1); ?>').val() != ''
|
450 |
+
<?php else: ?>
|
451 |
+
e.find('#_bulkdiscount_discount_<?php echo max($i-1, 1); ?>').val() != ''
|
452 |
<?php endif; ?>
|
453 |
) )
|
454 |
{
|
510 |
|
511 |
<div class="options_group">
|
512 |
<?php
|
513 |
+
woocommerce_wp_checkbox( array( 'id' => '_bulkdiscount_enabled', 'label' => __( 'Bulk Discount enabled', 'wc_bulk_discount' ) ) );
|
514 |
+
woocommerce_wp_textarea_input( array( 'id' => "_bulkdiscount_text_info", 'label' => __( 'Bulk discount special offer text in product description', 'wc_bulk_discount' ), 'description' => __( 'Optionally enter bulk discount information that will be visible on the product page.', 'wc_bulk_discount' ), 'desc_tip' => 'yes', 'class' => 'fullWidth' ) );
|
515 |
?>
|
516 |
</div>
|
517 |
|
527 |
<a id="delete_discount_line<?php echo $i; ?>" class="button-secondary"
|
528 |
href="#block<?php echo $i; ?>"><?php _e( 'Remove last discount line', 'wc_bulk_discount' ); ?></a>
|
529 |
|
530 |
+
<div class="block<?php echo $i; ?> <?php echo ( $i % 2 == 0 ) ? 'even' : 'odd' ?>">
|
531 |
<?php
|
532 |
+
woocommerce_wp_text_input( array( 'id' => "_bulkdiscount_quantity_$i", 'label' => __( 'Quantity (min.)', 'wc_bulk_discount' ), 'type' => 'number', 'description' => __( 'Enter the minimal quantity for which the discount applies.', 'wc_bulk_discount' ), 'custom_attributes' => array(
|
533 |
'step' => '1',
|
534 |
'min' => '1'
|
535 |
+
) ) );
|
536 |
if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) {
|
537 |
+
woocommerce_wp_text_input( array( 'id' => "_bulkdiscount_discount_flat_$i", 'type' => 'number', 'label' => sprintf( __( 'Discount (%s)', 'wc_bulk_discount' ), get_woocommerce_currency_symbol() ), 'description' => sprintf( __( 'Enter the flat discount in %s.', 'wc_bulk_discount' ), get_woocommerce_currency_symbol() ), 'custom_attributes' => array(
|
538 |
'step' => 'any',
|
539 |
'min' => '0'
|
540 |
+
) ) );
|
541 |
} else {
|
542 |
+
woocommerce_wp_text_input( array( 'id' => "_bulkdiscount_discount_$i", 'type' => 'number', 'label' => __( 'Discount (%)', 'wc_bulk_discount' ), 'description' => __( 'Enter the discount in percents (Allowed values: 0 to 100).', 'wc_bulk_discount' ), 'custom_attributes' => array(
|
543 |
'step' => 'any',
|
544 |
'min' => '0',
|
545 |
'max' => '100'
|
546 |
+
) ) );
|
547 |
}
|
548 |
?>
|
549 |
</div>
|
589 |
* @param $post_id
|
590 |
*/
|
591 |
public function action_process_meta( $post_id ) {
|
592 |
+
if ( isset( $_POST['_bulkdiscount_text_info'] ) ) update_post_meta( $post_id, '_bulkdiscount_text_info', stripslashes( $_POST['_bulkdiscount_text_info'] ) );
|
593 |
+
if ( isset( $_POST['_bulkdiscount_enabled'] ) && $_POST['_bulkdiscount_enabled'] == 'yes' ) {
|
594 |
+
update_post_meta( $post_id, '_bulkdiscount_enabled', stripslashes( $_POST['_bulkdiscount_enabled'] ) );
|
595 |
+
} else {
|
596 |
+
update_post_meta( $post_id, '_bulkdiscount_enabled', stripslashes( 'no' ) );
|
597 |
+
}
|
598 |
for ( $i = 1; $i <= 5; $i++ ) {
|
599 |
if ( isset( $_POST["_bulkdiscount_quantity_$i"] ) ) update_post_meta( $post_id, "_bulkdiscount_quantity_$i", stripslashes( $_POST["_bulkdiscount_quantity_$i"] ) );
|
600 |
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
|
628 |
// Determine the current tab in effect.
|
629 |
$current_tab = $this->get_tab_in_view( current_filter(), 'woocommerce_settings_tabs_' );
|
630 |
|
|
|
631 |
do_action( 'woocommerce_bulk_discount_settings' );
|
632 |
|
633 |
// Display settings for this tab (make sure to add the settings to the tab).
|
678 |
// Define settings
|
679 |
$this->fields['bulk_discount'] = apply_filters( 'woocommerce_bulk_discount_settings_fields', array(
|
680 |
|
681 |
+
array( 'name' => __( 'Bulk Discount', 'wc_bulk_discount' ), 'type' => 'title', 'desc' => __( 'The following options are specific to product bulk discount.', 'wc_bulk_discount' ) . '<br /><br/><strong><i>' . __( 'After changing the settings, it is recommended to clear all sessions in WooCommerce > System Status > Tools.', 'wc_bulk_discount' ) . '</i></strong>', 'id' => 't4m_bulk_discounts_options' ),
|
682 |
|
683 |
array(
|
684 |
+
'name' => __( 'Bulk Discount globally enabled', 'wc_bulk_discount' ),
|
685 |
'id' => 'woocommerce_t4m_enable_bulk_discounts',
|
686 |
'desc' => __( '', 'wc_bulk_discount' ),
|
687 |
'std' => 'yes',
|
707 |
array(
|
708 |
'name' => __( 'Treat product variations separately', 'wc_bulk_discount' ),
|
709 |
'id' => 'woocommerce_t4m_variations_separate',
|
710 |
+
'desc' => __( 'You need to have this option unchecked to apply discounts to variations by shared quantity.', 'wc_bulk_discount' ),
|
711 |
'std' => 'yes',
|
712 |
'type' => 'checkbox',
|
713 |
'default' => 'yes'
|
714 |
),
|
715 |
|
716 |
+
array(
|
717 |
+
'name' => __( 'Treat product variations as one product', 'wc_bulk_discount' ),
|
718 |
+
'id' => 'woocommerce_t4m_variations_as_one',
|
719 |
+
'desc' => __( 'You need to have this option checked to apply discounts to variations as if they were one product. Applies only if Flat Discount Type is selected.', 'wc_bulk_discount' ),
|
720 |
+
'std' => 'yes',
|
721 |
+
'type' => 'checkbox',
|
722 |
+
'default' => 'no'
|
723 |
+
),
|
724 |
+
|
725 |
array(
|
726 |
'name' => __( 'Show discount information next to cart item price', 'wc_bulk_discount' ),
|
727 |
'id' => 'woocommerce_t4m_show_on_item',
|
771 |
'default' => 'color: #4AB915; font-weight: bold;'
|
772 |
),
|
773 |
|
774 |
+
array( 'type' => 'sectionend', 'id' => 't4m_bulk_discounts_options' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
|
776 |
) ); // End settings
|
777 |
|
778 |
$js = "
|
779 |
+
jQuery('#woocommerce_t4m_enable_bulk_discounts').change(function() {
|
780 |
|
781 |
+
jQuery('#woocommerce_t4m_cart_info, #woocommerce_t4m_variations_separate, #woocommerce_t4m_variations_as_one, #woocommerce_t4m_discount_type, #woocommerce_t4m_css_old_price, #woocommerce_t4m_css_new_price, #woocommerce_t4m_show_on_item, #woocommerce_t4m_show_on_subtotal, #woocommerce_t4m_show_on_order_subtotal').closest('tr').hide();
|
782 |
|
783 |
if ( jQuery(this).attr('checked') ) {
|
784 |
jQuery('#woocommerce_t4m_cart_info').closest('tr').show();
|
785 |
jQuery('#woocommerce_t4m_variations_separate').closest('tr').show();
|
786 |
+
jQuery('#woocommerce_t4m_variations_as_one').closest('tr').show();
|
787 |
jQuery('#woocommerce_t4m_discount_type').closest('tr').show();
|
788 |
jQuery('#woocommerce_t4m_css_old_price').closest('tr').show();
|
789 |
jQuery('#woocommerce_t4m_css_new_price').closest('tr').show();
|
794 |
|
795 |
}).change();
|
796 |
|
797 |
+
jQuery('#woocommerce_t4m_variations_separate').change(function() {
|
798 |
+
if ( !jQuery(this).attr('checked') ) {
|
799 |
+
jQuery('#woocommerce_t4m_variations_as_one').closest('tr').show();
|
800 |
+
} else {
|
801 |
+
jQuery('#woocommerce_t4m_variations_as_one').closest('tr').hide();
|
802 |
+
}
|
803 |
+
}).change();
|
804 |
+
|
805 |
";
|
806 |
|
807 |
+
$this->run_js( $js );
|
808 |
+
|
809 |
+
}
|
810 |
+
|
811 |
+
/**
|
812 |
+
* Includes inline JavaScript.
|
813 |
+
*
|
814 |
+
* @param $js
|
815 |
+
*/
|
816 |
+
protected function run_js( $js ) {
|
817 |
+
global $woocommerce;
|
818 |
+
if ( function_exists( 'wc_enqueue_js' ) ) {
|
819 |
+
wc_enqueue_js( $js );
|
820 |
} else {
|
821 |
$woocommerce->add_inline_js( $js );
|
822 |
}
|
823 |
+
}
|
824 |
|
825 |
+
protected function is_coupon_applied() {
|
826 |
+
global $woocommerce;
|
827 |
+
return !( empty( $woocommerce->cart->applied_coupons ) );
|
828 |
}
|
829 |
|
830 |
}
|
831 |
|
832 |
+
new Woo_Bulk_Discount_Plugin_t4m();
|
833 |
|
834 |
}
|