Version Description
- (09 Apr 2017) Compatibility issues with WooCommerce 3.0 resolved.
Download this release
Release Info
Developer | Rene Puchinger |
Plugin | WooCommerce Bulk Discount |
Version | 2.4.5 |
Comparing to | |
See all releases |
Code changes from version 2.4.4 to 2.4.5
- readme.txt +18 -7
- woocommerce-bulk-discount.php +28 -7
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Rene Puchinger
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6VEQ8XXK6B3UE
|
4 |
Tags: woocommerce, bulk, discount
|
5 |
Requires at least: 3.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.4.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -15,7 +15,7 @@ Apply fine-grained bulk discounts to items in the shopping cart.
|
|
15 |
WooCommerce Bulk Discount makes it possible to apply fine-grained bulk discounts to items in the shopping cart,
|
16 |
depending on the ordered quantity and on the specific product.
|
17 |
|
18 |
-
**WooCommerce Bulk Discount is compatible with WooCommerce 2.0
|
19 |
|
20 |
Let us examine some examples of usage.
|
21 |
|
@@ -75,9 +75,7 @@ Once the plugin is activated, you can use it as follows:
|
|
75 |
configuration for bulk discounts. Make sure "Bulk Discount enabled" is checked and optionally
|
76 |
fill information about discounts which will be visible on the cart page. You can include HTML
|
77 |
markup in the text - you can, for instance, include a link to your page with your discount
|
78 |
-
policy.
|
79 |
-
"Treat product variations separately" option is unchecked. Since version 2.0 you
|
80 |
-
may choose to use a flat discount applied to the cart item subtotal. Optionally you may also
|
81 |
modify the CSS styles for the old value and the new value which is displayed in the cart.
|
82 |
Save the settings.
|
83 |
|
@@ -136,7 +134,6 @@ If the customer orders, say, 15 items of the product which costs $10 per item, t
|
|
136 |
line will apply and the customer will pay (15 * 10) - 10 dollars. If the customers orders
|
137 |
50 items, the second discount line will apply and the final price will be (50 * 10) - 20 dollars.
|
138 |
|
139 |
-
|
140 |
= Can you provide an example of setting a fixed bulk discount? =
|
141 |
Example for fixed discount follows:
|
142 |
|
@@ -148,6 +145,14 @@ line will apply and the customer will pay (15 * 10) - (15 * 2) = 15 * (10 - 2) d
|
|
148 |
50 items, the second discount line will apply and the final price will be (50 * 10) - (50 * 3) = 50 * (10 - 3) dollars.
|
149 |
**Note the difference between fixed and flat discount types!!! Flat discount is a discount from the line subtotal while fixed discount is applied on each individual quantity.**
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
= How do I set the discount globally for all products? =
|
153 |
This feature has been added to version 2.4.0 of WooCommerce Bulk Discount. If you want to set the discount policy globally for all products,
|
@@ -165,6 +170,9 @@ In the bulk discount section of this private product set the discount as in the
|
|
165 |
|
166 |
== Changelog ==
|
167 |
|
|
|
|
|
|
|
168 |
= 2.4.4 =
|
169 |
* (20 Feb 2017) Making the plugin compatible with WooCommerce 2.7 (tested with 2.7 Beta 3).
|
170 |
|
@@ -299,6 +307,9 @@ In the bulk discount section of this private product set the discount as in the
|
|
299 |
|
300 |
== Upgrade Notice ==
|
301 |
|
|
|
|
|
|
|
302 |
= 2.4.4 =
|
303 |
Maintenance release.
|
304 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6VEQ8XXK6B3UE
|
4 |
Tags: woocommerce, bulk, discount
|
5 |
Requires at least: 3.6
|
6 |
+
Tested up to: 4.9.4
|
7 |
+
Stable tag: 2.4.5
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
15 |
WooCommerce Bulk Discount makes it possible to apply fine-grained bulk discounts to items in the shopping cart,
|
16 |
depending on the ordered quantity and on the specific product.
|
17 |
|
18 |
+
**WooCommerce Bulk Discount is compatible with WooCommerce 2.0 to 3.3.**
|
19 |
|
20 |
Let us examine some examples of usage.
|
21 |
|
75 |
configuration for bulk discounts. Make sure "Bulk Discount enabled" is checked and optionally
|
76 |
fill information about discounts which will be visible on the cart page. You can include HTML
|
77 |
markup in the text - you can, for instance, include a link to your page with your discount
|
78 |
+
policy. Since version 2.0 you may choose to use a flat discount applied to the cart item subtotal. Optionally you may also
|
|
|
|
|
79 |
modify the CSS styles for the old value and the new value which is displayed in the cart.
|
80 |
Save the settings.
|
81 |
|
134 |
line will apply and the customer will pay (15 * 10) - 10 dollars. If the customers orders
|
135 |
50 items, the second discount line will apply and the final price will be (50 * 10) - 20 dollars.
|
136 |
|
|
|
137 |
= Can you provide an example of setting a fixed bulk discount? =
|
138 |
Example for fixed discount follows:
|
139 |
|
145 |
50 items, the second discount line will apply and the final price will be (50 * 10) - (50 * 3) = 50 * (10 - 3) dollars.
|
146 |
**Note the difference between fixed and flat discount types!!! Flat discount is a discount from the line subtotal while fixed discount is applied on each individual quantity.**
|
147 |
|
148 |
+
= What does mean the "Treat the variations separately" checkbox? =
|
149 |
+
To illustrate what the setting means, let's have two variations: A and B of some product. Both have this bulk discount setting:
|
150 |
+
quantity = 10, discount = 10%
|
151 |
+
quantity = 20, discount = 50%.
|
152 |
+
If we have "Treat variations separately" checked, then when we order 10 times variation A and 10 times variation B, then 10% bulk discount will be applied on both cart lines.
|
153 |
+
If we have "Treat variations separately" unchecked, then when we order 10 times variation A and 10 times variation B, it will count the discount to 10 + 10 items,
|
154 |
+
i.e. 20 items together and now the discount 50% will apply to both cart lines.
|
155 |
+
Therefore in the first case we treated the variations separately in the computation of the discount and in the second case we treat them as shared.
|
156 |
|
157 |
= How do I set the discount globally for all products? =
|
158 |
This feature has been added to version 2.4.0 of WooCommerce Bulk Discount. If you want to set the discount policy globally for all products,
|
170 |
|
171 |
== Changelog ==
|
172 |
|
173 |
+
= 2.4.5 =
|
174 |
+
* (09 Apr 2017) Compatibility issues with WooCommerce 3.0 resolved.
|
175 |
+
|
176 |
= 2.4.4 =
|
177 |
* (20 Feb 2017) Making the plugin compatible with WooCommerce 2.7 (tested with 2.7 Beta 3).
|
178 |
|
307 |
|
308 |
== Upgrade Notice ==
|
309 |
|
310 |
+
= 2.4.5 =
|
311 |
+
Bugfix release.
|
312 |
+
|
313 |
= 2.4.4 =
|
314 |
Maintenance release.
|
315 |
|
woocommerce-bulk-discount.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WooCommerce Bulk Discount
|
|
4 |
Plugin URI: http://wordpress.org/plugins/woocommerce-bulk-discount/
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
-
Version: 2.4.
|
8 |
Author URI: https://profiles.wordpress.org/rene-puchinger/
|
9 |
License: GPL3
|
10 |
|
@@ -138,6 +138,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
138 |
$product_id = $configurer->ID;
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
141 |
/* Find the appropriate discount coefficient by looping through up to the five discount settings */
|
142 |
for ( $i = 1; $i <= 5; $i++ ) {
|
143 |
array_push( $q, get_post_meta( $product_id, "_bulkdiscount_quantity_$i", true ) );
|
@@ -153,7 +158,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
153 |
$d[0] = $d[$i];
|
154 |
}
|
155 |
}
|
156 |
-
|
157 |
// for percentage discount convert the resulting discount from % to the multiplying coefficient
|
158 |
if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) {
|
159 |
return max( 0, $d[0] * $quantity );
|
@@ -279,13 +284,13 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
279 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
280 |
$_product = $values['data'];
|
281 |
$quantity = 0;
|
282 |
-
if ( get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'no' && $_product instanceof WC_Product_Variation && $_product
|
283 |
-
$parent = $_product
|
284 |
foreach ( $cart->cart_contents as $valuesInner ) {
|
285 |
$p = $valuesInner['data'];
|
286 |
-
if ( $p instanceof WC_Product_Variation && $p
|
287 |
$quantity += $valuesInner['quantity'];
|
288 |
-
$this->discount_coeffs[$_product
|
289 |
}
|
290 |
}
|
291 |
} else {
|
@@ -456,7 +461,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
456 |
protected function get_actual_id( $product ) {
|
457 |
|
458 |
if ( $product instanceof WC_Product_Variation ) {
|
459 |
-
return $product
|
460 |
} else {
|
461 |
return $this->get_product_id($product);
|
462 |
}
|
@@ -1015,7 +1020,23 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
|
|
1015 |
return get_product($id);
|
1016 |
}
|
1017 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1018 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1019 |
}
|
1020 |
|
1021 |
new Woo_Bulk_Discount_Plugin_t4m();
|
4 |
Plugin URI: http://wordpress.org/plugins/woocommerce-bulk-discount/
|
5 |
Description: Apply fine-grained bulk discounts to items in the shopping cart.
|
6 |
Author: Rene Puchinger
|
7 |
+
Version: 2.4.5
|
8 |
Author URI: https://profiles.wordpress.org/rene-puchinger/
|
9 |
License: GPL3
|
10 |
|
138 |
$product_id = $configurer->ID;
|
139 |
}
|
140 |
|
141 |
+
$product = $this->get_product($product_id);
|
142 |
+
if ($product instanceof WC_Product_Variation) {
|
143 |
+
$product_id = $product->get_parent_id();
|
144 |
+
}
|
145 |
+
|
146 |
/* Find the appropriate discount coefficient by looping through up to the five discount settings */
|
147 |
for ( $i = 1; $i <= 5; $i++ ) {
|
148 |
array_push( $q, get_post_meta( $product_id, "_bulkdiscount_quantity_$i", true ) );
|
158 |
$d[0] = $d[$i];
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
// for percentage discount convert the resulting discount from % to the multiplying coefficient
|
163 |
if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) {
|
164 |
return max( 0, $d[0] * $quantity );
|
284 |
foreach ( $cart->cart_contents as $cart_item_key => $values ) {
|
285 |
$_product = $values['data'];
|
286 |
$quantity = 0;
|
287 |
+
if ( get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'no' && $_product instanceof WC_Product_Variation && $this->get_parent($_product) ) {
|
288 |
+
$parent = $this->get_parent($_product);
|
289 |
foreach ( $cart->cart_contents as $valuesInner ) {
|
290 |
$p = $valuesInner['data'];
|
291 |
+
if ( $p instanceof WC_Product_Variation && $this->get_parent($p) && $this->get_product_id($this->get_parent($p)) == $this->get_product_id($parent) ) {
|
292 |
$quantity += $valuesInner['quantity'];
|
293 |
+
$this->discount_coeffs[$this->get_variation_id($_product)]['quantity'] = $quantity;
|
294 |
}
|
295 |
}
|
296 |
} else {
|
461 |
protected function get_actual_id( $product ) {
|
462 |
|
463 |
if ( $product instanceof WC_Product_Variation ) {
|
464 |
+
return $this->get_variation_id($product);
|
465 |
} else {
|
466 |
return $this->get_product_id($product);
|
467 |
}
|
1020 |
return get_product($id);
|
1021 |
}
|
1022 |
}
|
1023 |
+
|
1024 |
+
protected function get_variation_id($_product) {
|
1025 |
+
if ( version_compare( WOOCOMMERCE_VERSION, "2.7.0" ) >= 0 ) {
|
1026 |
+
return $_product->get_id();
|
1027 |
+
} else {
|
1028 |
+
return $_product->variation_id;
|
1029 |
+
}
|
1030 |
+
}
|
1031 |
|
1032 |
+
protected function get_parent($_product) {
|
1033 |
+
if ( version_compare( WOOCOMMERCE_VERSION, "2.7.0" ) >= 0 ) {
|
1034 |
+
return $this->get_product($_product->get_parent_id());
|
1035 |
+
} else {
|
1036 |
+
return $_product->parent;
|
1037 |
+
}
|
1038 |
+
}
|
1039 |
+
|
1040 |
}
|
1041 |
|
1042 |
new Woo_Bulk_Discount_Plugin_t4m();
|