WooCommerce Bulk Discount - Version 2.4.0

Version Description

  • (12 Feb 2016) new feature - it is now possible to set the discount globally for all products.
Download this release

Release Info

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

Code changes from version 2.3.2 to 2.4.0

Files changed (2) hide show
  1. readme.txt +21 -6
  2. woocommerce-bulk-discount.php +23 -18
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.6
6
  Tested up to: 4.4.2
7
- Stable tag: 2.3.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -37,18 +37,19 @@ policies to be adopted in your store.
37
 
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 by shared quantity when discounting.
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 can or cannot be applied if a coupon code is used, depending on configuration.
49
  * HTML markup is allowed in information about the bulk discount offer in Product Description.
50
  * Bulk Discount can be disabled more easily in the Product Options page.
51
- * Compatibility with WooCommerce 2.0.x to 2.3.x.
52
 
53
  WooCommerce Bulk Discount has been localised to these languages:
54
 
@@ -82,10 +83,13 @@ may choose to use a flat discount applied to the cart item subtotal. Optionally
82
  modify the CSS styles for the old value and the new value which is displayed in the cart.
83
  Save the settings.
84
 
85
- 2. Navigate to Products and choose a product for which you want to create a discount policy.
86
  In the Product Data panel, click Bulk Discount and optionally fill information about the discount
87
  which will be visible in the product description.
88
 
 
 
 
89
  3. Click "Add discount line" button to create a policy. Quantity (min.) means minimal
90
  number of ordered items so that the (second textbox) Discount applies. It is possible to
91
  add up to five discount lines to fine-tune the discount setting.
@@ -135,6 +139,11 @@ line will apply and the customer will pay (15 * 10) - 10 dollars. If the custome
135
  50 items, the second discount line will apply and the final price will be (50 * 10) - 20 dollars.
136
  Setting bulk discounts couldn't have been easier.
137
 
 
 
 
 
 
138
  == Screenshots ==
139
 
140
  1. Bulk Discount Settings page.
@@ -146,6 +155,9 @@ Setting bulk discounts couldn't have been easier.
146
 
147
  == Changelog ==
148
 
 
 
 
149
  = 2.3.2 =
150
  * (4 Feb 2016) Bugfix - the discount was not applied when the user created an account during checkout.
151
 
@@ -263,6 +275,9 @@ Setting bulk discounts couldn't have been easier.
263
 
264
  == Upgrade Notice ==
265
 
 
 
 
266
  = 2.3.2 =
267
  Bugfix release.
268
 
4
  Tags: woocommerce, bulk, discount
5
  Requires at least: 3.6
6
  Tested up to: 4.4.2
7
+ Stable tag: 2.4.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
37
 
38
  Here is the list of the main features:
39
 
40
+ * Possibility to set percentage bulk discount or flat (fixed) bulk discount in currency units.
41
+ * Possibility to set the discount individually per product.
42
+ * Possibility to set the discount globally for all products. **NEW - see the documentation**
43
  * Bulk discounts for product variations is supported to treat them separately or by shared quantity when discounting.
44
  * Discount is better visible and is available on several locations (see below).
45
+ * Discount is visible on the Checkout page.
46
+ * Discount is visible on the Order Details page.
47
  * Discount is visible in WooCommerce order e-mails and invoices as well.
48
  * Showing the applied discount when hovering over the item price in the cart.
49
  * Possibility of easily changing the CSS of the price before and after discount.
50
  * Bulk discount can or cannot be applied if a coupon code is used, depending on configuration.
51
  * HTML markup is allowed in information about the bulk discount offer in Product Description.
52
  * Bulk Discount can be disabled more easily in the Product Options page.
 
53
 
54
  WooCommerce Bulk Discount has been localised to these languages:
55
 
83
  modify the CSS styles for the old value and the new value which is displayed in the cart.
84
  Save the settings.
85
 
86
+ 2. If you want to set the discount individually per product then navigate to Products and choose a product for which you want to create a discount policy.
87
  In the Product Data panel, click Bulk Discount and optionally fill information about the discount
88
  which will be visible in the product description.
89
 
90
+ If you want to set the discount policy globally for all products, just create a private product with the title 'wc_bulk_discount_configurer' (without quotes).
91
+ In the bulk discount section of this private product set the discount as in the case of any individual product (see step 3).
92
+
93
  3. Click "Add discount line" button to create a policy. Quantity (min.) means minimal
94
  number of ordered items so that the (second textbox) Discount applies. It is possible to
95
  add up to five discount lines to fine-tune the discount setting.
139
  50 items, the second discount line will apply and the final price will be (50 * 10) - 20 dollars.
140
  Setting bulk discounts couldn't have been easier.
141
 
142
+ = How do I set the discount globally for all products? =
143
+ 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,
144
+ just create a private product with the title 'wc_bulk_discount_configurer' (without quotes). See <a href="https://codex.wordpress.org/Content_Visibility">https://codex.wordpress.org/Content_Visibility</a> how to make a post (and also product) private.
145
+ In the bulk discount section of this private product set the discount as in the case of any individual product. This discount configuration will override all individual discounts set on products (if they have been set).
146
+
147
  == Screenshots ==
148
 
149
  1. Bulk Discount Settings page.
155
 
156
  == Changelog ==
157
 
158
+ = 2.4.0 =
159
+ * (12 Feb 2016) new feature - it is now possible to set the discount globally for all products.
160
+
161
  = 2.3.2 =
