Version Description
- (9 Oct 2013) Translations updated.
- Minor code formatting changes.
Download this release
Release Info
Developer | Rene Puchinger |
Plugin | WooCommerce Bulk Discount |
Version | 2.0.9 |
Comparing to | |
See all releases |
Code changes from version 2.0.8 to 2.0.9
- lang/wc_bulk_discount-pt_PT.mo +0 -0
- lang/wc_bulk_discount-pt_PT.po +72 -41
- readme.txt +8 -1
- woocommerce-bulk-discount.php +632 -657
lang/wc_bulk_discount-pt_PT.mo
CHANGED
Binary file
|
lang/wc_bulk_discount-pt_PT.po
CHANGED
@@ -6,8 +6,8 @@ msgid ""
|
|
6 |
msgstr ""
|
7 |
"Project-Id-Version: WooCommerce Bulk Discount v2.0.5\n"
|
8 |
"Report-Msgid-Bugs-To: jpBenfic@<jp.jp@sapo.pt>\n"
|
9 |
-
"POT-Creation-Date:
|
10 |
-
"PO-Revision-Date: 2013-09
|
11 |
"Last-Translator: jpBenfica <jp.jp@sapo.pt>\n"
|
12 |
"Language-Team: Portuguese <jp.jp@sapo.pt>\n"
|
13 |
"Language: Portuguese\n"
|
@@ -15,56 +15,65 @@ msgstr ""
|
|
15 |
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
"Content-Transfer-Encoding: 8bit\n"
|
17 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
18 |
-
"X-Generator:
|
19 |
"X-Poedit-SourceCharset: utf-8\n"
|
20 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
21 |
"X-Poedit-Basepath: ../\n"
|
22 |
"X-Poedit-SourceCharset: utf-8\n"
|
23 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
24 |
"X-Poedit-Basepath: ../\n"
|
25 |
-
"X-Poedit-SearchPath-0: .\n"
|
26 |
"X-Poedit-SourceCharset: utf-8\n"
|
27 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
28 |
"X-Poedit-Basepath: ../\n"
|
29 |
"X-Poedit-SourceCharset: utf-8\n"
|
30 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
31 |
"X-Poedit-Basepath: ../\n"
|
32 |
-
"X-Poedit-SearchPath-0: .\n"
|
33 |
"X-Poedit-SourceCharset: utf-8\n"
|
34 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
35 |
"X-Poedit-Basepath: ../\n"
|
36 |
"X-Poedit-SourceCharset: utf-8\n"
|
37 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
38 |
"X-Poedit-Basepath: ../\n"
|
39 |
-
"X-Poedit-SearchPath-0: .\n"
|
40 |
"X-Poedit-SourceCharset: utf-8\n"
|
41 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
42 |
"X-Poedit-Basepath: ../\n"
|
43 |
"X-Poedit-SourceCharset: utf-8\n"
|
44 |
-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;
|
|
|
45 |
"X-Poedit-Basepath: ../\n"
|
46 |
"X-Poedit-SearchPath-0: .\n"
|
47 |
|
48 |
-
#: woocommerce-bulk-discount.php:48 woocommerce-bulk-discount.php:
|
49 |
-
#: woocommerce-bulk-discount.php:
|
50 |
msgid "Bulk Discount"
|
51 |
msgstr "Desconto de quantidade"
|
52 |
|
53 |
-
#: woocommerce-bulk-discount.php:
|
|
|
|
|
|
|
|
|
54 |
#, php-format
|
55 |
-
msgid "%
|
56 |
-
msgstr "%
|
57 |
|
58 |
-
#: woocommerce-bulk-discount.php:
|
59 |
#, php-format
|
60 |
msgid "Incl. %s discount"
|
61 |
msgstr "Inclui %s desconto"
|
62 |
|
63 |
-
#: woocommerce-bulk-discount.php:
|
64 |
msgid "Bulk discount info in product description"
|
65 |
msgstr "Informação de desconto de quantidade na descrição do produto"
|
66 |
|
67 |
-
#: woocommerce-bulk-discount.php:
|
68 |
msgid ""
|
69 |
"Optionally enter bulk discount information that will be visible on the "
|
70 |
"product page."
|
@@ -72,38 +81,38 @@ msgstr ""
|
|
72 |
"Opcionalmente, insira as informações de desconto de quantidade que serão "
|
73 |
"visíveis na página do produto."
|
74 |
|
75 |
-
#: woocommerce-bulk-discount.php:
|
76 |
msgid "Quantity (min.)"
|
77 |
msgstr "Quantidade (min.)"
|
78 |
|
79 |
-
#: woocommerce-bulk-discount.php:
|
80 |
msgid "Enter the minimal quantity for which the discount applies."
|
81 |
msgstr "Introduza a quantidade mínima para a qual se aplica o desconto."
|
82 |
|
83 |
-
#: woocommerce-bulk-discount.php:
|
84 |
#, php-format
|
85 |
msgid "Discount (%s)"
|
86 |
msgstr "Desconto (%s)"
|
87 |
|
88 |
-
#: woocommerce-bulk-discount.php:
|
89 |
#, php-format
|
90 |
msgid "Enter the flat discount in %s."
|
91 |
msgstr "Inserir o desconto fixo em %s."
|
92 |
|
93 |
-
#: woocommerce-bulk-discount.php:
|
94 |
msgid "Discount (%)"
|
95 |
msgstr "Desconto (%)"
|
96 |
|
97 |
-
#: woocommerce-bulk-discount.php:
|
98 |
msgid "Enter the discount in percents (Allowed values: 0 to 100)."
|
99 |
msgstr "Insira o desconto em porcentagens (Valores permitidos: 0 a 100)."
|
100 |
|
101 |
-
#: woocommerce-bulk-discount.php:
|
102 |
msgid "The following options are specific to product bulk discount."
|
103 |
msgstr ""
|
104 |
"As opções a seguir são específicas para o desconto de quantidade de produto."
|
105 |
|
106 |
-
#: woocommerce-bulk-discount.php:
|
107 |
msgid ""
|
108 |
"After changing the settings, it is recommended to clear all sessions in "
|
109 |
"WooCommerce > System Status > Tools."
|
@@ -111,15 +120,15 @@ msgstr ""
|
|
111 |
"Depois de alterar as configurações, recomenda-se limpar todas as sessões do "
|
112 |
"WooCommerce > Estado do Sistema > Ferramentas."
|
113 |
|
114 |
-
#: woocommerce-bulk-discount.php:
|
115 |
msgid "Bulk Discount enabled"
|
116 |
msgstr "Desconto de Quantidade habilitado"
|
117 |
|
118 |
-
#: woocommerce-bulk-discount.php:
|
119 |
msgid "Discount Type"
|
120 |
msgstr "Tipo de Desconto"
|
121 |
|
122 |
-
#: woocommerce-bulk-discount.php:
|
123 |
#, php-format
|
124 |
msgid ""
|
125 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
@@ -128,19 +137,19 @@ msgstr ""
|
|
128 |
"Selecione o tipo de desconto. Desconto Percentual deduz a quantidade de %% "
|
129 |
"do preço enquanto o Desconto Fixo deduz o montante fixo em %s"
|
130 |
|
131 |
-
#: woocommerce-bulk-discount.php:
|
132 |
msgid "Percentage Discount"
|
133 |
msgstr "Desconto Percentual"
|
134 |
|
135 |
-
#: woocommerce-bulk-discount.php:
|
136 |
msgid "Flat Discount"
|
137 |
msgstr "Desconto Fixo"
|
138 |
|
139 |
-
#: woocommerce-bulk-discount.php:
|
140 |
msgid "Treat product variations separately"
|
141 |
msgstr "Tratar as variações do produto separadamente"
|
142 |
|
143 |
-
#: woocommerce-bulk-discount.php:
|
144 |
msgid ""
|
145 |
"You need to have this option unchecked to handle discounts on product "
|
146 |
"variations as a whole."
|
@@ -148,18 +157,40 @@ msgstr ""
|
|
148 |
"Você precisa ter esta opção desmarcada para lidar com descontos sobre as "
|
149 |
"variações do produto como um todo."
|
150 |
|
151 |
-
#: woocommerce-bulk-discount.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
msgid "Optionally enter information about discounts visible on cart page."
|
153 |
msgstr ""
|
154 |
"Opcionalmente, insira as informações sobre descontos visíveis na página do "
|
155 |
"carrinho."
|
156 |
|
157 |
-
#: woocommerce-bulk-discount.php:
|
158 |
msgid "Optionally change the CSS for old price on cart before discounting."
|
159 |
msgstr ""
|
160 |
"Opcionalmente altere o CSS para preço antigo no carrinho antes de descontar."
|
161 |
|
162 |
-
#: woocommerce-bulk-discount.php:
|
163 |
msgid "Optionally change the CSS for new price on cart after discounting."
|
164 |
msgstr ""
|
165 |
-
"Opcionalmente, altere o CSS para novo preço no carrinho após descontar."
|
6 |
msgstr ""
|
7 |
"Project-Id-Version: WooCommerce Bulk Discount v2.0.5\n"
|
8 |
"Report-Msgid-Bugs-To: jpBenfic@<jp.jp@sapo.pt>\n"
|
9 |
+
"POT-Creation-Date: 2013-10-09 19:17+0100\n"
|
10 |
+
"PO-Revision-Date: 2013-10-09 19:19+0100\n"
|
11 |
"Last-Translator: jpBenfica <jp.jp@sapo.pt>\n"
|
12 |
"Language-Team: Portuguese <jp.jp@sapo.pt>\n"
|
13 |
"Language: Portuguese\n"
|
15 |
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
"Content-Transfer-Encoding: 8bit\n"
|
17 |
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
18 |
+
"X-Generator: Poedit 1.5.7\n"
|
19 |
"X-Poedit-SourceCharset: utf-8\n"
|
20 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
21 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
22 |
"X-Poedit-Basepath: ../\n"
|
23 |
"X-Poedit-SourceCharset: utf-8\n"
|
24 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
25 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
26 |
"X-Poedit-Basepath: ../\n"
|
|
|
27 |
"X-Poedit-SourceCharset: utf-8\n"
|
28 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
29 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
30 |
"X-Poedit-Basepath: ../\n"
|
31 |
"X-Poedit-SourceCharset: utf-8\n"
|
32 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
33 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
34 |
"X-Poedit-Basepath: ../\n"
|
|
|
35 |
"X-Poedit-SourceCharset: utf-8\n"
|
36 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
37 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
38 |
"X-Poedit-Basepath: ../\n"
|
39 |
"X-Poedit-SourceCharset: utf-8\n"
|
40 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
41 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
42 |
"X-Poedit-Basepath: ../\n"
|
|
|
43 |
"X-Poedit-SourceCharset: utf-8\n"
|
44 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
45 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
46 |
"X-Poedit-Basepath: ../\n"
|
47 |
"X-Poedit-SourceCharset: utf-8\n"
|
48 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
49 |
+
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
50 |
"X-Poedit-Basepath: ../\n"
|
51 |
"X-Poedit-SearchPath-0: .\n"
|
52 |
|
53 |
+
#: woocommerce-bulk-discount.php:48 woocommerce-bulk-discount.php:387
|
54 |
+
#: woocommerce-bulk-discount.php:586
|
55 |
msgid "Bulk Discount"
|
56 |
msgstr "Desconto de quantidade"
|
57 |
|
58 |
+
#: woocommerce-bulk-discount.php:98
|
59 |
+
msgid "Settings"
|
60 |
+
msgstr "Settings"
|
61 |
+
|
62 |
+
#: woocommerce-bulk-discount.php:163
|
63 |
#, php-format
|
64 |
+
msgid "%s%% bulk discount applied!"
|
65 |
+
msgstr "%s%% desconto de quantidade aplicado!"
|
66 |
|
67 |
+
#: woocommerce-bulk-discount.php:194 woocommerce-bulk-discount.php:260
|
68 |
#, php-format
|
69 |
msgid "Incl. %s discount"
|
70 |
msgstr "Inclui %s desconto"
|
71 |
|
72 |
+
#: woocommerce-bulk-discount.php:433
|
73 |
msgid "Bulk discount info in product description"
|
74 |
msgstr "Informação de desconto de quantidade na descrição do produto"
|
75 |
|
76 |
+
#: woocommerce-bulk-discount.php:433
|
77 |
msgid ""
|
78 |
"Optionally enter bulk discount information that will be visible on the "
|
79 |
"product page."
|
81 |
"Opcionalmente, insira as informações de desconto de quantidade que serão "
|
82 |
"visíveis na página do produto."
|
83 |
|
84 |
+
#: woocommerce-bulk-discount.php:447
|
85 |
msgid "Quantity (min.)"
|
86 |
msgstr "Quantidade (min.)"
|
87 |
|
88 |
+
#: woocommerce-bulk-discount.php:447
|
89 |
msgid "Enter the minimal quantity for which the discount applies."
|
90 |
msgstr "Introduza a quantidade mínima para a qual se aplica o desconto."
|
91 |
|
92 |
+
#: woocommerce-bulk-discount.php:449
|
93 |
#, php-format
|
94 |
msgid "Discount (%s)"
|
95 |
msgstr "Desconto (%s)"
|
96 |
|
97 |
+
#: woocommerce-bulk-discount.php:449
|
98 |
#, php-format
|
99 |
msgid "Enter the flat discount in %s."
|
100 |
msgstr "Inserir o desconto fixo em %s."
|
101 |
|
102 |
+
#: woocommerce-bulk-discount.php:451
|
103 |
msgid "Discount (%)"
|
104 |
msgstr "Desconto (%)"
|
105 |
|
106 |
+
#: woocommerce-bulk-discount.php:451
|
107 |
msgid "Enter the discount in percents (Allowed values: 0 to 100)."
|
108 |
msgstr "Insira o desconto em porcentagens (Valores permitidos: 0 a 100)."
|
109 |
|
110 |
+
#: woocommerce-bulk-discount.php:586
|
111 |
msgid "The following options are specific to product bulk discount."
|
112 |
msgstr ""
|
113 |
"As opções a seguir são específicas para o desconto de quantidade de produto."
|
114 |
|
115 |
+
#: woocommerce-bulk-discount.php:586
|
116 |
msgid ""
|
117 |
"After changing the settings, it is recommended to clear all sessions in "
|
118 |
"WooCommerce > System Status > Tools."
|
120 |
"Depois de alterar as configurações, recomenda-se limpar todas as sessões do "
|
121 |
"WooCommerce > Estado do Sistema > Ferramentas."
|
122 |
|
123 |
+
#: woocommerce-bulk-discount.php:589
|
124 |
msgid "Bulk Discount enabled"
|
125 |
msgstr "Desconto de Quantidade habilitado"
|
126 |
|
127 |
+
#: woocommerce-bulk-discount.php:598
|
128 |
msgid "Discount Type"
|
129 |
msgstr "Tipo de Desconto"
|
130 |
|
131 |
+
#: woocommerce-bulk-discount.php:600
|
132 |
#, php-format
|
133 |
msgid ""
|
134 |
"Select the type of discount. Percentage Discount deducts amount of %% from "
|
137 |
"Selecione o tipo de desconto. Desconto Percentual deduz a quantidade de %% "
|
138 |
"do preço enquanto o Desconto Fixo deduz o montante fixo em %s"
|
139 |
|
140 |
+
#: woocommerce-bulk-discount.php:607
|
141 |
msgid "Percentage Discount"
|
142 |
msgstr "Desconto Percentual"
|
143 |
|
144 |
+
#: woocommerce-bulk-discount.php:608
|
145 |
msgid "Flat Discount"
|
146 |
msgstr "Desconto Fixo"
|
147 |
|
148 |
+
#: woocommerce-bulk-discount.php:613
|
149 |
msgid "Treat product variations separately"
|
150 |
msgstr "Tratar as variações do produto separadamente"
|
151 |
|
152 |
+
#: woocommerce-bulk-discount.php:615
|
153 |
msgid ""
|
154 |
"You need to have this option unchecked to handle discounts on product "
|
155 |
"variations as a whole."
|
157 |
"Você precisa ter esta opção desmarcada para lidar com descontos sobre as "
|
158 |
"variações do produto como um todo."
|
159 |
|
160 |
+
#: woocommerce-bulk-discount.php:622
|
161 |
+
msgid "Show discount information next to cart item price"
|
162 |
+
msgstr "Mostrar informação de desconto junto ao preço do item no carrinho"
|
163 |
+
|
164 |
+
#: woocommerce-bulk-discount.php:624
|
165 |
+
msgid "Applies only to percentage discount."
|
166 |
+
msgstr "Aplica-se somente ao desconto percentual."
|
167 |
+
|
168 |
+
#: woocommerce-bulk-discount.php:631
|
169 |
+
msgid "Show discount information next to item subtotal price"
|
170 |
+
msgstr "Mostrar informação de desconto junto ao item preço subtotal"
|
171 |
+
|
172 |
+
#: woocommerce-bulk-discount.php:639
|
173 |
+
msgid "Show discount information next to item subtotal price in order history"
|
174 |
+
msgstr ""
|
175 |
+
"Mostrar informação de desconto junto ao item preço subtotal no histórico de "
|
176 |
+
"pedidos"
|
177 |
+
|
178 |
+
#: woocommerce-bulk-discount.php:641
|
179 |
+
msgid "Includes showing discount in order e-mails and invoices."
|
180 |
+
msgstr "Mostra o desconto em pedidos de e-mails e faturas."
|
181 |
+
|
182 |
+
#: woocommerce-bulk-discount.php:648
|
183 |
msgid "Optionally enter information about discounts visible on cart page."
|
184 |
msgstr ""
|
185 |
"Opcionalmente, insira as informações sobre descontos visíveis na página do "
|
186 |
"carrinho."
|
187 |
|
188 |
+
#: woocommerce-bulk-discount.php:655
|
189 |
msgid "Optionally change the CSS for old price on cart before discounting."
|
190 |
msgstr ""
|
191 |
"Opcionalmente altere o CSS para preço antigo no carrinho antes de descontar."
|
192 |
|
193 |
+
#: woocommerce-bulk-discount.php:663
|
194 |
msgid "Optionally change the CSS for new price on cart after discounting."
|
195 |
msgstr ""
|
196 |
+
"Opcionalmente, altere o CSS para novo preço no carrinho após descontar."
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -135,6 +135,10 @@ Setting bulk discounts couldn't have been easier.
|
|
135 |
|
136 |
== Changelog ==
|
137 |
|
|
|
|
|
|
|
|
|
138 |
= 2.0.8 =
|
139 |
* (6 Oct 2013) Refined discount precision for percentage discounts with decimal point (no impact on integer discounts).
|
140 |
* Translations updated.
|
@@ -199,6 +203,9 @@ Setting bulk discounts couldn't have been easier.
|
|
199 |
|
200 |
== Upgrade Notice ==
|
201 |
|
|
|
|
|
|
|
202 |
= 2.0.8 =
|
203 |
Maintenance release.
|
204 |
|
4 |
Tags: woocommerce, bulk, discount
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 2.0.9
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
135 |
|
136 |
== Changelog ==
|
137 |
|
138 |
+
= 2.0.9 =
|
139 |
+
* (9 Oct 2013) Translations updated.
|
140 |
+
* Minor code formatting changes.
|
141 |
+
|
142 |
= 2.0.8 =
|
143 |
* (6 Oct 2013) Refined discount precision for percentage discounts with decimal point (no impact on integer discounts).
|
144 |
* Translations updated.
|
203 |
|
204 |
== Upgrade Notice ==
|
205 |
|
206 |
+
= 2.0.9 =
|
207 |
+
Maintenance release.
|
208 |
+
|
209 |
= 2.0.8 =
|
210 |
Maintenance release.
|
211 |
|
woocommerce-bulk-discount.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WooCommerce Bulk Discount
|
|
4 |
Plugin URI: http://www.tools4me.net/wordpress/woocommerce-bulk-discount-plugin
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
-
Version: 2.0.
|
8 |
Author URI: http://www.renepuchinger.com
|
9 |
License: GPL3
|
10 |
|
@@ -32,654 +32,629 @@ if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get
|
|
32 |
|
33 |
if (!class_exists('Woo_Bulk_Discount_Plugin_t4m')) {
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
'css' => 'width:100%;',
|
659 |
-
'default' => 'color: #777; text-decoration: line-through; margin-right: 4px;'
|
660 |
-
),
|
661 |
-
|
662 |
-
array(
|
663 |
-
'name' => __('Optionally change the CSS for new price on cart after discounting.', 'wc_bulk_discount'),
|
664 |
-
'id' => 'woocommerce_t4m_css_new_price',
|
665 |
-
'type' => 'textarea',
|
666 |
-
'css' => 'width:100%;',
|
667 |
-
'default' => 'color: #4AB915; font-weight: bold;'
|
668 |
-
),
|
669 |
-
|
670 |
-
array('type' => 'sectionend', 'id' => 't4m_bulk_discounts_options'),
|
671 |
-
|
672 |
-
array(
|
673 |
-
'desc' => '<b>If you find WooCommerce Bulk Discount useful, please rate the plugin at <a 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>',
|
674 |
-
'id' => 'woocommerce_t4m_begging_text',
|
675 |
-
'type' => 'title'
|
676 |
-
),
|
677 |
-
|
678 |
-
array('type' => 'sectionend', 'id' => 'woocommerce_t4m_begging_text'),
|
679 |
-
|
680 |
-
)); // End settings
|
681 |
-
|
682 |
-
$js = "
|
683 |
jQuery('#woocommerce_t4m_enable_bulk_discounts').change(function(){
|
684 |
|
685 |
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();
|
@@ -699,16 +674,16 @@ if (!class_exists('Woo_Bulk_Discount_Plugin_t4m')) {
|
|
699 |
|
700 |
";
|
701 |
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
|
708 |
-
|
709 |
|
710 |
-
|
711 |
|
712 |
-
|
713 |
|
714 |
}
|
4 |
Plugin URI: http://www.tools4me.net/wordpress/woocommerce-bulk-discount-plugin
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
+
Version: 2.0.9
|
8 |
Author URI: http://www.renepuchinger.com
|
9 |
License: GPL3
|
10 |
|
32 |
|
33 |
if (!class_exists('Woo_Bulk_Discount_Plugin_t4m')) {
|
34 |
|
35 |
+
class Woo_Bulk_Discount_Plugin_t4m {
|
36 |
+
|
37 |
+
var $discount_coeffs;
|
38 |
+
|
39 |
+
public function __construct() {
|
40 |
+
|
41 |
+
load_plugin_textdomain('wc_bulk_discount', false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
42 |
+
|
43 |
+
$this->current_tab = (isset($_GET['tab'])) ? $_GET['tab'] : 'general';
|
44 |
+
|
45 |
+
$this->settings_tabs = array(
|
46 |
+
'bulk_discount' => __('Bulk Discount', 'wc_bulk_discount')
|
47 |
+
);
|
48 |
+
|
49 |
+
add_action('admin_enqueue_scripts', array($this, 'action_enqueue_dependencies_admin'));
|
50 |
+
add_action('wp_head', array($this, 'action_enqueue_dependencies'));
|
51 |
+
|
52 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'action_links'));
|
53 |
+
|
54 |
+
add_action('woocommerce_settings_tabs', array($this, 'add_tab'), 10);
|
55 |
+
|
56 |
+
// Run these actions when generating the settings tabs.
|
57 |
+
foreach ($this->settings_tabs as $name => $label) {
|
58 |
+
add_action('woocommerce_settings_tabs_' . $name, array($this, 'settings_tab_action'), 10);
|
59 |
+
add_action('woocommerce_update_options_' . $name, array($this, 'save_settings'), 10);
|
60 |
+
}
|
61 |
+
|
62 |
+
// Add the settings fields to each tab.
|
63 |
+
add_action('woocommerce_bulk_discount_settings', array($this, 'add_settings_fields'), 10);
|
64 |
+
|
65 |
+
if (get_option('woocommerce_t4m_enable_bulk_discounts', 'yes') == 'yes') {
|
66 |
+
add_action('woocommerce_before_calculate_totals', array($this, 'action_before_calculate'), 10, 1);
|
67 |
+
add_action('woocommerce_calculate_totals', array($this, 'action_after_calculate'), 10, 1);
|
68 |
+
add_action('woocommerce_before_cart_table', array($this, 'before_cart_table'));
|
69 |
+
add_action('woocommerce_single_product_summary', array($this, 'single_product_summary'), 45);
|
70 |
+
if (class_exists('WC_Inline_Javascript_Helper')) { // is WooCommerce 2.1 installed?
|
71 |
+
add_filter('woocommerce_cart_item_price', array($this, 'filter_item_price'), 10, 2);
|
72 |
+
} else {
|
73 |
+
add_filter('woocommerce_cart_item_price_html', array($this, 'filter_item_price'), 10, 2);
|
74 |
+
}
|
75 |
+
add_filter('woocommerce_cart_item_subtotal', array($this, 'filter_subtotal_price'), 10, 2);
|
76 |
+
add_filter('woocommerce_checkout_item_subtotal', array($this, 'filter_subtotal_price'), 10, 2);
|
77 |
+
add_filter('woocommerce_order_formatted_line_subtotal', array($this, 'filter_subtotal_order_price'), 10, 3);
|
78 |
+
add_filter('woocommerce_product_write_panel_tabs', array($this, 'action_product_write_panel_tabs'));
|
79 |
+
add_filter('woocommerce_product_write_panels', array($this, 'action_product_write_panels'));
|
80 |
+
add_action('woocommerce_process_product_meta', array($this, 'action_process_meta'));
|
81 |
+
add_filter('woocommerce_cart_product_subtotal', array($this, 'filter_cart_product_subtotal'), 10, 3);
|
82 |
+
add_action('woocommerce_checkout_update_order_meta', array($this, 'order_update_meta'));
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Add action links under WordPress > Plugins
|
89 |
+
*
|
90 |
+
* @param $links
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
public function action_links($links) {
|
94 |
+
|
95 |
+
$plugin_links = array(
|
96 |
+
'<a href="' . admin_url('admin.php?page=woocommerce&tab=bulk_discount') . '">' . __('Settings', 'woocommerce') . '</a>',
|
97 |
+
);
|
98 |
+
|
99 |
+
return array_merge($plugin_links, $links);
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* For given product, and quantity return the price modifying factor (percentage discount) or value to deduct (flat discount).
|
104 |
+
*
|
105 |
+
* @param $product_id
|
106 |
+
* @param $quantity
|
107 |
+
* @param $order
|
108 |
+
* @return float
|
109 |
+
*/
|
110 |
+
protected function get_discounted_coeff($product_id, $quantity) {
|
111 |
+
$q = array(0.0);
|
112 |
+
$d = array(0.0);
|
113 |
+
/* Find the appropriate discount coefficient by looping through up to the five discount settings */
|
114 |
+
for ($i = 1; $i <= 5; $i++) {
|
115 |
+
array_push($q, get_post_meta($product_id, "_bulkdiscount_quantity_$i", true));
|
116 |
+
if (get_option('woocommerce_t4m_discount_type', '') == 'flat') {
|
117 |
+
array_push($d, get_post_meta($product_id, "_bulkdiscount_discount_flat_$i", true) ? get_post_meta($product_id, "_bulkdiscount_discount_flat_$i", true) : 0.0);
|
118 |
+
} else {
|
119 |
+
array_push($d, get_post_meta($product_id, "_bulkdiscount_discount_$i", true) ? get_post_meta($product_id, "_bulkdiscount_discount_$i", true) : 0.0);
|
120 |
+
}
|
121 |
+
if ($quantity >= $q[$i] && $q[$i] > $q[0]) {
|
122 |
+
$q[0] = $q[$i];
|
123 |
+
$d[0] = $d[$i];
|
124 |
+
}
|
125 |
+
}
|
126 |
+
// for percentage discount convert the resulting discount from % to the multiplying coefficient
|
127 |
+
return (get_option('woocommerce_t4m_discount_type', '') == 'flat') ? max(0, $d[0]) : min(1.0, max(0, (100.0 - round($d[0], 2)) / 100.0));
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Filter product price so that the discount is visible.
|
132 |
+
*
|
133 |
+
* @param $price
|
134 |
+
* @param $values
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
public function filter_item_price($price, $values) {
|
138 |
+
global $woocommerce;
|
139 |
+
if ((get_option('woocommerce_t4m_show_on_item', 'yes') == 'no')) {
|
140 |
+
return $price;
|
141 |
+
}
|
142 |
+
if ((get_option('woocommerce_t4m_discount_type', '') == 'flat')) {
|
143 |
+
return $price; // for flat discount this filter has no meaning
|
144 |
+
}
|
145 |
+
$_product = $values['data'];
|
146 |
+
if (empty($this->discount_coeffs) || !isset($this->discount_coeffs[$this->get_actual_id($_product)])
|
147 |
+
|| !isset($this->discount_coeffs[$this->get_actual_id($_product)]['orig_price']) || !isset($this->discount_coeffs[$this->get_actual_id($_product)]['coeff'])
|
148 |
+
) {
|
149 |
+
$this->gather_discount_coeffs();
|
150 |
+
}
|
151 |
+
$coeff = $this->discount_coeffs[$this->get_actual_id($_product)]['coeff'];
|
152 |
+
if ($coeff == 1.0) {
|
153 |
+
return $price; // no price modification
|
154 |
+
}
|
155 |
+
$discprice = woocommerce_price($_product->get_price() * $coeff);
|
156 |
+
$oldprice = woocommerce_price($this->discount_coeffs[$this->get_actual_id($_product)]['orig_price']);
|
157 |
+
$old_css = esc_attr(get_option('woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;'));
|
158 |
+
$new_css = esc_attr(get_option('woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;'));
|
159 |
+
return "<span class='discount-info' title='" . sprintf(__('%s%% bulk discount applied!', 'wc_bulk_discount'), round((1.0 - $coeff) * 100.0, 2)) . "'>" .
|
160 |
+
"<span class='old-price' style='$old_css'>$oldprice</span>" .
|
161 |
+
"<span class='new-price' style='$new_css'>$discprice</span></span>";
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Filter product price so that the discount is visible.
|
166 |
+
*
|
167 |
+
* @param $price
|
168 |
+
* @param $values
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
public function filter_subtotal_price($price, $values) {
|
172 |
+
global $woocommerce;
|
173 |
+
if ((get_option('woocommerce_t4m_show_on_subtotal', 'yes') == 'no')) {
|
174 |
+
return $price;
|
175 |
+
}
|
176 |
+
$_product = $values['data'];
|
177 |
+
if (empty($this->discount_coeffs) || !isset($this->discount_coeffs[$this->get_actual_id($_product)])
|
178 |
+
|| !isset($this->discount_coeffs[$this->get_actual_id($_product)]['orig_price']) || !isset($this->discount_coeffs[$this->get_actual_id($_product)]['coeff'])
|
179 |
+
) {
|
180 |
+
$this->gather_discount_coeffs();
|
181 |
+
}
|
182 |
+
$coeff = $this->discount_coeffs[$this->get_actual_id($_product)]['coeff'];
|
183 |
+
if ((get_option('woocommerce_t4m_discount_type', '') == 'flat' && $coeff == 0) || (get_option('woocommerce_t4m_discount_type', '') == '' && $coeff == 1.0)) {
|
184 |
+
return $price; // no price modification
|
185 |
+
}
|
186 |
+
$oldprice = woocommerce_price($this->discount_coeffs[$this->get_actual_id($_product)]['orig_price']);
|
187 |
+
$old_css = esc_attr(get_option('woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;'));
|
188 |
+
$new_css = esc_attr(get_option('woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;'));
|
189 |
+
$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) . "%")));
|
190 |
+
return "<span class='discount-info' title='$bulk_info'>" .
|
191 |
+
"<span>$price</span>" .
|
192 |
+
"<span class='new-price' style='$new_css'> ($bulk_info)</span></span>";
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Gather discount information to the array $this->discount_coefs
|
197 |
+
*/
|
198 |
+
protected function gather_discount_coeffs() {
|
199 |
+
global $woocommerce;
|
200 |
+
$cart = $woocommerce->cart;
|
201 |
+
$this->discount_coeffs = array();
|
202 |
+
if (sizeof($cart->cart_contents) > 0) {
|
203 |
+
foreach ($cart->cart_contents as $cart_item_key => $values) {
|
204 |
+
$_product = $values['data'];
|
205 |
+
$quantity = 0;
|
206 |
+
if (get_option('woocommerce_t4m_variations_separate', 'yes') == 'no' && $_product instanceof WC_Product_Variation && $_product->parent) {
|
207 |
+
$parent = $_product->parent;
|
208 |
+
foreach ($cart->cart_contents as $valuesInner) {
|
209 |
+
$p = $valuesInner['data'];
|
210 |
+
if ($p instanceof WC_Product_Variation && $p->parent && $p->parent->id == $parent->id) {
|
211 |
+
$quantity += $valuesInner['quantity'];
|
212 |
+
$this->discount_coeffs[$_product->variation_id]['quantity'] = $quantity;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
} else {
|
216 |
+
$quantity = $values['quantity'];
|
217 |
+
}
|
218 |
+
$this->discount_coeffs[$this->get_actual_id($_product)]['coeff'] = $this->get_discounted_coeff($_product->id, $quantity);
|
219 |
+
$this->discount_coeffs[$this->get_actual_id($_product)]['orig_price'] = $_product->get_price();
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Filter product price so that the discount is visible during order viewing.
|
226 |
+
*
|
227 |
+
* @param $price
|
228 |
+
* @param $values
|
229 |
+
* @return string
|
230 |
+
*/
|
231 |
+
public function filter_subtotal_order_price($price, $values, $order) {
|
232 |
+
global $woocommerce;
|
233 |
+
if ((get_option('woocommerce_t4m_show_on_order_subtotal', 'yes') == 'no')) {
|
234 |
+
return $price;
|
235 |
+
}
|
236 |
+
$_product = get_product($values['product_id']);
|
237 |
+
$actual_id = $values['product_id'];
|
238 |
+
if ($_product && $_product instanceof WC_Product_Variable && $values['variation_id']) {
|
239 |
+
$actual_id = $values['variation_id'];
|
240 |
+
}
|
241 |
+
$discount_coeffs = $this->gather_discount_coeffs_from_order($order->id);
|
242 |
+
if (empty($discount_coeffs)) {
|
243 |
+
return $price;
|
244 |
+
}
|
245 |
+
$coeff = $discount_coeffs[$actual_id]['coeff'];
|
246 |
+
$discount_type = get_post_meta($order->id, '_woocommerce_t4m_discount_type', true);
|
247 |
+
if (($discount_type == 'flat' && $coeff == 0) || ($discount_type == '' && $coeff == 1.0)) {
|
248 |
+
return $price; // no price modification
|
249 |
+
}
|
250 |
+
$oldprice = woocommerce_price($discount_coeffs[$actual_id]['orig_price']);
|
251 |
+
$old_css = esc_attr(get_option('woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;'));
|
252 |
+
$new_css = esc_attr(get_option('woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;'));
|
253 |
+
$bulk_info = sprintf(__('Incl. %s discount', 'wc_bulk_discount'), ($discount_type == 'flat' ? get_woocommerce_currency_symbol() . $coeff : (round((1 - $coeff) * 100, 2) . "%")));
|
254 |
+
return "<span class='discount-info' title='$bulk_info'>" .
|
255 |
+
"<span>$price</span>" .
|
256 |
+
"<span class='new-price' style='$new_css'> ($bulk_info)</span></span>";
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Gather discount information from order.
|
261 |
+
*
|
262 |
+
* @param $order_id
|
263 |
+
* @return array
|
264 |
+
*/
|
265 |
+
protected function gather_discount_coeffs_from_order($order_id) {
|
266 |
+
$meta = get_post_meta($order_id, '_woocommerce_t4m_discount_coeffs', true);
|
267 |
+
if (!$meta) {
|
268 |
+
return null;
|
269 |
+
}
|
270 |
+
$order_discount_coeffs = json_decode($meta, true);
|
271 |
+
return $order_discount_coeffs;
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Hook to woocommerce_before_calculate_totals action.
|
276 |
+
*
|
277 |
+
* @param WC_Cart $cart
|
278 |
+
*/
|
279 |
+
public function action_before_calculate(WC_Cart $cart) {
|
280 |
+
|
281 |
+
$this->gather_discount_coeffs();
|
282 |
+
|
283 |
+
if (sizeof($cart->cart_contents) > 0) {
|
284 |
+
foreach ($cart->cart_contents as $cart_item_key => $values) {
|
285 |
+
$_product = $values['data'];
|
286 |
+
if ((get_option('woocommerce_t4m_discount_type', '') == 'flat')) {
|
287 |
+
$row_base_price = max(0, $_product->get_price() - ($this->discount_coeffs[$this->get_actual_id($_product)]['coeff'] / $values['quantity']));
|
288 |
+
} else {
|
289 |
+
$row_base_price = $_product->get_price() * $this->discount_coeffs[$this->get_actual_id($_product)]['coeff'];
|
290 |
+
}
|
291 |
+
|
292 |
+
$values['data']->set_price($row_base_price);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
protected function get_actual_id($product) {
|
298 |
+
if ($product instanceof WC_Product_Variation) {
|
299 |
+
return $product->variation_id;
|
300 |
+
} else {
|
301 |
+
return $product->id;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Hook to woocommerce_calculate_totals.
|
307 |
+
*
|
308 |
+
* @param WC_Cart $cart
|
309 |
+
*/
|
310 |
+
public function action_after_calculate(WC_Cart $cart) {
|
311 |
+
if (sizeof($cart->cart_contents) > 0) {
|
312 |
+
foreach ($cart->cart_contents as $cart_item_key => $values) {
|
313 |
+
$_product = $values['data'];
|
314 |
+
$values['data']->set_price($this->discount_coeffs[$this->get_actual_id($_product)]['orig_price']);
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Show discount info in cart.
|
321 |
+
*/
|
322 |
+
public function before_cart_table() {
|
323 |
+
echo "<div class='cart-show-discounts'>";
|
324 |
+
echo get_option('woocommerce_t4m_cart_info');
|
325 |
+
echo "</div>";
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Hook to woocommerce_cart_product_subtotal filter.
|
330 |
+
*
|
331 |
+
* @param $subtotal
|
332 |
+
* @param $_product
|
333 |
+
* @param $quantity
|
334 |
+
* @param WC_Cart $cart
|
335 |
+
* @return string
|
336 |
+
*/
|
337 |
+
public function filter_cart_product_subtotal($subtotal, $_product, $quantity) {
|
338 |
+
$coeff = $this->discount_coeffs[$this->get_actual_id($_product)]['coeff'];
|
339 |
+
if ((get_option('woocommerce_t4m_discount_type', '') == 'flat')) {
|
340 |
+
$newsubtotal = woocommerce_price(max(0, ($_product->get_price() * $quantity) - $coeff));
|
341 |
+
} else {
|
342 |
+
$newsubtotal = woocommerce_price($_product->get_price() * $quantity * $coeff);
|
343 |
+
}
|
344 |
+
return $newsubtotal;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Store discount info to order as well
|
349 |
+
*
|
350 |
+
* @param $order_id
|
351 |
+
*/
|
352 |
+
public function order_update_meta($order_id) {
|
353 |
+
update_post_meta($order_id, "_woocommerce_t4m_discount_type", get_option('woocommerce_t4m_discount_type', ''));
|
354 |
+
update_post_meta($order_id, "_woocommerce_t4m_discount_coeffs", json_encode($this->discount_coeffs));
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Display discount information in Product Detail.
|
359 |
+
*/
|
360 |
+
public function single_product_summary() {
|
361 |
+
global $thepostid, $post;
|
362 |
+
if (!$thepostid) $thepostid = $post->ID;
|
363 |
+
echo "<div class='productinfo-show-discounts'>";
|
364 |
+
echo get_post_meta($thepostid, '_bulkdiscount_text_info', true);
|
365 |
+
echo "</div>";
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Add entry to Product Settings.
|
370 |
+
*/
|
371 |
+
public function action_product_write_panel_tabs() {
|
372 |
+
echo '<li class="bulkdiscount_tab bulkdiscount_options"><a href="#bulkdiscount_product_data">' . __('Bulk Discount', 'wc_bulk_discount') . '</a></li>';
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Add entry content to Product Settings.
|
377 |
+
*/
|
378 |
+
public function action_product_write_panels() {
|
379 |
+
global $thepostid, $post;
|
380 |
+
if (!$thepostid) $thepostid = $post->ID;
|
381 |
+
?>
|
382 |
+
<script type="text/javascript">
|
383 |
+
jQuery(document).ready(function () {
|
384 |
+
<?php
|
385 |
+
for($i = 1; $i <= 5; $i++) :
|
386 |
+
?>
|
387 |
+
jQuery('#bulkdiscount_product_data').find('.block<?php echo $i; ?>').hide();
|
388 |
+
jQuery('#bulkdiscount_product_data').find('.options_group<?php echo max($i, 2); ?>').hide();
|
389 |
+
jQuery('#bulkdiscount_product_data').find('#add_discount_line<?php echo max($i, 2); ?>').hide();
|
390 |
+
jQuery("#bulkdiscount_product_data").find('#add_discount_line<?php echo $i; ?>').click(function () {
|
391 |
+
jQuery('#bulkdiscount_product_data').find('.block<?php echo $i; ?>').show(400);
|
392 |
+
jQuery('#bulkdiscount_product_data').find('.options_group<?php echo min($i+1, 5); ?>').show(400);
|
393 |
+
jQuery('#bulkdiscount_product_data').find('#add_discount_line<?php echo min($i+1, 5); ?>').show(400);
|
394 |
+
jQuery('#bulkdiscount_product_data').find('#add_discount_line<?php echo $i; ?>').hide(400);
|
395 |
+
});
|
396 |
+
<?php
|
397 |
+
endfor;
|
398 |
+
for ($i = 1; $i <= 5; $i++) {
|
399 |
+
if (get_post_meta($thepostid, "_bulkdiscount_quantity_$i", true)) {
|
400 |
+
?>
|
401 |
+
jQuery('#bulkdiscount_product_data').find('.block<?php echo $i; ?>').show();
|
402 |
+
jQuery('#bulkdiscount_product_data').find('.options_group<?php echo $i; ?>').show();
|
403 |
+
jQuery("#bulkdiscount_product_data").find('#add_discount_line<?php echo $i; ?>').hide();
|
404 |
+
jQuery("#bulkdiscount_product_data").find('.options_group<?php echo min($i+1,5); ?>').show();
|
405 |
+
jQuery("#bulkdiscount_product_data").find('#add_discount_line<?php echo min($i+1,5); ?>').show();
|
406 |
+
<?php
|
407 |
+
}
|
408 |
+
}
|
409 |
+
?>
|
410 |
+
});
|
411 |
+
</script>
|
412 |
+
|
413 |
+
<div id="bulkdiscount_product_data" class="panel woocommerce_options_panel">
|
414 |
+
|
415 |
+
<div class="options_group">
|
416 |
+
<?php
|
417 |
+
woocommerce_wp_textarea_input(array('id' => "_bulkdiscount_text_info", 'label' => __('Bulk discount info 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'));
|
418 |
+
?>
|
419 |
+
</div>
|
420 |
+
|
421 |
+
<?php
|
422 |
+
for ($i = 1; $i <= 5; $i++) :
|
423 |
+
?>
|
424 |
+
|
425 |
+
<div class="options_group<?php echo $i; ?>">
|
426 |
+
<a id="add_discount_line<?php echo $i; ?>" class="button-secondary"
|
427 |
+
href="#block<?php echo $i; ?>">Add discount line</a>
|
428 |
+
|
429 |
+
<div class="block<?php echo $i; ?>">
|
430 |
+
<?php
|
431 |
+
woocommerce_wp_text_input(array('id' => "_bulkdiscount_quantity_$i", 'label' => __('Quantity (min.)', 'wc_bulk_discount'), 'description' => __('Enter the minimal quantity for which the discount applies.', 'wc_bulk_discount')));
|
432 |
+
if (get_option('woocommerce_t4m_discount_type', '') == 'flat') {
|
433 |
+
woocommerce_wp_text_input(array('id' => "_bulkdiscount_discount_flat_$i", '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())));
|
434 |
+
} else {
|
435 |
+
woocommerce_wp_text_input(array('id' => "_bulkdiscount_discount_$i", 'label' => __('Discount (%)', 'wc_bulk_discount'), 'description' => __('Enter the discount in percents (Allowed values: 0 to 100).', 'wc_bulk_discount')));
|
436 |
+
}
|
437 |
+
?>
|
438 |
+
</div>
|
439 |
+
</div>
|
440 |
+
|
441 |
+
<?php
|
442 |
+
endfor;
|
443 |
+
?>
|
444 |
+
|
445 |
+
<br/>
|
446 |
+
|
447 |
+
</div>
|
448 |
+
|
449 |
+
<?php
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Enqueue frontend dependencies.
|
454 |
+
*/
|
455 |
+
public function action_enqueue_dependencies() {
|
456 |
+
wp_register_style('woocommercebulkdiscount-style', plugins_url('css/style.css', __FILE__));
|
457 |
+
wp_enqueue_style('woocommercebulkdiscount-style');
|
458 |
+
wp_enqueue_script('jquery');
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Enqueue backend dependencies.
|
463 |
+
*/
|
464 |
+
public function action_enqueue_dependencies_admin() {
|
465 |
+
wp_register_style('woocommercebulkdiscount-style-admin', plugins_url('css/admin.css', __FILE__));
|
466 |
+
wp_enqueue_style('woocommercebulkdiscount-style-admin');
|
467 |
+
wp_enqueue_script('jquery');
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Updating post meta.
|
472 |
+
*
|
473 |
+
* @param $post_id
|
474 |
+
*/
|
475 |
+
public function action_process_meta($post_id) {
|
476 |
+
if (isset($_POST['_bulkdiscount_text_info'])) update_post_meta($post_id, '_bulkdiscount_text_info', esc_attr($_POST['_bulkdiscount_text_info']));
|
477 |
+
for ($i = 1; $i <= 5; $i++) {
|
478 |
+
if (isset($_POST["_bulkdiscount_quantity_$i"])) update_post_meta($post_id, "_bulkdiscount_quantity_$i", stripslashes($_POST["_bulkdiscount_quantity_$i"]));
|
479 |
+
if ((get_option('woocommerce_t4m_discount_type', '') == 'flat')) {
|
480 |
+
if (isset($_POST["_bulkdiscount_discount_flat_$i"])) update_post_meta($post_id, "_bulkdiscount_discount_flat_$i", stripslashes($_POST["_bulkdiscount_discount_flat_$i"]));
|
481 |
+
} else {
|
482 |
+
if (isset($_POST["_bulkdiscount_discount_$i"])) update_post_meta($post_id, "_bulkdiscount_discount_$i", stripslashes($_POST["_bulkdiscount_discount_$i"]));
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* @access public
|
489 |
+
* @return void
|
490 |
+
*/
|
491 |
+
public function add_tab() {
|
492 |
+
foreach ($this->settings_tabs as $name => $label) {
|
493 |
+
$class = 'nav-tab';
|
494 |
+
if ($this->current_tab == $name)
|
495 |
+
$class .= ' nav-tab-active';
|
496 |
+
echo '<a href="' . admin_url('admin.php?page=woocommerce&tab=' . $name) . '" class="' . $class . '">' . $label . '</a>';
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* @access public
|
502 |
+
* @return void
|
503 |
+
*/
|
504 |
+
public function settings_tab_action() {
|
505 |
+
global $woocommerce_settings;
|
506 |
+
|
507 |
+
// Determine the current tab in effect.
|
508 |
+
$current_tab = $this->get_tab_in_view(current_filter(), 'woocommerce_settings_tabs_');
|
509 |
+
|
510 |
+
// Hook onto this from another function to keep things clean.
|
511 |
+
do_action('woocommerce_bulk_discount_settings');
|
512 |
+
|
513 |
+
// Display settings for this tab (make sure to add the settings to the tab).
|
514 |
+
woocommerce_admin_fields($woocommerce_settings[$current_tab]);
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Save settings in a single field in the database for each tab's fields (one field per tab).
|
519 |
+
*/
|
520 |
+
public function save_settings() {
|
521 |
+
global $woocommerce_settings;
|
522 |
+
|
523 |
+
// Make sure our settings fields are recognised.
|
524 |
+
$this->add_settings_fields();
|
525 |
+
|
526 |
+
$current_tab = $this->get_tab_in_view(current_filter(), 'woocommerce_update_options_');
|
527 |
+
woocommerce_update_options($woocommerce_settings[$current_tab]);
|
528 |
+
}
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Get the tab current in view/processing.
|
532 |
+
*/
|
533 |
+
public function get_tab_in_view($current_filter, $filter_base) {
|
534 |
+
return str_replace($filter_base, '', $current_filter);
|
535 |
+
}
|
536 |
+
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Add settings fields for each tab.
|
540 |
+
*/
|
541 |
+
public function add_settings_fields() {
|
542 |
+
global $woocommerce_settings;
|
543 |
+
|
544 |
+
// Load the prepared form fields.
|
545 |
+
$this->init_form_fields();
|
546 |
+
|
547 |
+
if (is_array($this->fields))
|
548 |
+
foreach ($this->fields as $k => $v)
|
549 |
+
$woocommerce_settings[$k] = $v;
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Prepare form fields to be used in the various tabs.
|
554 |
+
*/
|
555 |
+
public function init_form_fields() {
|
556 |
+
global $woocommerce;
|
557 |
+
|
558 |
+
// Define settings
|
559 |
+
$this->fields['bulk_discount'] = apply_filters('woocommerce_bulk_discount_settings_fields', array(
|
560 |
+
|
561 |
+
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'),
|
562 |
+
|
563 |
+
array(
|
564 |
+
'name' => __('Bulk Discount enabled', 'wc_bulk_discount'),
|
565 |
+
'id' => 'woocommerce_t4m_enable_bulk_discounts',
|
566 |
+
'desc' => __('', 'wc_bulk_discount'),
|
567 |
+
'std' => 'yes',
|
568 |
+
'type' => 'checkbox',
|
569 |
+
'default' => 'yes'
|
570 |
+
),
|
571 |
+
|
572 |
+
array(
|
573 |
+
'title' => __('Discount Type', 'wc_bulk_discount'),
|
574 |
+
'id' => 'woocommerce_t4m_discount_type',
|
575 |
+
'desc' => sprintf(__('Select the type of discount. Percentage Discount deducts amount of %% from price while Flat Discount deducts fixed amount in %s', 'wc_bulk_discount'), get_woocommerce_currency_symbol()),
|
576 |
+
'desc_tip' => true,
|
577 |
+
'std' => 'yes',
|
578 |
+
'type' => 'select',
|
579 |
+
'css' => 'min-width:200px;',
|
580 |
+
'class' => 'chosen_select',
|
581 |
+
'options' => array(
|
582 |
+
'' => __('Percentage Discount', 'wc_bulk_discount'),
|
583 |
+
'flat' => __('Flat Discount', 'wc_bulk_discount')
|
584 |
+
)
|
585 |
+
),
|
586 |
+
|
587 |
+
array(
|
588 |
+
'name' => __('Treat product variations separately', 'wc_bulk_discount'),
|
589 |
+
'id' => 'woocommerce_t4m_variations_separate',
|
590 |
+
'desc' => __('You need to have this option unchecked to handle discounts on product variations as a whole.', 'wc_bulk_discount'),
|
591 |
+
'std' => 'yes',
|
592 |
+
'type' => 'checkbox',
|
593 |
+
'default' => 'yes'
|
594 |
+
),
|
595 |
+
|
596 |
+
array(
|
597 |
+
'name' => __('Show discount information next to cart item price', 'wc_bulk_discount'),
|
598 |
+
'id' => 'woocommerce_t4m_show_on_item',
|
599 |
+
'desc' => __('Applies only to percentage discount.', 'wc_bulk_discount'),
|
600 |
+
'std' => 'yes',
|
601 |
+
'type' => 'checkbox',
|
602 |
+
'default' => 'yes'
|
603 |
+
),
|
604 |
+
|
605 |
+
array(
|
606 |
+
'name' => __('Show discount information next to item subtotal price', 'wc_bulk_discount'),
|
607 |
+
'id' => 'woocommerce_t4m_show_on_subtotal',
|
608 |
+
'std' => 'yes',
|
609 |
+
'type' => 'checkbox',
|
610 |
+
'default' => 'yes'
|
611 |
+
),
|
612 |
+
|
613 |
+
array(
|
614 |
+
'name' => __('Show discount information next to item subtotal price in order history', 'wc_bulk_discount'),
|
615 |
+
'id' => 'woocommerce_t4m_show_on_order_subtotal',
|
616 |
+
'desc' => __('Includes showing discount in order e-mails and invoices.', 'wc_bulk_discount'),
|
617 |
+
'std' => 'yes',
|
618 |
+
'type' => 'checkbox',
|
619 |
+
'default' => 'yes'
|
620 |
+
),
|
621 |
+
|
622 |
+
array(
|
623 |
+
'name' => __('Optionally enter information about discounts visible on cart page.', 'wc_bulk_discount'),
|
624 |
+
'id' => 'woocommerce_t4m_cart_info',
|
625 |
+
'type' => 'textarea',
|
626 |
+
'css' => 'width:100%; height: 75px;'
|
627 |
+
),
|
628 |
+
|
629 |
+
array(
|
630 |
+
'name' => __('Optionally change the CSS for old price on cart before discounting.', 'wc_bulk_discount'),
|
631 |
+
'id' => 'woocommerce_t4m_css_old_price',
|
632 |
+
'type' => 'textarea',
|
633 |
+
'css' => 'width:100%;',
|
634 |
+
'default' => 'color: #777; text-decoration: line-through; margin-right: 4px;'
|
635 |
+
),
|
636 |
+
|
637 |
+
array(
|
638 |
+
'name' => __('Optionally change the CSS for new price on cart after discounting.', 'wc_bulk_discount'),
|
639 |
+
'id' => 'woocommerce_t4m_css_new_price',
|
640 |
+
'type' => 'textarea',
|
641 |
+
'css' => 'width:100%;',
|
642 |
+
'default' => 'color: #4AB915; font-weight: bold;'
|
643 |
+
),
|
644 |
+
|
645 |
+
array('type' => 'sectionend', 'id' => 't4m_bulk_discounts_options'),
|
646 |
+
|
647 |
+
array(
|
648 |
+
'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>',
|
649 |
+
'id' => 'woocommerce_t4m_begging_text',
|
650 |
+
'type' => 'title'
|
651 |
+
),
|
652 |
+
|
653 |
+
array('type' => 'sectionend', 'id' => 'woocommerce_t4m_begging_text'),
|
654 |
+
|
655 |
+
)); // End settings
|
656 |
+
|
657 |
+
$js = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
jQuery('#woocommerce_t4m_enable_bulk_discounts').change(function(){
|
659 |
|
660 |
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();
|
674 |
|
675 |
";
|
676 |
|
677 |
+
if (class_exists('WC_Inline_Javascript_Helper')) {
|
678 |
+
$woocommerce->get_helper('inline-javascript')->add_inline_js($js);
|
679 |
+
} else {
|
680 |
+
$woocommerce->add_inline_js($js);
|
681 |
+
}
|
682 |
|
683 |
+
}
|
684 |
|
685 |
+
}
|
686 |
|
687 |
+
$woo_bulk_discount_plugin = new Woo_Bulk_Discount_Plugin_t4m();
|
688 |
|
689 |
}
|