WooCommerce Bulk Discount - Version 2.1.1

Version Description

  • (13 Nov 2013) Feature of product variations reverted to 2.0 version state.
Download this release

Release Info

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

Code changes from version 2.1 to 2.1.1

Files changed (2) hide show
  1. readme.txt +8 -9
  2. woocommerce-bulk-discount.php +13 -29
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.1
7
- Stable tag: 2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -38,7 +38,7 @@ 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 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
@@ -82,12 +82,6 @@ which will be visible in the product description.
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,13 +138,15 @@ Setting bulk discounts couldn't have been easier.
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,6 +225,9 @@ Setting bulk discounts couldn't have been easier.
229
 
230
  == Upgrade Notice ==
231
 
 
 
 
232
  = 2.1 =
233
  Release with new features.
234
 
4
  Tags: woocommerce, bulk, discount
5
  Requires at least: 3.5
6
  Tested up to: 3.6.1
7
+ Stable tag: 2.1.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
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
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
  == Frequently Asked Questions ==
86
 
87
  = Are multiple discounts supported? How many levels of discounting may be applied? =
138
 
139
  == Changelog ==
140
 
141
+ = 2.1.1 =
142
+ * (13 Nov 2013) Feature of product variations reverted to 2.0 version state.
143
+
144
  = 2.1 =
145
  * (12 Nov 2013) Bulk discount is not applied if coupon code is used.
146
  * HTML markup is allowed in information about the bulk discount offer in Product Description.
147
  * Bulk Discount can be disabled more easily in the Product Options page.
148
  * There are further settings for applying bulk discount to product variations.
149
 
 
150
  = 2.0.12 =
151
  * (23 Oct 2013) Added Swedish translation.
152
 
225
 
226
  == Upgrade Notice ==
227
 
228
+ = 2.1.1 =
229
+ Maintenance release.
230
+
231
  = 2.1 =
232
  Release with new features.
233
 
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.1
8
  Author URI: http://www.renepuchinger.com
9
  License: GPL3
10
 
@@ -212,13 +212,11 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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,11 +228,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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
  }
@@ -510,7 +504,7 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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>
@@ -713,15 +707,6 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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,19 +756,26 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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,14 +786,6 @@ if ( !class_exists( 'Woo_Bulk_Discount_Plugin_t4m' ) ) {
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 );
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.1
8
  Author URI: http://www.renepuchinger.com
9
  License: GPL3
10
 
212
  global $woocommerce;
213
  $cart = $woocommerce->cart;
214
  $this->discount_coeffs = array();
 
215
  if ( sizeof( $cart->cart_contents ) > 0 ) {
216
  foreach ( $cart->cart_contents as $cart_item_key => $values ) {
217
  $_product = $values['data'];
218
  $quantity = 0;
219
  if ( get_option( 'woocommerce_t4m_variations_separate', 'yes' ) == 'no' && $_product instanceof WC_Product_Variation && $_product->parent ) {
 
220
  $parent = $_product->parent;
221
  foreach ( $cart->cart_contents as $valuesInner ) {
222
  $p = $valuesInner['data'];
228
  } else {
229
  $quantity = $values['quantity'];
230
  }
231
+ $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'] = $this->get_discounted_coeff( $_product->id, $quantity );
 
 
 
 
232
  $this->discount_coeffs[$this->get_actual_id( $_product )]['orig_price'] = $_product->get_price();
233
  }
234
  }
504
 
505
  <div class="options_group">
506
  <?php
507
+ woocommerce_wp_checkbox( array( 'id' => '_bulkdiscount_enabled', 'value' => get_option('_bulkdiscount_enabled') ? get_option('_bulkdiscount_enabled') : 'yes', 'label' => __( 'Bulk Discount enabled', 'wc_bulk_discount' ) ) );
508
  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' ) );
509
  ?>
510
  </div>
707
  'default' => 'yes'
708
  ),
709
 
 
 
 
 
 
 
 
 
 
710
  array(
711
  'name' => __( 'Show discount information next to cart item price', 'wc_bulk_discount' ),
712
  'id' => 'woocommerce_t4m_show_on_item',
756
  'default' => 'color: #4AB915; font-weight: bold;'
757
  ),
758
 
759
+ array( 'type' => 'sectionend', 'id' => 't4m_bulk_discounts_options' ),
760
+
761
+ array(
762
+ 'desc' => 'If you find the WooCommerce Bulk Discount extension useful, please rate it <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/woocommerce-bulk-discount#postform">&#9733;&#9733;&#9733;&#9733;&#9733;</a>. You can also contact us if you want a custom tailored WooCommerce extension.',
763
+ 'id' => 'woocommerce_t4m_bulk_discount_notice_text',
764
+ 'type' => 'title'
765
+ ),
766
+
767
+ array( 'type' => 'sectionend', 'id' => 'woocommerce_t4m_bulk_discount_notice_text' )
768
 
769
  ) ); // End settings
770
 
771
  $js = "
772
  jQuery('#woocommerce_t4m_enable_bulk_discounts').change(function() {
773
 
774
+ 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();
775
 
776
  if ( jQuery(this).attr('checked') ) {
777
  jQuery('#woocommerce_t4m_cart_info').closest('tr').show();
778
  jQuery('#woocommerce_t4m_variations_separate').closest('tr').show();
 
779
  jQuery('#woocommerce_t4m_discount_type').closest('tr').show();
780
  jQuery('#woocommerce_t4m_css_old_price').closest('tr').show();
781
  jQuery('#woocommerce_t4m_css_new_price').closest('tr').show();
786
 
787
  }).change();
788
 
 
 
 
 
 
 
 
 
789
  ";
790
 
791
  $this->run_js( $js );