162
  * (4 Feb 2016) Bugfix - the discount was not applied when the user created an account during checkout.
163
 
275
 
276
  == Upgrade Notice ==
277
 
278
+ = 2.4.0 =
279
+ New feature release.
280
+
281
  = 2.3.2 =
282
  Bugfix release.
283
 
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.3.2
8
  Author URI: https://profiles.wordpress.org/rene-puchinger/
9
  License: GPL3
10
 
@@ -67,7 +67,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
67
  }
68
 
69
  /**
70
- * Main processing hooks
71
  */
72
  public function woocommerce_loaded() {
73
 
@@ -104,13 +104,13 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
104
  * @return array
105
  */
106
  public function action_links( $links ) {
107
-
108
  $settings_slug = 'woocommerce';
109
-
110
  if ( version_compare( WOOCOMMERCE_VERSION, "2.1.0" ) >= 0 ) {
111
-
112
- $settings_slug = 'wc-settings';
113
-
114
  }
115
 
116
  $plugin_links = array(
@@ -133,6 +133,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
133
  $q = array( 0.0 );
134
  $d = array( 0.0 );
135
 
 
 
 
 
 
136
  /* Find the appropriate discount coefficient by looping through up to the five discount settings */
137
  for ( $i = 1; $i <= 5; $i++ ) {
138
  array_push( $q, get_post_meta( $product_id, "_bulkdiscount_quantity_$i", true ) );
@@ -347,7 +352,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
347
  return;
348
  }
349
 
350
- if ($this->bulk_discount_calculated) {
351
  return;
352
  }
353
 
@@ -379,7 +384,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
379
 
380
  global $woocommerce;
381
 
382
- if ($this->bulk_discount_calculated) {
383
  return $res;
384
  }
385
 
@@ -440,10 +445,10 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
440
  return;
441
  }
442
 
443
- if ( !$this->bulk_discount_calculated) {
444
  return;
445
  }
446
-
447
  if ( sizeof( $cart->cart_contents ) > 0 ) {
448
  foreach ( $cart->cart_contents as $cart_item_key => $values ) {
449
  $_product = $values['data'];
@@ -539,7 +544,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
539
  $style = 'style = "padding: 10px !important"';
540
  }
541
 
542
- echo '<li class="bulkdiscount_tab bulkdiscount_options"><a href="#bulkdiscount_product_data" '.$style.'>' . __( 'Bulk Discount', 'wc_bulk_discount' ) . '</a></li>';
543
 
544
  }
545
 
@@ -736,13 +741,13 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
736
  * @return void
737
  */
738
  public function add_tab() {
739
-
740
  $settings_slug = 'woocommerce';
741
-
742
  if ( version_compare( WOOCOMMERCE_VERSION, "2.1.0" ) >= 0 ) {
743
-
744
- $settings_slug = 'wc-settings';
745
-
746
  }
747
 
748
  foreach ( $this->settings_tabs as $name => $label ) {
@@ -966,7 +971,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
966
  }
967
 
968
  /**
969
- * @return bool
970
  */
971
  protected function coupon_check() {
972
 
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.0
8
  Author URI: https://profiles.wordpress.org/rene-puchinger/
9
  License: GPL3
10
 
67
  }
68
 
69
  /**
70
+ * Main processing hooks
71
  */
72
  public function woocommerce_loaded() {
73
 
104
  * @return array
105
  */
106
  public function action_links( $links ) {
107
+
108
  $settings_slug = 'woocommerce';
109
+
110
  if ( version_compare( WOOCOMMERCE_VERSION, "2.1.0" ) >= 0 ) {
111
+
112
+ $settings_slug = 'wc-settings';
113
+
114
  }
115
 
116
  $plugin_links = array(
133
  $q = array( 0.0 );
134
  $d = array( 0.0 );
135
 
136
+ $configurer = get_page_by_title( 'wc_bulk_discount_configurer', OBJECT, 'product' );
137
+ if ( $configurer && $configurer->ID && $configurer->post_status == 'private' ) {
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 ) );
352
  return;
353
  }
354
 
355
+ if ( $this->bulk_discount_calculated ) {
356
  return;
357
  }
358
 
384
 
385
  global $woocommerce;
386
 
387
+ if ( $this->bulk_discount_calculated ) {
388
  return $res;
389
  }
390
 
445
  return;
446
  }
447
 
448
+ if ( !$this->bulk_discount_calculated ) {
449
  return;
450
  }
451
+
452
  if ( sizeof( $cart->cart_contents ) > 0 ) {
453
  foreach ( $cart->cart_contents as $cart_item_key => $values ) {
454
  $_product = $values['data'];
544
  $style = 'style = "padding: 10px !important"';
545
  }
546
 
547
+ echo '<li class="bulkdiscount_tab bulkdiscount_options"><a href="#bulkdiscount_product_data" ' . $style . '>' . __( 'Bulk Discount', 'wc_bulk_discount' ) . '</a></li>';
548
 
549
  }
550
 
741
  * @return void
742
  */
743
  public function add_tab() {
744
+
745
  $settings_slug = 'woocommerce';
746
+
747
  if ( version_compare( WOOCOMMERCE_VERSION, "2.1.0" ) >= 0 ) {
748
+
749
+ $settings_slug = 'wc-settings';
750
+
751
  }
752
 
753
  foreach ( $this->settings_tabs as $name => $label ) {
971
  }
972
 
973
  /**
974
+ * @return bool
975
  */
976
  protected function coupon_check() {
977