WooCommerce Bulk Discount - Version 2.4.4

Version Description

  • (20 Feb 2017) Making the plugin compatible with WooCommerce 2.7 (tested with 2.7 Beta 3).
Download this release

Release Info

Developer Rene Puchinger
Plugin Icon 128x128 WooCommerce Bulk Discount
Version 2.4.4
Comparing to
See all releases

Code changes from version 2.4.3 to 2.4.4

Files changed (2) hide show
  1. readme.txt +13 -4
  2. woocommerce-bulk-discount.php +27 -11
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.2
7
- Stable tag: 2.4.3
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.x to 2.7.x.**
19
 
20
  Let us examine some examples of usage.
21
 
@@ -165,8 +165,11 @@ In the bulk discount section of this private product set the discount as in the
165
 
166
  == Changelog ==
167
 
 
 
 
168
  = 2.4.3 =
169
- * (17 Feb 2017) Making the plugin compatible with WooCommerce 2.7.
170
 
171
  = 2.4.2 =
172
  * (25 May 2016) Testing the plugin with WooCommerce 2.6.
@@ -296,6 +299,12 @@ In the bulk discount section of this private product set the discount as in the
296
 
297
  == Upgrade Notice ==
298
 
 
 
 
 
 
 
299
  = 2.4.2 =
300
  New features release.
301
 
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.3
7
+ Stable tag: 2.4.4
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.x to 3.0.x.**
19
 
20
  Let us examine some examples of usage.
21
 
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
+
171
  = 2.4.3 =
172
+ * (17 Feb 2017) Making the plugin compatible with WooCommerce 2.7 (tested with 2.7 Beta 2).
173
 
174
  = 2.4.2 =
175
  * (25 May 2016) Testing the plugin with WooCommerce 2.6.
299
 
300
  == Upgrade Notice ==
301
 
302
+ = 2.4.4 =
303
+ Maintenance release.
304
+
305
+ = 2.4.3 =
306
+ Maintenance release.
307
+
308
  = 2.4.2 =
309
  New features release.
310
 
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.3
8
  Author URI: https://profiles.wordpress.org/rene-puchinger/
9
  License: GPL3
10
 
@@ -199,21 +199,21 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
199
 
200
  if ( !$this->bulk_discount_calculated ) {
201
  if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
202
- $discprice = woocommerce_price( $_product->get_price() - $coeff );
203
  } else if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) ) {
204
- $discprice = woocommerce_price( $_product->get_price() - $coeff / $this->discount_coeffs[$this->get_actual_id( $_product )]['quantity'] );
205
  } else {
206
- $discprice = woocommerce_price( $_product->get_price() * $coeff );
207
  }
208
  } else {
209
- $discprice = woocommerce_price( $_product->get_price() );
210
  }
211
 
212
- $oldprice = woocommerce_price( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] );
213
  $old_css = esc_attr( get_option( 'woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;' ) );
214
  $new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
215
  if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) {
216
- return "<span class='discount-info' title='" . sprintf( __( '%s bulk discount applied!', 'wc_bulk_discount' ), woocommerce_price( $coeff / $this->discount_coeffs[$this->get_actual_id( $_product )]['quantity'] ) ) . "'>" .
217
  "<span class='old-price' style='$old_css'>$oldprice</span>" .
218
  "<span class='new-price' style='$new_css'>$discprice</span></span>";
219
 
@@ -315,7 +315,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
315
  return $price;
316
  }
317
 
318
- $_product = get_product( $values['product_id'] );
319
  if ( get_post_meta( $values['product_id'], "_bulkdiscount_enabled", true ) != '' && get_post_meta( $values['product_id'], "_bulkdiscount_enabled", true ) !== 'yes' ) {
320
  return $price;
321
  }
@@ -527,11 +527,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
527
 
528
  $coeff = $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'];
529
  if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
530
- $newsubtotal = woocommerce_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
531
  } else if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) ) {
532
- $newsubtotal = woocommerce_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
533
  } else {
534
- $newsubtotal = woocommerce_price( $_product->get_price() * $quantity * $coeff );
535
  }
536
 
537
  return $newsubtotal;
@@ -1000,6 +1000,22 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
1000
  return $_product->id;
1001
  }
1002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1003
  }
1004
 
1005
  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.4
8
  Author URI: https://profiles.wordpress.org/rene-puchinger/
9
  License: GPL3
10
 
199
 
200
  if ( !$this->bulk_discount_calculated ) {
201
  if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
202
+ $discprice = $this->get_price( $_product->get_price() - $coeff );
203
  } else if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) ) {
204
+ $discprice = $this->get_price( $_product->get_price() - $coeff / $this->discount_coeffs[$this->get_actual_id( $_product )]['quantity'] );
205
  } else {
206
+ $discprice = $this->get_price( $_product->get_price() * $coeff );
207
  }
208
  } else {
209
+ $discprice = $this->get_price( $_product->get_price() );
210
  }
211
 
212
+ $oldprice = $this->get_price( $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] );
213
  $old_css = esc_attr( get_option( 'woocommerce_t4m_css_old_price', 'color: #777; text-decoration: line-through; margin-right: 4px;' ) );
214
  $new_css = esc_attr( get_option( 'woocommerce_t4m_css_new_price', 'color: #4AB915; font-weight: bold;' ) );
215
  if ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) {
216
+ return "<span class='discount-info' title='" . sprintf( __( '%s bulk discount applied!', 'wc_bulk_discount' ), $this->get_price( $coeff / $this->discount_coeffs[$this->get_actual_id( $_product )]['quantity'] ) ) . "'>" .
217
  "<span class='old-price' style='$old_css'>$oldprice</span>" .
218
  "<span class='new-price' style='$new_css'>$discprice</span></span>";
219
 
315
  return $price;
316
  }
317
 
318
+ $_product = $this->get_product( $values['product_id'] );
319
  if ( get_post_meta( $values['product_id'], "_bulkdiscount_enabled", true ) != '' && get_post_meta( $values['product_id'], "_bulkdiscount_enabled", true ) !== 'yes' ) {
320
  return $price;
321
  }
527
 
528
  $coeff = $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'];
529
  if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
530
+ $newsubtotal = $this->get_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
531
  } else if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'fixed' ) ) {
532
+ $newsubtotal = $this->get_price( max( 0, ( $_product->get_price() * $quantity ) - $coeff ) );
533
  } else {
534
+ $newsubtotal = $this->get_price( $_product->get_price() * $quantity * $coeff );
535
  }
536
 
537
  return $newsubtotal;
1000
  return $_product->id;
1001
  }
1002
 
1003
+ protected function get_price($price) {
1004
+ if ( version_compare( WOOCOMMERCE_VERSION, "2.7.0" ) >= 0 ) {
1005
+ return wc_price($price);
1006
+ } else {
1007
+ return woocommerce_price($price);
1008
+ }
1009
+ }
1010
+
1011
+ protected function get_product($id) {
1012
+ if ( version_compare( WOOCOMMERCE_VERSION, "2.7.0" ) >= 0 ) {
1013
+ return wc_get_product($id);
1014
+ } else {
1015
+ return get_product($id);
1016
+ }
1017
+ }
1018
+
1019
  }
1020
 
1021
  new Woo_Bulk_Discount_Plugin_t4m();