Discount Rules for WooCommerce - Version 1.8.2

Version Description

  • 14/11/19 =
  • Feature - Option to display promotion message in cart about the upcoming discount (Subtotal based).
  • Improvement - Upgrading to pro option in deactivation survey.
  • Improvement - WordPress 5.3 UI improvement.
  • Fix - PHP Fatal error Call to a member function get() on null while apply coupon through third-party plugin(On renewal subscription).
  • Fix - Wrong subtotal calculation while having tax settings as excluding tax and display by including tax.
  • Fix - Auto add free product on subtotal matches in price rule.
  • Fix - Dynamic coupon removed, while remove third party coupon option is enabled.
  • Fix - Loading trashed coupon in the selected coupon fields while having large number of coupons.
Download this release

Release Info

Developer flycart
Plugin Icon 128x128 Discount Rules for WooCommerce
Version 1.8.2
Comparing to
See all releases

Code changes from version 1.8.1 to 1.8.2

assets/css/style.css CHANGED
@@ -230,4 +230,32 @@ span.price_discount_amount_tool_tip{
230
  }
231
  .wdr_validation_notice{
232
  display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  }
230
  }
231
  .wdr_validation_notice{
232
  display: none;
233
+ }
234
+ .show_promotion_message_fields_con{
235
+ margin-top: 15px;
236
+ }
237
+ #promotion_qty_from, #promotion_subtotal_from{
238
+ max-width: 100px;
239
+ }
240
+ .woo_discount_loader_outer input[type=checkbox]{
241
+ width: 1.5rem;
242
+ height: 1.5rem;
243
+ }
244
+ .woo_discount_loader_outerinput[type=checkbox]::before,
245
+ .woo_discount_loader_outer input[type=checkbox]:checked::before{
246
+ width: 1.7rem;
247
+ height: 1.7rem;
248
+ }
249
+ .woo_discount_loader_outer input[type=radio]{
250
+ width: 1.5rem;
251
+ height: 1.5rem;
252
+ }
253
+ .woo_discount_loader_outer input[type=radio]::before,
254
+ .woo_discount_loader_outer input[type=radio]:checked::before{
255
+ width: .9rem;
256
+ height: .9rem;
257
+ margin: .2rem;
258
+ }
259
+ select#price_rule_method{
260
+ max-width: 100%;
261
  }
assets/css/woo_discount_rules.css CHANGED
@@ -26,4 +26,7 @@
26
  }
27
  .wdr_table_off_settings_hint{
28
  display: block;
 
 
 
29
  }
26
  }
27
  .wdr_table_off_settings_hint{
28
  display: block;
29
+ }
30
+ .wdr_checkout_promotion_messages_data{
31
+ display: none;
32
  }
assets/js/app.js CHANGED
@@ -831,6 +831,7 @@ function wooo_discount_range_altered() {
831
  $('#roles_div_' + count).css('display', 'none');
832
  $('#countries_div_' + count).css('display', 'none');
833
  $('#purchase_history_div_' + count).css('display', 'none');
 
834
  });
835
 
836
  $(document).on('change', '.cart_rule_type', function () {
@@ -838,7 +839,7 @@ function wooo_discount_range_altered() {
838
  id = id.replace('cart_condition_type_', '');
839
  var active = $(this).val();
840
  showOnly(active, id);
841
-
842
  });
843
 
844
  $('#cart_rule_discount_type').on('change', function () {
@@ -1095,6 +1096,7 @@ function wooo_discount_range_altered() {
1095
  var confirm_remove = confirm(woo_discount_localization.are_you_sure_to_remove);
1096
  if (confirm_remove) {
1097
  $(this).closest('.cart_rules_list').remove();
 
1098
  }
1099
  });
1100
 
@@ -1351,6 +1353,29 @@ function wooo_discount_range_altered() {
1351
  });
1352
  $('select.purchased_history_duration').trigger('change');
1353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1354
  //--------------------------------------------------------------------------------------------------------------
1355
  //-----------------------------------------------SIDE PANEL-----------------------------------------------------
1356
  //--------------------------------------------------------------------------------------------------------------
831
  $('#roles_div_' + count).css('display', 'none');
832
  $('#countries_div_' + count).css('display', 'none');
833
  $('#purchase_history_div_' + count).css('display', 'none');
834
+ $("#cart_rules_list").trigger('cart_rule_condition_updated');
835
  });
836
 
837
  $(document).on('change', '.cart_rule_type', function () {
839
  id = id.replace('cart_condition_type_', '');
840
  var active = $(this).val();
841
  showOnly(active, id);
842
+ $("#cart_rules_list").trigger('cart_rule_condition_updated');
843
  });
844
 
845
  $('#cart_rule_discount_type').on('change', function () {
1096
  var confirm_remove = confirm(woo_discount_localization.are_you_sure_to_remove);
1097
  if (confirm_remove) {
1098
  $(this).closest('.cart_rules_list').remove();
1099
+ $("#cart_rules_list").trigger('cart_rule_condition_updated');
1100
  }
1101
  });
1102
 
1353
  });
1354
  $('select.purchased_history_duration').trigger('change');
1355
 
1356
+ $("#cart_rules_list").on('cart_rule_condition_updated', function () {
1357
+ var cart_condition_type = $(this).find('select.cart_rule_type');
1358
+ var allow_promotion_message, has_subtotal_least, has_quantity_least;
1359
+ allow_promotion_message = has_subtotal_least = has_quantity_least = false;
1360
+ $(".promotion_subtotal_from_con").hide();
1361
+ $.each( cart_condition_type, function( key, container ) {
1362
+ var option_value = $(container).val();
1363
+ if(option_value == 'subtotal_least'){
1364
+ allow_promotion_message = true;
1365
+ if(option_value == 'subtotal_least'){
1366
+ has_subtotal_least = true;
1367
+ $(".promotion_subtotal_from_con").show();
1368
+ }
1369
+ }
1370
+ });
1371
+ if(allow_promotion_message === true){
1372
+ $(".show_promotion_message_cart_block").show();
1373
+ } else {
1374
+ $(".show_promotion_message_cart_block").hide();
1375
+ }
1376
+ });
1377
+ $("#cart_rules_list").trigger('cart_rule_condition_updated');
1378
+
1379
  //--------------------------------------------------------------------------------------------------------------
1380
  //-----------------------------------------------SIDE PANEL-----------------------------------------------------
1381
  //--------------------------------------------------------------------------------------------------------------
helper/general-helper.php CHANGED
@@ -1083,10 +1083,6 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
1083
  {
1084
  if(is_string($coupon_data)){
1085
  $used_coupon_codes = self::getDynamicUsedCouponsInRules();
1086
- // Getting Coupon Remove status from Session.
1087
- $is_removed = WC()->session->get('woo_coupon_removed');
1088
- // If Both are same, then it won't added.
1089
- if (in_array(wc_strtoupper($is_removed), $used_coupon_codes)) return $response;
1090
  if (in_array(wc_strtoupper($coupon_data), $used_coupon_codes)) {
1091
  $discount_type = 'percent';
1092
  $amount = 0;
@@ -1122,5 +1118,104 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
1122
 
1123
  return $response;
1124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1125
  }
1126
  }
1083
  {
1084
  if(is_string($coupon_data)){
1085
  $used_coupon_codes = self::getDynamicUsedCouponsInRules();
 
 
 
 
1086
  if (in_array(wc_strtoupper($coupon_data), $used_coupon_codes)) {
1087
  $discount_type = 'percent';
1088
  $amount = 0;
1118
 
1119
  return $response;
1120
  }
1121
+
1122
+ /**
1123
+ * Get promotion messages
1124
+ * */
1125
+ public static function getPromotionMessages(){
1126
+ return FlycartWoocommerceSession::getSession('woo_discount_promotion_messages_cart', array());
1127
+ }
1128
+
1129
+ /**
1130
+ * Clear promotion messages
1131
+ * */
1132
+ public static function clearCartPromotionMessages(){
1133
+ FlycartWoocommerceSession::setSession('woo_discount_promotion_messages_cart', array());
1134
+ }
1135
+
1136
+ /**
1137
+ * Set messages
1138
+ * */
1139
+ public static function setPromotionMessage($message, $rule_id = '', $type = 'cart'){
1140
+ $messages = FlycartWoocommerceSession::getSession('woo_discount_promotion_messages_'.$type, array());
1141
+ if(!is_array($messages)) $messages = array();
1142
+ if(!empty($messages) && in_array($message, $messages)){
1143
+ } else {
1144
+ if(empty($rule_id)){
1145
+ $messages[] = $message;
1146
+ } else {
1147
+ $messages[$rule_id] = $message;
1148
+ }
1149
+ }
1150
+
1151
+ FlycartWoocommerceSession::setSession('woo_discount_promotion_messages_'.$type, $messages);
1152
+ }
1153
+
1154
+ /**
1155
+ * Set messages
1156
+ * */
1157
+ public static function removePromotionMessage($rule_id, $type = 'cart'){
1158
+ $messages = FlycartWoocommerceSession::getSession('woo_discount_promotion_messages_'.$type, array());
1159
+ if(is_array($messages) && !empty($messages)){
1160
+ if(isset($messages[$rule_id])){
1161
+ unset($messages[$rule_id]);
1162
+ }
1163
+ }
1164
+
1165
+ FlycartWoocommerceSession::setSession('woo_discount_promotion_messages_'.$type, $messages);
1166
+ }
1167
+
1168
+ /**
1169
+ * Display promotional messages
1170
+ * */
1171
+ public static function displayPromotionMessages(){
1172
+ $messages = self::getPromotionMessages();
1173
+ if(!empty($messages) && is_array($messages)){
1174
+ foreach ($messages as $message){
1175
+ wc_print_notice($message, "notice");
1176
+ }
1177
+ }
1178
+ }
1179
+
1180
+ /**
1181
+ * Display promotional message in check out while processing order review
1182
+ * */
1183
+ public static function displayPromotionMessagesInCheckout(){
1184
+ echo "<div id='wdr_checkout_promotion_messages_data'>";
1185
+ self::displayPromotionMessages();
1186
+ echo "</div>";
1187
+ echo "<script>";
1188
+ echo "jQuery('#wdr_checkout_promotion_messages').html(jQuery('#wdr_checkout_promotion_messages_data').html());jQuery('#wdr_checkout_promotion_messages_data').remove()";
1189
+ echo "</script>";
1190
+ }
1191
+
1192
+ /**
1193
+ * Load outer div for displaying promotional message in check out
1194
+ * */
1195
+ public static function displayPromotionMessagesInCheckoutContainer(){
1196
+ echo "<div id='wdr_checkout_promotion_messages'>";
1197
+ echo "</div>";
1198
+ }
1199
+
1200
+ /**
1201
+ * Get calculated item subtotal manually
1202
+ *
1203
+ * @param $rule array
1204
+ * @return int/float
1205
+ * */
1206
+ public static function get_calculated_item_subtotal_manually($rule = array()){
1207
+ global $woocommerce;
1208
+ $sub_total = 0;
1209
+ if(count($woocommerce->cart->cart_contents)){
1210
+ foreach ($woocommerce->cart->cart_contents as $key => $cartItem) {
1211
+ $calculate_sub_total = apply_filters('woo_discount_rules_skip_item_to_calculate_subtotal_for_price_rules', true, $cartItem, $rule);
1212
+ if($calculate_sub_total === true){
1213
+ $sub_total += FlycartWooDiscountRulesCartRules::getSubTotalOfCartItem($cartItem);
1214
+ }
1215
+ }
1216
+ }
1217
+
1218
+ return $sub_total;
1219
+ }
1220
  }
1221
  }
helper/woo-function.php CHANGED
@@ -871,4 +871,39 @@ if(!class_exists('FlycartWoocommerceOrderItem')){
871
  return FlycartWoocommerceVersion::wcVersion('3.0') ? $order_item->get_order_id() : $order_item->order_id;
872
  }
873
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
  }
871
  return FlycartWoocommerceVersion::wcVersion('3.0') ? $order_item->get_order_id() : $order_item->order_id;
872
  }
873
  }
874
+ }
875
+
876
+ if(!class_exists('FlycartWoocommerceSession')){
877
+ class FlycartWoocommerceSession{
878
+
879
+ /**
880
+ * Get session value by key
881
+ * @param $key
882
+ * @param null $default
883
+ * @return mixed
884
+ */
885
+ public static function getSession($key, $default = NULL)
886
+ {
887
+ if (function_exists('WC')) {
888
+ if (method_exists(WC()->session, 'get')) {
889
+ return WC()->session->get($key);
890
+ }
891
+ }
892
+ return $default;
893
+ }
894
+
895
+ /**
896
+ * set session value
897
+ * @param $key string
898
+ * @param $value mixed
899
+ */
900
+ public static function setSession($key, $value)
901
+ {
902
+ if (function_exists('WC')) {
903
+ if (method_exists(WC()->session, 'set')) {
904
+ WC()->session->set($key, $value);
905
+ }
906
+ }
907
+ }
908
+ }
909
  }
i18n/languages/woo-discount-rules.pot CHANGED
@@ -152,7 +152,7 @@ msgstr ""
152
  msgid "Saved successfully"
153
  msgstr ""
154
 
155
- #: includes/cart-rules.php:163 includes/pricing-rules.php:153
156
  msgid "Failed to save"
157
  msgstr ""
158
 
@@ -165,7 +165,7 @@ msgstr ""
165
  #: view/pricing-rules.php:179 view/settings_cart_rules.php:95
166
  #: view/settings_cart_rules.php:102 view/settings_price_rules.php:169
167
  #: view/settings_promotion.php:22 view/settings_promotion.php:62
168
- #: view/settings_promotion.php:97
169
  msgid "Disabled"
170
  msgstr ""
171
 
@@ -268,13 +268,13 @@ msgstr ""
268
  msgid "Discount percentage"
269
  msgstr ""
270
 
271
- #: includes/discount-base.php:1018 view/view-cart-rules.php:738
272
  #: view/view-pricing-rules.php:717
273
  msgid "Percentage Discount"
274
  msgstr ""
275
 
276
- #: includes/discount-base.php:1019 view/view-cart-rules.php:744
277
- #: view/view-cart-rules.php:746 view/view-pricing-rules.php:725
278
  #: view/view-pricing-rules.php:727
279
  msgid "Price Discount"
280
  msgstr ""
@@ -768,105 +768,105 @@ msgstr ""
768
  msgid "Exclude categories in cart"
769
  msgstr ""
770
 
771
- #: includes/discount-base.php:1204 view/includes/menu.php:13
772
  msgid "Settings"
773
  msgstr ""
774
 
775
- #: includes/pricing-rules.php:3104 view/view-pricing-rules.php:601
776
  msgid "Buy"
777
  msgstr ""
778
 
779
- #: includes/pricing-rules.php:3108
780
  msgid " less than or equal to "
781
  msgstr ""
782
 
783
- #: includes/pricing-rules.php:3108 includes/pricing-rules.php:3114
784
  msgid " Quantity"
785
  msgstr ""
786
 
787
- #: includes/pricing-rules.php:3111
788
  msgid " Quantity "
789
  msgstr ""
790
 
791
- #: includes/pricing-rules.php:3118
792
  msgid " or more Quantity"
793
  msgstr ""
794
 
795
- #: includes/pricing-rules.php:3127
796
  msgid " any "
797
  msgstr ""
798
 
799
- #: includes/pricing-rules.php:3127
800
  msgid " products from "
801
  msgstr ""
802
 
803
- #: includes/pricing-rules.php:3134
804
  msgid " in each products"
805
  msgstr ""
806
 
807
- #: includes/pricing-rules.php:3146
808
  msgid " and get discount on "
809
  msgstr ""
810
 
811
- #: includes/pricing-rules.php:3149
812
  msgid " first "
813
  msgstr ""
814
 
815
- #: includes/pricing-rules.php:3151 includes/pricing-rules.php:3155
816
  msgid " quantity of product(s) - "
817
  msgstr ""
818
 
819
- #: includes/pricing-rules.php:3153
820
  msgid " after first "
821
  msgstr ""
822
 
823
- #: includes/pricing-rules.php:3171
824
  msgid "Category(ies) "
825
  msgstr ""
826
 
827
- #: includes/pricing-rules.php:3242
828
  msgid "Get "
829
  msgstr ""
830
 
831
- #: includes/pricing-rules.php:3244
832
  #, php-format
833
  msgid "% discount in "
834
  msgstr ""
835
 
836
- #: includes/pricing-rules.php:3247
837
  msgid "same product"
838
  msgstr ""
839
 
840
- #: includes/pricing-rules.php:3249
841
  msgid "any cheapest one from cart"
842
  msgstr ""
843
 
844
- #: includes/pricing-rules.php:3252
845
  msgid "any cheapest one of "
846
  msgstr ""
847
 
848
- #: includes/pricing-rules.php:3257
849
  msgid " quantity of any "
850
  msgstr ""
851
 
852
- #: includes/pricing-rules.php:3259
853
  msgid " cheapest item "
854
  msgstr ""
855
 
856
- #: includes/pricing-rules.php:3262
857
  msgid " quantity of cheapest item "
858
  msgstr ""
859
 
860
- #: includes/pricing-rules.php:3266
861
  msgid "from the category "
862
  msgstr ""
863
 
864
- #: includes/pricing-rules.php:3288
865
  #, php-format
866
  msgid "%s for %s Quantity(s)"
867
  msgstr ""
868
 
869
- #: includes/pricing-rules.php:3290
870
  #, php-format
871
  msgid "%s as price per unit"
872
  msgstr ""
@@ -880,67 +880,71 @@ msgid "Sending Feedback"
880
  msgstr ""
881
 
882
  #: includes/survey.php:239
883
- msgid "I am switching to a different discount plugin."
884
  msgstr ""
885
 
886
  #: includes/survey.php:243
887
- msgid "I could not get my discount rule to work."
888
  msgstr ""
889
 
890
  #: includes/survey.php:247
891
- msgid "It does not meet my discount requirements."
892
  msgstr ""
893
 
894
  #: includes/survey.php:251
895
- msgid "Plugin is complex."
896
  msgstr ""
897
 
898
  #: includes/survey.php:255
899
- msgid "I'm trying to troubleshoot the plugin."
900
  msgstr ""
901
 
902
  #: includes/survey.php:259
903
- msgid "I was instructed to deactivate by Flycart Support."
904
  msgstr ""
905
 
906
  #: includes/survey.php:263
907
- msgid "I no longer use this plugin."
908
  msgstr ""
909
 
910
  #: includes/survey.php:267
911
- msgid "It's a temporary deactivation."
912
  msgstr ""
913
 
914
  #: includes/survey.php:271
 
 
 
 
915
  msgid "Other"
916
  msgstr ""
917
 
918
- #: includes/survey.php:273
919
  msgid "Please share the reason"
920
  msgstr ""
921
 
922
- #: includes/survey.php:283
923
  msgid "Quick Feedback"
924
  msgstr ""
925
 
926
- #: includes/survey.php:284
927
  msgid "Close"
928
  msgstr ""
929
 
930
- #: includes/survey.php:292
931
  #, php-format
932
  msgid "If you have a moment, please share why you are deactivating %s:"
933
  msgstr ""
934
 
935
- #: includes/survey.php:293
936
  msgid "Discount Rules for WooCommerce"
937
  msgstr ""
938
 
939
- #: includes/survey.php:321
940
  msgid "Submit & Deactivate"
941
  msgstr ""
942
 
943
- #: includes/survey.php:323
944
  msgid "Skip & Deactivate"
945
  msgstr ""
946
 
@@ -1156,7 +1160,7 @@ msgid "Conditions"
1156
  msgstr ""
1157
 
1158
  #: view/includes/cart-menu.php:13 view/includes/sub-menu.php:13
1159
- #: view/template/discount-table.php:42 view/view-cart-rules.php:718
1160
  #: view/view-pricing-rules.php:667
1161
  msgid "Discount"
1162
  msgstr ""
@@ -1589,6 +1593,7 @@ msgid "Show a message on applying price rules in cart"
1589
  msgstr ""
1590
 
1591
  #: view/settings_promotion.php:73 view/settings_promotion.php:108
 
1592
  msgid "Message"
1593
  msgstr ""
1594
 
@@ -1604,6 +1609,28 @@ msgstr ""
1604
  msgid "Show a message on applying cart rules in cart"
1605
  msgstr ""
1606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1607
  #: view/settings_taxonomy.php:32
1608
  msgid ""
1609
  "Choose taxonomies that can be supported in the discount rules (as categories)"
@@ -1764,7 +1791,7 @@ msgstr ""
1764
  msgid "Current date and time: %s"
1765
  msgstr ""
1766
 
1767
- #: view/view-cart-rules.php:145 view/view-cart-rules.php:712
1768
  #: view/view-pricing-rules.php:183 view/view-pricing-rules.php:660
1769
  msgid "Next"
1770
  msgstr ""
@@ -1785,36 +1812,67 @@ msgstr ""
1785
  msgid "Email with TLD (Eg: edu)"
1786
  msgstr ""
1787
 
1788
- #: view/view-cart-rules.php:711 view/view-cart-rules.php:808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1789
  #: view/view-pricing-rules.php:659 view/view-pricing-rules.php:918
1790
  msgid "Previous"
1791
  msgstr ""
1792
 
1793
- #: view/view-cart-rules.php:714
1794
  msgid "Guide to create cart rules"
1795
  msgstr ""
1796
 
1797
- #: view/view-cart-rules.php:734
1798
  msgid "Discount Type :"
1799
  msgstr ""
1800
 
1801
- #: view/view-cart-rules.php:753 view/view-cart-rules.php:755
1802
  msgid "Product Discount"
1803
  msgstr ""
1804
 
1805
- #: view/view-cart-rules.php:762 view/view-cart-rules.php:764
1806
  msgid "Free shipping"
1807
  msgstr ""
1808
 
1809
- #: view/view-cart-rules.php:773
1810
  msgid "value :"
1811
  msgstr ""
1812
 
1813
- #: view/view-cart-rules.php:781
1814
  msgid "Select products :"
1815
  msgstr ""
1816
 
1817
- #: view/view-cart-rules.php:795
1818
  msgid "Quantity :"
1819
  msgstr ""
1820
 
@@ -2068,9 +2126,9 @@ msgstr ""
2068
 
2069
  #: view/view-pricing-rules.php:675
2070
  msgid ""
2071
- "Package / bundle deals should NOT be mixed with any other adjustment types "
2072
- "when adding ranges. Example: If your first range's adjustment type is "
2073
- "Package / Bundle deal, other ranges should also be same type."
2074
  msgstr ""
2075
 
2076
  #: view/view-pricing-rules.php:884
152
  msgid "Saved successfully"
153
  msgstr ""
154
 
155
+ #: includes/cart-rules.php:164 includes/pricing-rules.php:153
156
  msgid "Failed to save"
157
  msgstr ""
158
 
165
  #: view/pricing-rules.php:179 view/settings_cart_rules.php:95
166
  #: view/settings_cart_rules.php:102 view/settings_price_rules.php:169
167
  #: view/settings_promotion.php:22 view/settings_promotion.php:62
168
+ #: view/settings_promotion.php:97 view/settings_promotion.php:132
169
  msgid "Disabled"
170
  msgstr ""
171
 
268
  msgid "Discount percentage"
269
  msgstr ""
270
 
271
+ #: includes/discount-base.php:1018 view/view-cart-rules.php:776
272
  #: view/view-pricing-rules.php:717
273
  msgid "Percentage Discount"
274
  msgstr ""
275
 
276
+ #: includes/discount-base.php:1019 view/view-cart-rules.php:782
277
+ #: view/view-cart-rules.php:784 view/view-pricing-rules.php:725
278
  #: view/view-pricing-rules.php:727
279
  msgid "Price Discount"
280
  msgstr ""
768
  msgid "Exclude categories in cart"
769
  msgstr ""
770
 
771
+ #: includes/discount-base.php:1207 view/includes/menu.php:13
772
  msgid "Settings"
773
  msgstr ""
774
 
775
+ #: includes/pricing-rules.php:3158 view/view-pricing-rules.php:601
776
  msgid "Buy"
777
  msgstr ""
778
 
779
+ #: includes/pricing-rules.php:3162
780
  msgid " less than or equal to "
781
  msgstr ""
782
 
783
+ #: includes/pricing-rules.php:3162 includes/pricing-rules.php:3168
784
  msgid " Quantity"
785
  msgstr ""
786
 
787
+ #: includes/pricing-rules.php:3165
788
  msgid " Quantity "
789
  msgstr ""
790
 
791
+ #: includes/pricing-rules.php:3172
792
  msgid " or more Quantity"
793
  msgstr ""
794
 
795
+ #: includes/pricing-rules.php:3181
796
  msgid " any "
797
  msgstr ""
798
 
799
+ #: includes/pricing-rules.php:3181
800
  msgid " products from "
801
  msgstr ""
802
 
803
+ #: includes/pricing-rules.php:3188
804
  msgid " in each products"
805
  msgstr ""
806
 
807
+ #: includes/pricing-rules.php:3200
808
  msgid " and get discount on "
809
  msgstr ""
810
 
811
+ #: includes/pricing-rules.php:3203
812
  msgid " first "
813
  msgstr ""
814
 
815
+ #: includes/pricing-rules.php:3205 includes/pricing-rules.php:3209
816
  msgid " quantity of product(s) - "
817
  msgstr ""
818
 
819
+ #: includes/pricing-rules.php:3207
820
  msgid " after first "
821
  msgstr ""
822
 
823
+ #: includes/pricing-rules.php:3225
824
  msgid "Category(ies) "
825
  msgstr ""
826
 
827
+ #: includes/pricing-rules.php:3296
828
  msgid "Get "
829
  msgstr ""
830
 
831
+ #: includes/pricing-rules.php:3298
832
  #, php-format
833
  msgid "% discount in "
834
  msgstr ""
835
 
836
+ #: includes/pricing-rules.php:3301
837
  msgid "same product"
838
  msgstr ""
839
 
840
+ #: includes/pricing-rules.php:3303
841
  msgid "any cheapest one from cart"
842
  msgstr ""
843
 
844
+ #: includes/pricing-rules.php:3306
845
  msgid "any cheapest one of "
846
  msgstr ""
847
 
848
+ #: includes/pricing-rules.php:3311
849
  msgid " quantity of any "
850
  msgstr ""
851
 
852
+ #: includes/pricing-rules.php:3313
853
  msgid " cheapest item "
854
  msgstr ""
855
 
856
+ #: includes/pricing-rules.php:3316
857
  msgid " quantity of cheapest item "
858
  msgstr ""
859
 
860
+ #: includes/pricing-rules.php:3320
861
  msgid "from the category "
862
  msgstr ""
863
 
864
+ #: includes/pricing-rules.php:3342
865
  #, php-format
866
  msgid "%s for %s Quantity(s)"
867
  msgstr ""
868
 
869
+ #: includes/pricing-rules.php:3344
870
  #, php-format
871
  msgid "%s as price per unit"
872
  msgstr ""
880
  msgstr ""
881
 
882
  #: includes/survey.php:239
883
+ msgid "Upgrading to PRO."
884
  msgstr ""
885
 
886
  #: includes/survey.php:243
887
+ msgid "I am switching to a different discount plugin."
888
  msgstr ""
889
 
890
  #: includes/survey.php:247
891
+ msgid "I could not get my discount rule to work."
892
  msgstr ""
893
 
894
  #: includes/survey.php:251
895
+ msgid "It does not meet my discount requirements."
896
  msgstr ""
897
 
898
  #: includes/survey.php:255
899
+ msgid "Plugin is complex."
900
  msgstr ""
901
 
902
  #: includes/survey.php:259
903
+ msgid "I'm trying to troubleshoot the plugin."
904
  msgstr ""
905
 
906
  #: includes/survey.php:263
907
+ msgid "I was instructed to deactivate by Flycart Support."
908
  msgstr ""
909
 
910
  #: includes/survey.php:267
911
+ msgid "I no longer use this plugin."
912
  msgstr ""
913
 
914
  #: includes/survey.php:271
915
+ msgid "It's a temporary deactivation."
916
+ msgstr ""
917
+
918
+ #: includes/survey.php:275
919
  msgid "Other"
920
  msgstr ""
921
 
922
+ #: includes/survey.php:277
923
  msgid "Please share the reason"
924
  msgstr ""
925
 
926
+ #: includes/survey.php:287
927
  msgid "Quick Feedback"
928
  msgstr ""
929
 
930
+ #: includes/survey.php:288
931
  msgid "Close"
932
  msgstr ""
933
 
934
+ #: includes/survey.php:296
935
  #, php-format
936
  msgid "If you have a moment, please share why you are deactivating %s:"
937
  msgstr ""
938
 
939
+ #: includes/survey.php:297
940
  msgid "Discount Rules for WooCommerce"
941
  msgstr ""
942
 
943
+ #: includes/survey.php:325
944
  msgid "Submit & Deactivate"
945
  msgstr ""
946
 
947
+ #: includes/survey.php:327
948
  msgid "Skip & Deactivate"
949
  msgstr ""
950
 
1160
  msgstr ""
1161
 
1162
  #: view/includes/cart-menu.php:13 view/includes/sub-menu.php:13
1163
+ #: view/template/discount-table.php:42 view/view-cart-rules.php:756
1164
  #: view/view-pricing-rules.php:667
1165
  msgid "Discount"
1166
  msgstr ""
1593
  msgstr ""
1594
 
1595
  #: view/settings_promotion.php:73 view/settings_promotion.php:108
1596
+ #: view/view-cart-rules.php:730
1597
  msgid "Message"
1598
  msgstr ""
1599
 
1609
  msgid "Show a message on applying cart rules in cart"
1610
  msgstr ""
1611
 
1612
+ #: view/settings_promotion.php:125
1613
+ msgid ""
1614
+ "Subtotal based promo text (available only in cart rules -> subtotal based "
1615
+ "discounts)"
1616
+ msgstr ""
1617
+
1618
+ #: view/settings_promotion.php:134
1619
+ msgid "Shop page"
1620
+ msgstr ""
1621
+
1622
+ #: view/settings_promotion.php:137
1623
+ msgid "Product page"
1624
+ msgstr ""
1625
+
1626
+ #: view/settings_promotion.php:140
1627
+ msgid "Cart page"
1628
+ msgstr ""
1629
+
1630
+ #: view/settings_promotion.php:143
1631
+ msgid "Checkout page"
1632
+ msgstr ""
1633
+
1634
  #: view/settings_taxonomy.php:32
1635
  msgid ""
1636
  "Choose taxonomies that can be supported in the discount rules (as categories)"
1791
  msgid "Current date and time: %s"
1792
  msgstr ""
1793
 
1794
+ #: view/view-cart-rules.php:145 view/view-cart-rules.php:750
1795
  #: view/view-pricing-rules.php:183 view/view-pricing-rules.php:660
1796
  msgid "Next"
1797
  msgstr ""
1812
  msgid "Email with TLD (Eg: edu)"
1813
  msgstr ""
1814
 
1815
+ #: view/view-cart-rules.php:713
1816
+ msgid "Promotion message"
1817
+ msgstr ""
1818
+
1819
+ #: view/view-cart-rules.php:718
1820
+ msgid "Subtotal from"
1821
+ msgstr ""
1822
+
1823
+ #: view/view-cart-rules.php:724
1824
+ #, php-format
1825
+ msgid ""
1826
+ "Set a threshold from which you want to start showing the promotion "
1827
+ "message<br>Example: Let's say, you offer a 10% discount for $1000 and "
1828
+ "above. You may want to set 900 here. So that the customer can see the promo "
1829
+ "text when his cart subtotal reaches 900"
1830
+ msgstr ""
1831
+
1832
+ #: view/view-cart-rules.php:735
1833
+ #, php-format
1834
+ msgid "Spend {{difference_amount}} more and get 10% discount"
1835
+ msgstr ""
1836
+
1837
+ #: view/view-cart-rules.php:737
1838
+ msgid "{{difference_amount}} -> Difference amount to get discount"
1839
+ msgstr ""
1840
+
1841
+ #: view/view-cart-rules.php:738
1842
+ #, php-format
1843
+ msgid "<b>Eg:</b> Spend {{difference_amount}} more and get 10% discount"
1844
+ msgstr ""
1845
+
1846
+ #: view/view-cart-rules.php:749 view/view-cart-rules.php:846
1847
  #: view/view-pricing-rules.php:659 view/view-pricing-rules.php:918
1848
  msgid "Previous"
1849
  msgstr ""
1850
 
1851
+ #: view/view-cart-rules.php:752
1852
  msgid "Guide to create cart rules"
1853
  msgstr ""
1854
 
1855
+ #: view/view-cart-rules.php:772
1856
  msgid "Discount Type :"
1857
  msgstr ""
1858
 
1859
+ #: view/view-cart-rules.php:791 view/view-cart-rules.php:793
1860
  msgid "Product Discount"
1861
  msgstr ""
1862
 
1863
+ #: view/view-cart-rules.php:800 view/view-cart-rules.php:802
1864
  msgid "Free shipping"
1865
  msgstr ""
1866
 
1867
+ #: view/view-cart-rules.php:811
1868
  msgid "value :"
1869
  msgstr ""
1870
 
1871
+ #: view/view-cart-rules.php:819
1872
  msgid "Select products :"
1873
  msgstr ""
1874
 
1875
+ #: view/view-cart-rules.php:833
1876
  msgid "Quantity :"
1877
  msgstr ""
1878
 
2126
 
2127
  #: view/view-pricing-rules.php:675
2128
  msgid ""
2129
+ "Bundle (Set) Discount should NOT be mixed with any other adjustment types "
2130
+ "when adding ranges. Example: If your first range's adjustment type is Bundle "
2131
+ "(Set) Discount, other ranges should also be same type."
2132
  msgstr ""
2133
 
2134
  #: view/view-pricing-rules.php:884
includes/cart-rules.php CHANGED
@@ -146,7 +146,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
146
  'dynamic_coupons_to_apply',
147
  'rule_order',
148
  'status',
149
- 'wpml_language',
 
150
  );
151
  $coupons_used = array();
152
  $request['dynamic_coupons_to_apply'] = '';
@@ -218,6 +219,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
218
  $request['wpml_language'] = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
219
 
220
  foreach ($request as $index => $value) {
 
221
  if (in_array($index, $form)) {
222
  if (get_post_meta($id, $index)) {
223
  update_post_meta($id, $index, $value);
@@ -363,9 +365,14 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
363
  {
364
  $coupon_code = $this->coupon_code;
365
  // Getting Coupon Remove status from Session.
366
- $is_removed = WC()->session->get('woo_coupon_removed');
367
- // If Both are same, then it won't added.
368
- if ($coupon_code == $is_removed) return $response;
 
 
 
 
 
369
  if ($coupon_data == $coupon_code || wc_strtolower($coupon_data) == wc_strtolower($coupon_code)) {
370
 
371
  if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
@@ -418,9 +425,14 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
418
  $bogo_coupon_codes = $this->bogo_coupon_codes;
419
  $coupon_codes = array_keys($bogo_coupon_codes);
420
  // Getting Coupon Remove status from Session.
421
- $is_removed = WC()->session->get('woo_coupon_removed');
422
- // If Both are same, then it won't added.
423
- if (in_array($is_removed, $coupon_codes)) return false;
 
 
 
 
 
424
  if (in_array($old_coupon_code, $coupon_codes) || in_array(wc_strtolower($old_coupon_code), $coupon_codes)) {
425
  if (in_array($this->postData->get('remove_coupon', false), $coupon_codes)) return false;
426
  $this->makeLog();
@@ -624,7 +636,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
624
 
625
  // Check point having list of checklist to apply.
626
  if ($this->checkPoint()) return false;
627
-
628
  // To Generate Valid Rule sets.
629
  $this->generateRuleSets();
630
  }
@@ -716,10 +728,15 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
716
  $rule_sets[$index]['to_discount'] = (isset($rule->to_discount) ? $rule->to_discount : false);
717
  $rule_sets[$index]['cart_discounted_products'] = isset($rule->cart_discounted_products) ? json_decode($rule->cart_discounted_products) : array();
718
  $rule_sets[$index]['product_discount_quantity'] = isset($rule->product_discount_quantity) ? $rule->product_discount_quantity : 1;
 
 
 
 
 
719
  if (in_array($rule->discount_type, array('product_discount'))) {
720
- $rule_sets[$index]['enabled'] = $this->validateBOGOCart($rule_sets[$index]['discount_rule'],$rule);
721
  }else{
722
- $rule_sets[$index]['enabled'] = $this->validateCart($rule_sets[$index]['discount_rule']);
723
  }
724
  }
725
  $rule_sets = apply_filters('woo_discount_rules_cart_rule_sets_to_apply', $rule_sets);
@@ -968,7 +985,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
968
  * @param array $rules
969
  * @return bool true|false
970
  */
971
- public function validateCart($rules)
972
  {
973
  $this->checked_for_categories_and_product_match = false;
974
  $this->calculateCartSubtotal();
@@ -979,7 +996,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
979
  if(is_array($rules) && count($rules)){
980
  foreach ($rules as $index => $rule) {
981
  // Validating the Rules one by one.
982
- if ($this->applyRule($index, $rule, $rules, $rules_with_all_data) == false) {
983
  return false;
984
  }
985
  }
@@ -987,6 +1004,36 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
987
  return true;
988
  }
989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
990
  /**
991
  * Applying bunch amount of rules with the line item.
992
  *
@@ -994,7 +1041,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
994
  * @param array $rule array of rule info.
995
  * @return bool true|false as matched or not.
996
  */
997
- public function applyRule($index, $rule, $rules, $rules_with_all_data)
998
  {
999
  $skipRuleType = array('categories_in', 'exclude_categories', 'in_each_category', 'atleast_one_including_sub_categories', 'products_in_list', 'products_not_in_list', 'exclude_sale_products');
1000
  $availableRuleToSkip = array_intersect($skipRuleType, array_keys($rules));
@@ -1004,6 +1051,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1004
  case 'subtotal_least':
1005
  if(!empty($availableRuleToSkip)){
1006
  } elseif ($this->sub_total < $rule) {
 
1007
  return false;
1008
  }
1009
  return true;
@@ -1321,7 +1369,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1321
  case 'atleast_one_including_sub_categories':
1322
  case 'in_each_category':
1323
  if(count($rule)){
1324
- $ruleSuccess = $this->validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data);
1325
  if($ruleSuccess){
1326
  return true;
1327
  }
@@ -1838,7 +1886,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1838
  /**
1839
  * verify the cart items are from selected category
1840
  * */
1841
- protected function validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data){
1842
  if($this->checked_for_categories_and_product_match){
1843
  return $this->categories_and_product_match_value;
1844
  }
@@ -1851,7 +1899,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1851
  if($matches){
1852
  $allow_discount = 1;
1853
  $cart_item_quantity = (isset($cartItem['quantity']) && $cartItem['quantity']) ? $cartItem['quantity'] : 1;
1854
- $sub_total += ((float)FlycartWoocommerceProduct::get_price($cartItem['data'], true)) * $cart_item_quantity;
1855
  $quantity += $cart_item_quantity;
1856
  $item_count++;
1857
  }
@@ -1865,6 +1913,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1865
  if(in_array($rule_type, $checkRuleTypes)){
1866
  if($rule_type == 'subtotal_least'){
1867
  if ($sub_total < $rule_values) {
 
1868
  $ruleSuccess = 0;
1869
  }
1870
  } elseif ($rule_type == 'subtotal_less'){
@@ -1942,8 +1991,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1942
  // Iterate over all cart items and
1943
  if(is_array($this->cart_items) && count($this->cart_items)){
1944
  foreach ($this->cart_items as $cart_item_key => $cart_item) {
1945
- $quantity = (isset($cart_item['quantity']) && $cart_item['quantity']) ? $cart_item['quantity'] : 1;
1946
- $cart_subtotal += ((float)FlycartWoocommerceProduct::get_price($cart_item['data'], true)) * $quantity;
1947
  }
1948
  }
1949
 
@@ -1951,6 +1999,39 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1951
 
1952
  }
1953
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1954
  public function calculate_conditional_subtotal($conditions, $rule) {
1955
  $cart_subtotal = 0;
1956
  $rules = $rules_with_all_data = array();
@@ -1974,8 +2055,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1974
 
1975
  if($apply_discount) {
1976
  //total should be specific to the products from certan categories
1977
- $quantity = (isset($cart_item['quantity']) && $cart_item['quantity']) ? $cart_item['quantity'] : 1;
1978
- $cart_subtotal += FlycartWoocommerceProduct::get_price($cart_item['data'], true) * $quantity;
1979
  }
1980
 
1981
  }
@@ -2114,7 +2194,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2114
  * @param $rule_set
2115
  * @return bool
2116
  */
2117
- function validateBOGOCart($conditions,$rule_set){
2118
  $this->checked_for_categories_and_product_match = false;
2119
  $this->calculateCartSubtotal();
2120
  $rules = (is_string($conditions) ? json_decode($conditions, true) : array());
@@ -2124,7 +2204,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2124
  if(is_array($rules) && count($rules)){
2125
  foreach ($rules as $index => $rule) {
2126
  // Validating the Rules one by one.
2127
- if ($this->applyCartBOGORule($index, $rule, $rules,$rule_set, $rules_with_all_data) == false) {
2128
  return false;
2129
  }
2130
  }
@@ -2140,7 +2220,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2140
  * @param $rule_set
2141
  * @return bool
2142
  */
2143
- function applyCartBOGORule($index, $rule, $rules,$rule_set, $rules_with_all_data){
2144
  //Calculating subtotal, quantity for BOGO Products
2145
  $cart = array();
2146
  $free_line_item = 0;
@@ -2150,8 +2230,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2150
  foreach ($this->cart_items as $cart_items){
2151
  $product_id = FlycartWoocommerceProduct::get_id($cart_items['data']);
2152
  $cart[$product_id]['quantity'] = $cart_items['quantity'];
2153
- $cart[$product_id]['price'] = FlycartWoocommerceProduct::get_price($cart_items['data'], true);
2154
- $cart[$product_id]['subtotal'] = $cart[$product_id]['price'] * $cart[$product_id]['quantity'];
2155
  }
2156
  }
2157
  $discounted_products = (isset($rule_set->cart_discounted_products)) ? $rule_set->cart_discounted_products : '[]';
@@ -2180,6 +2260,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2180
  case 'subtotal_least':
2181
  if(!empty($availableRuleToSkip)){
2182
  } elseif ($cart_subtotal_except_free < $rule) {
 
2183
  return false;
2184
  }
2185
  return true;
@@ -2497,7 +2578,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2497
  case 'atleast_one_including_sub_categories':
2498
  case 'in_each_category':
2499
  if(count($rule)){
2500
- $ruleSuccess = $this->validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data);
2501
  if($ruleSuccess){
2502
  return true;
2503
  }
146
  'dynamic_coupons_to_apply',
147
  'rule_order',
148
  'status',
149
+ 'promotion_subtotal_from',
150
+ 'promotion_message',
151
  );
152
  $coupons_used = array();
153
  $request['dynamic_coupons_to_apply'] = '';
219
  $request['wpml_language'] = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
220
 
221
  foreach ($request as $index => $value) {
222
+ //$value = sanitize_text_field($value);
223
  if (in_array($index, $form)) {
224
  if (get_post_meta($id, $index)) {
225
  update_post_meta($id, $index, $value);
365
  {
366
  $coupon_code = $this->coupon_code;
367
  // Getting Coupon Remove status from Session.
368
+ if(isset(WC()->session) && is_object(WC()->session) && method_exists(WC()->session, 'get')) {
369
+ $is_removed = WC()->session->get('woo_coupon_removed', '');
370
+ // If Both are same, then it won't added.
371
+ if(!empty($is_removed)){
372
+ if ($coupon_code == $is_removed) return $response;
373
+ }
374
+ }
375
+
376
  if ($coupon_data == $coupon_code || wc_strtolower($coupon_data) == wc_strtolower($coupon_code)) {
377
 
378
  if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
425
  $bogo_coupon_codes = $this->bogo_coupon_codes;
426
  $coupon_codes = array_keys($bogo_coupon_codes);
427
  // Getting Coupon Remove status from Session.
428
+ if(isset(WC()->session) && is_object(WC()->session) && method_exists(WC()->session, 'get')) {
429
+ $is_removed = WC()->session->get('woo_coupon_removed', '');
430
+ if(!empty($is_removed)){
431
+ // If Both are same, then it won't added.
432
+ if (in_array($is_removed, $coupon_codes)) return false;
433
+ }
434
+ }
435
+
436
  if (in_array($old_coupon_code, $coupon_codes) || in_array(wc_strtolower($old_coupon_code), $coupon_codes)) {
437
  if (in_array($this->postData->get('remove_coupon', false), $coupon_codes)) return false;
438
  $this->makeLog();
636
 
637
  // Check point having list of checklist to apply.
638
  if ($this->checkPoint()) return false;
639
+ FlycartWooDiscountRulesGeneralHelper::clearCartPromotionMessages();
640
  // To Generate Valid Rule sets.
641
  $this->generateRuleSets();
642
  }
728
  $rule_sets[$index]['to_discount'] = (isset($rule->to_discount) ? $rule->to_discount : false);
729
  $rule_sets[$index]['cart_discounted_products'] = isset($rule->cart_discounted_products) ? json_decode($rule->cart_discounted_products) : array();
730
  $rule_sets[$index]['product_discount_quantity'] = isset($rule->product_discount_quantity) ? $rule->product_discount_quantity : 1;
731
+ $rule_sets[$index]['promotion_qty_from'] = isset($rule->promotion_qty_from) ? $rule->promotion_qty_from : 0;
732
+ $rule_sets[$index]['promotion_subtotal_from'] = isset($rule->promotion_subtotal_from) ? $rule->promotion_subtotal_from : 0;
733
+ $rule_sets[$index]['promotion_message'] = isset($rule->promotion_message) ? $rule->promotion_message : '';
734
+ $rule_sets[$index]['rule_id'] = isset($rule->ID) ? $rule->ID : '';
735
+ $rule_sets[$index]['rule_order_id'] = isset($rule->rule_order) ? $rule->rule_order : '';
736
  if (in_array($rule->discount_type, array('product_discount'))) {
737
+ $rule_sets[$index]['enabled'] = $this->validateBOGOCart($rule_sets[$index]['discount_rule'],$rule, $rule_sets[$index]);
738
  }else{
739
+ $rule_sets[$index]['enabled'] = $this->validateCart($rule_sets[$index]['discount_rule'], $rule_sets[$index]);
740
  }
741
  }
742
  $rule_sets = apply_filters('woo_discount_rules_cart_rule_sets_to_apply', $rule_sets);
985
  * @param array $rules
986
  * @return bool true|false
987
  */
988
+ public function validateCart($rules, $rule_sets)
989
  {
990
  $this->checked_for_categories_and_product_match = false;
991
  $this->calculateCartSubtotal();
996
  if(is_array($rules) && count($rules)){
997
  foreach ($rules as $index => $rule) {
998
  // Validating the Rules one by one.
999
+ if ($this->applyRule($index, $rule, $rules, $rules_with_all_data, $rule_sets) == false) {
1000
  return false;
1001
  }
1002
  }
1004
  return true;
1005
  }
1006
 
1007
+ /**
1008
+ * Process promotion message
1009
+ *
1010
+ * @param $rule_sets array
1011
+ * @param $rule_value mixed
1012
+ * @param $type string
1013
+ * */
1014
+ public function processPromotionMessage($rule_sets, $rule_value, $type, $additional_data = array()){
1015
+ if($type == "subtotal_least"){
1016
+ if(isset($rule_sets["promotion_subtotal_from"]) && isset($rule_sets["promotion_message"])){
1017
+ $message = trim($rule_sets["promotion_message"]);
1018
+ if(!empty($message)){
1019
+ $sub_total = $this->sub_total;
1020
+ if(isset($additional_data['subtotal'])){
1021
+ $sub_total = $additional_data['subtotal'];
1022
+ }
1023
+ $promotion_subtotal_from = (float)$rule_sets["promotion_subtotal_from"];
1024
+ if($sub_total >= $promotion_subtotal_from){
1025
+ $difference_amount = $rule_value - $sub_total;
1026
+ if($difference_amount > 0){
1027
+ $difference_amount = FlycartWoocommerceProduct::wc_price($difference_amount);
1028
+ $message = str_replace('{{difference_amount}}', $difference_amount, $message);
1029
+ FlycartWooDiscountRulesGeneralHelper::setPromotionMessage($message, $rule_sets['rule_id']);
1030
+ }
1031
+ }
1032
+ }
1033
+ }
1034
+ }
1035
+ }
1036
+
1037
  /**
1038
  * Applying bunch amount of rules with the line item.
1039
  *
1041
  * @param array $rule array of rule info.
1042
  * @return bool true|false as matched or not.
1043
  */
1044
+ public function applyRule($index, $rule, $rules, $rules_with_all_data, $rule_sets)
1045
  {
1046
  $skipRuleType = array('categories_in', 'exclude_categories', 'in_each_category', 'atleast_one_including_sub_categories', 'products_in_list', 'products_not_in_list', 'exclude_sale_products');
1047
  $availableRuleToSkip = array_intersect($skipRuleType, array_keys($rules));
1051
  case 'subtotal_least':
1052
  if(!empty($availableRuleToSkip)){
1053
  } elseif ($this->sub_total < $rule) {
1054
+ $this->processPromotionMessage($rule_sets, $rule, $index);
1055
  return false;
1056
  }
1057
  return true;
1369
  case 'atleast_one_including_sub_categories':
1370
  case 'in_each_category':
1371
  if(count($rule)){
1372
+ $ruleSuccess = $this->validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data, $rule_sets);
1373
  if($ruleSuccess){
1374
  return true;
1375
  }
1886
  /**
1887
  * verify the cart items are from selected category
1888
  * */
1889
+ protected function validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data, $rule_sets){
1890
  if($this->checked_for_categories_and_product_match){
1891
  return $this->categories_and_product_match_value;
1892
  }
1899
  if($matches){
1900
  $allow_discount = 1;
1901
  $cart_item_quantity = (isset($cartItem['quantity']) && $cartItem['quantity']) ? $cartItem['quantity'] : 1;
1902
+ $sub_total += self::getSubTotalOfCartItem($cartItem);
1903
  $quantity += $cart_item_quantity;
1904
  $item_count++;
1905
  }
1913
  if(in_array($rule_type, $checkRuleTypes)){
1914
  if($rule_type == 'subtotal_least'){
1915
  if ($sub_total < $rule_values) {
1916
+ $this->processPromotionMessage($rule_sets, $rule_values, $rule_type, array('subtotal' => $sub_total));
1917
  $ruleSuccess = 0;
1918
  }
1919
  } elseif ($rule_type == 'subtotal_less'){
1991
  // Iterate over all cart items and
1992
  if(is_array($this->cart_items) && count($this->cart_items)){
1993
  foreach ($this->cart_items as $cart_item_key => $cart_item) {
1994
+ $cart_subtotal += self::getSubTotalOfCartItem($cart_item);
 
1995
  }
1996
  }
1997
 
1999
 
2000
  }
2001
 
2002
+ /**
2003
+ * Get subtotal of cart item
2004
+ *
2005
+ * @param $cart_item array
2006
+ * @return integer/float
2007
+ * */
2008
+ public static function getSubTotalOfCartItem($cart_item){
2009
+ if(get_option('woocommerce_tax_display_cart', 'incl') == 'incl'){
2010
+ $subtotal = $cart_item['line_subtotal']+$cart_item['line_subtotal_tax'];
2011
+ } else {
2012
+ $quantity = (isset($cart_item['quantity']) && $cart_item['quantity']) ? $cart_item['quantity'] : 1;
2013
+ $subtotal = ((float)FlycartWoocommerceProduct::get_price($cart_item['data'], true)) * $quantity;
2014
+ }
2015
+
2016
+ return $subtotal;
2017
+ }
2018
+
2019
+ /**
2020
+ * Get price of cart item
2021
+ *
2022
+ * @param $cart_item array
2023
+ * @return integer/float
2024
+ * */
2025
+ public function getPriceOfCartItem($cart_item){
2026
+ if(get_option('woocommerce_tax_display_cart', 'incl') == 'incl'){
2027
+ $price = FlycartWoocommerceProduct::get_price_including_tax($cart_item['data']);
2028
+ } else {
2029
+ $price = ((float)FlycartWoocommerceProduct::get_price($cart_item['data'], true));
2030
+ }
2031
+
2032
+ return $price;
2033
+ }
2034
+
2035
  public function calculate_conditional_subtotal($conditions, $rule) {
2036
  $cart_subtotal = 0;
2037
  $rules = $rules_with_all_data = array();
2055
 
2056
  if($apply_discount) {
2057
  //total should be specific to the products from certan categories
2058
+ $cart_subtotal += self::getSubTotalOfCartItem($cart_item);
 
2059
  }
2060
 
2061
  }
2194
  * @param $rule_set
2195
  * @return bool
2196
  */
2197
+ function validateBOGOCart($conditions, $rule_set, $rule_sets){
2198
  $this->checked_for_categories_and_product_match = false;
2199
  $this->calculateCartSubtotal();
2200
  $rules = (is_string($conditions) ? json_decode($conditions, true) : array());
2204
  if(is_array($rules) && count($rules)){
2205
  foreach ($rules as $index => $rule) {
2206
  // Validating the Rules one by one.
2207
+ if ($this->applyCartBOGORule($index, $rule, $rules, $rule_set, $rules_with_all_data, $rule_sets) == false) {
2208
  return false;
2209
  }
2210
  }
2220
  * @param $rule_set
2221
  * @return bool
2222
  */
2223
+ function applyCartBOGORule($index, $rule, $rules, $rule_set, $rules_with_all_data, $rule_sets){
2224
  //Calculating subtotal, quantity for BOGO Products
2225
  $cart = array();
2226
  $free_line_item = 0;
2230
  foreach ($this->cart_items as $cart_items){
2231
  $product_id = FlycartWoocommerceProduct::get_id($cart_items['data']);
2232
  $cart[$product_id]['quantity'] = $cart_items['quantity'];
2233
+ $cart[$product_id]['price'] = $this->getPriceOfCartItem($cart_items);
2234
+ $cart[$product_id]['subtotal'] = self::getSubTotalOfCartItem($cart_items);
2235
  }
2236
  }
2237
  $discounted_products = (isset($rule_set->cart_discounted_products)) ? $rule_set->cart_discounted_products : '[]';
2260
  case 'subtotal_least':
2261
  if(!empty($availableRuleToSkip)){
2262
  } elseif ($cart_subtotal_except_free < $rule) {
2263
+ $this->processPromotionMessage($rule_sets, $rule, $index);
2264
  return false;
2265
  }
2266
  return true;
2578
  case 'atleast_one_including_sub_categories':
2579
  case 'in_each_category':
2580
  if(count($rule)){
2581
+ $ruleSuccess = $this->validateCartItemsInSelectedProductsAndCategories($index, $rule, $rules, $rules_with_all_data, $rule_sets);
2582
  if($ruleSuccess){
2583
  return true;
2584
  }
includes/discount-base.php CHANGED
@@ -321,7 +321,7 @@ if (!class_exists('FlycartWooDiscountBase')) {
321
  // $posts = get_posts($args);
322
  $in_data = "'".implode("','", $selected)."'";
323
  global $wpdb;
324
- $query = "SELECT `post_title`, `post_name` FROM $wpdb->posts WHERE `post_type` = 'shop_coupon' AND `post_title` IN (".$in_data.")";
325
  $posts = $wpdb->get_results($query);
326
  if(!empty($posts)){
327
  if(count($posts)){
@@ -1142,6 +1142,9 @@ if (!class_exists('FlycartWooDiscountBase')) {
1142
  if(!empty($used_coupons) && is_array($used_coupons)){
1143
  $applied_coupon = array_merge($applied_coupon, $used_coupons);
1144
  }
 
 
 
1145
  $skip_coupons = apply_filters('woo_discount_rules_coupons_to_skip_while_apply_rules_and_remove_third_party_coupon', $applied_coupon);
1146
  global $woocommerce;
1147
  if(!empty($woocommerce->cart)){
321
  // $posts = get_posts($args);
322
  $in_data = "'".implode("','", $selected)."'";
323
  global $wpdb;
324
+ $query = "SELECT `post_title`, `post_name` FROM $wpdb->posts WHERE `post_type` = 'shop_coupon' AND `post_status` <> 'trash' AND `post_title` IN (".$in_data.")";
325
  $posts = $wpdb->get_results($query);
326
  if(!empty($posts)){
327
  if(count($posts)){
1142
  if(!empty($used_coupons) && is_array($used_coupons)){
1143
  $applied_coupon = array_merge($applied_coupon, $used_coupons);
1144
  }
1145
+ if(!empty($applied_coupon)){
1146
+ $applied_coupon = array_map('strtolower', $applied_coupon);
1147
+ }
1148
  $skip_coupons = apply_filters('woo_discount_rules_coupons_to_skip_while_apply_rules_and_remove_third_party_coupon', $applied_coupon);
1149
  global $woocommerce;
1150
  if(!empty($woocommerce->cart)){
includes/pricing-rules.php CHANGED
@@ -328,6 +328,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
328
  if (is_null($id) || !isset($id)) return false;
329
  FlycartWooDiscountRulesGeneralHelper::resetUsedCoupons($id, $coupons_used);
330
  foreach ($request as $index => $value) {
 
331
  if (in_array($index, $form)) {
332
  if (get_post_meta($id, $index)) {
333
  update_post_meta($id, $index, $value);
@@ -979,6 +980,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
979
  $is_woocommerce3 = FlycartWoocommerceVersion::isWCVersion3x();
980
  if($is_woocommerce3){
981
  $rule_sets[$index]['allow']['subtotal'] = $this->checkSubtotalMatches($rule);
 
 
 
 
 
 
 
 
 
 
 
982
  }
983
  }
984
 
@@ -1019,6 +1031,35 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1019
  self::$rule_sets_generated = 1;
1020
  }
1021
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1022
  /**
1023
  * Check with users roles
1024
  * */
@@ -1064,7 +1105,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1064
  if(isset($rule->subtotal_to_apply_option)){
1065
  if($rule->subtotal_to_apply_option == 'atleast'){
1066
  if(isset($rule->subtotal_to_apply) && $rule->subtotal_to_apply > 0){
1067
- $sub_total = FlycartWooDiscountRulesAdvancedHelper::get_calculated_item_subtotal();
 
1068
  if(!($rule->subtotal_to_apply <= $sub_total)){
1069
  $allowed = 0;
1070
  }
@@ -1756,6 +1798,18 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1756
  if(empty($cartItem['data'])){
1757
  continue;
1758
  }
 
 
 
 
 
 
 
 
 
 
 
 
1759
  $is_exclude_sale_items = $this->isItemInSaleItems($exclude_sale_items, $cartItem['data']);
1760
  if($is_exclude_sale_items){
1761
  continue;
@@ -4316,7 +4370,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4316
  if($greatestDiscountPrice > 0 || ($this->hasDiscountForProductId($maxProductId))){
4317
  $greatestDiscountPrice = FlycartWoocommerceProduct::wc_price($greatestDiscountPrice);
4318
  } else {
4319
- $greatestDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($maxProduct));
 
4320
  }
4321
  if($minProductId){
4322
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
@@ -4324,7 +4379,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4324
  if($leastDiscountPrice > 0 || ($this->hasDiscountForProductId($minProductId))){
4325
  $leastDiscountPrice = FlycartWoocommerceProduct::wc_price($leastDiscountPrice);
4326
  } else {
4327
- $leastDiscountPrice = FlycartWoocommerceProduct::wc_price(FlycartWoocommerceProduct::get_price($minProduct));
 
4328
  }
4329
  if($display_only_lowest_price){
4330
  $price_to_display = $leastDiscountPrice;
328
  if (is_null($id) || !isset($id)) return false;
329
  FlycartWooDiscountRulesGeneralHelper::resetUsedCoupons($id, $coupons_used);
330
  foreach ($request as $index => $value) {
331
+ //$value = sanitize_text_field($value);
332
  if (in_array($index, $form)) {
333
  if (get_post_meta($id, $index)) {
334
  update_post_meta($id, $index, $value);
980
  $is_woocommerce3 = FlycartWoocommerceVersion::isWCVersion3x();
981
  if($is_woocommerce3){
982
  $rule_sets[$index]['allow']['subtotal'] = $this->checkSubtotalMatches($rule);
983
+ if(in_array($rule->subtotal_to_apply_option, array('atleast'))){
984
+ $has_bogo = $this->has_bogo_auto_add($rule_sets[$index]);
985
+ if($has_bogo){
986
+ if(!did_action('woo_discount_rules_run_auto_add_bogo_product')){
987
+ global $flycart_woo_discount_rules;
988
+ remove_action('woocommerce_after_cart_item_quantity_update', array($flycart_woo_discount_rules->discountBase, 'handleDiscount'), 100);
989
+ do_action('woo_discount_rules_run_auto_add_bogo_product', '');
990
+ }
991
+ }
992
+ }
993
+
994
  }
995
  }
996
 
1031
  self::$rule_sets_generated = 1;
1032
  }
1033
 
1034
+ /**
1035
+ * Has BOGO auto add
1036
+ *
1037
+ * @param $rule array
1038
+ * @return boolean
1039
+ * */
1040
+ public function has_bogo_auto_add($rule){
1041
+ $has_BOGO = false;
1042
+ if(isset($rule['method']) && $rule['method'] == 'qty_based'){
1043
+ if (isset($rule['type']) && isset($rule['apply_to'])) {
1044
+ //Check for product_discount to apply the rule only once
1045
+ if(isset($rule['discount'])) {
1046
+ if (!empty($rule['discount'])) {
1047
+ foreach ($rule['discount'] as $discount_rules) {
1048
+ if (isset($discount_rules->discount_type) && $discount_rules->discount_type == 'product_discount') {
1049
+ if (isset($discount_rules->discount_product_option) && $discount_rules->discount_product_option == 'all') {
1050
+ $has_BOGO = true;
1051
+ break;
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+
1060
+ return $has_BOGO;
1061
+ }
1062
+
1063
  /**
1064
  * Check with users roles
1065
  * */
1105
  if(isset($rule->subtotal_to_apply_option)){
1106
  if($rule->subtotal_to_apply_option == 'atleast'){
1107
  if(isset($rule->subtotal_to_apply) && $rule->subtotal_to_apply > 0){
1108
+ //get_calculated_item_subtotal_manually
1109
+ $sub_total = FlycartWooDiscountRulesGeneralHelper::get_calculated_item_subtotal_manually($rule);//FlycartWooDiscountRulesAdvancedHelper::get_calculated_item_subtotal();
1110
  if(!($rule->subtotal_to_apply <= $sub_total)){
1111
  $allowed = 0;
1112
  }
1798
  if(empty($cartItem['data'])){
1799
  continue;
1800
  }
1801
+
1802
+ //Exclude the bundled products items
1803
+ $exclude_bundle_product_item = apply_filters('woo_discount_rules_exclude_woocommerce_bundled_item', true, $cartItem);
1804
+ if($exclude_bundle_product_item){
1805
+ if(isset($cartItem['bundled_item_id']) && !empty($cartItem['bundled_item_id'])){
1806
+ continue;
1807
+ }
1808
+ }
1809
+
1810
+ $exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $cartItem);
1811
+ if($exclude_cart_item) continue;
1812
+
1813
  $is_exclude_sale_items = $this->isItemInSaleItems($exclude_sale_items, $cartItem['data']);
1814
  if($is_exclude_sale_items){
1815
  continue;
4370
  if($greatestDiscountPrice > 0 || ($this->hasDiscountForProductId($maxProductId))){
4371
  $greatestDiscountPrice = FlycartWoocommerceProduct::wc_price($greatestDiscountPrice);
4372
  } else {
4373
+ $greatestDiscountPrice = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($maxProduct) : FlycartWoocommerceProduct::get_price_excluding_tax( $maxProduct );
4374
+ $greatestDiscountPrice = FlycartWoocommerceProduct::wc_price($greatestDiscountPrice);
4375
  }
4376
  if($minProductId){
4377
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
4379
  if($leastDiscountPrice > 0 || ($this->hasDiscountForProductId($minProductId))){
4380
  $leastDiscountPrice = FlycartWoocommerceProduct::wc_price($leastDiscountPrice);
4381
  } else {
4382
+ $leastDiscountPrice = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($minProduct) : FlycartWoocommerceProduct::get_price_excluding_tax( $minProduct );
4383
+ $leastDiscountPrice = FlycartWoocommerceProduct::wc_price($leastDiscountPrice);
4384
  }
4385
  if($display_only_lowest_price){
4386
  $price_to_display = $leastDiscountPrice;
includes/survey.php CHANGED
@@ -236,38 +236,42 @@ class FlycartWooDiscountRulesSurvey
236
  {
237
  $options = array(
238
  1 => array(
 
 
 
 
239
  'title' => esc_html__('I am switching to a different discount plugin.', $this->plugin_text_domain),
240
  'reason' => 'I am switching to a different discount plugin.'
241
  ),
242
- 2 => array(
243
  'title' => esc_html__('I could not get my discount rule to work.', $this->plugin_text_domain),
244
  'reason' => 'I could not get my discount rule to work.'
245
  ),
246
- 3 => array(
247
  'title' => esc_html__('It does not meet my discount requirements.', $this->plugin_text_domain),
248
  'reason' => 'It does not meet my discount requirements.'
249
  ),
250
- 4 => array(
251
  'title' => esc_html__('Plugin is complex.', $this->plugin_text_domain),
252
  'reason' => 'Plugin is complex.'
253
  ),
254
- 5 => array(
255
  'title' => esc_html__('I\'m trying to troubleshoot the plugin.', $this->plugin_text_domain),
256
  'reason' => 'I\'m trying to troubleshoot the plugin.'
257
  ),
258
- 6 => array(
259
  'title' => esc_html__('I was instructed to deactivate by Flycart Support.', $this->plugin_text_domain),
260
  'reason' => 'I was instructed to deactivate by Flycart Support.'
261
  ),
262
- 7 => array(
263
  'title' => esc_html__('I no longer use this plugin.', $this->plugin_text_domain),
264
  'reason' => 'I no longer use this plugin.'
265
  ),
266
- 8 => array(
267
  'title' => esc_html__('It\'s a temporary deactivation.', $this->plugin_text_domain),
268
  'reason' => 'It\'s a temporary deactivation.'
269
  ),
270
- 9 => array(
271
  'title' => esc_html__('Other', $this->plugin_text_domain),
272
  'reason' => 'Other',
273
  'details' => esc_html__('Please share the reason', $this->plugin_text_domain),
236
  {
237
  $options = array(
238
  1 => array(
239
+ 'title' => esc_html__('Upgrading to PRO.', $this->plugin_text_domain),
240
+ 'reason' => 'Upgrading to PRO.'
241
+ ),
242
+ 2 => array(
243
  'title' => esc_html__('I am switching to a different discount plugin.', $this->plugin_text_domain),
244
  'reason' => 'I am switching to a different discount plugin.'
245
  ),
246
+ 3 => array(
247
  'title' => esc_html__('I could not get my discount rule to work.', $this->plugin_text_domain),
248
  'reason' => 'I could not get my discount rule to work.'
249
  ),
250
+ 4 => array(
251
  'title' => esc_html__('It does not meet my discount requirements.', $this->plugin_text_domain),
252
  'reason' => 'It does not meet my discount requirements.'
253
  ),
254
+ 5 => array(
255
  'title' => esc_html__('Plugin is complex.', $this->plugin_text_domain),
256
  'reason' => 'Plugin is complex.'
257
  ),
258
+ 6 => array(
259
  'title' => esc_html__('I\'m trying to troubleshoot the plugin.', $this->plugin_text_domain),
260
  'reason' => 'I\'m trying to troubleshoot the plugin.'
261
  ),
262
+ 7 => array(
263
  'title' => esc_html__('I was instructed to deactivate by Flycart Support.', $this->plugin_text_domain),
264
  'reason' => 'I was instructed to deactivate by Flycart Support.'
265
  ),
266
+ 8 => array(
267
  'title' => esc_html__('I no longer use this plugin.', $this->plugin_text_domain),
268
  'reason' => 'I no longer use this plugin.'
269
  ),
270
+ 9 => array(
271
  'title' => esc_html__('It\'s a temporary deactivation.', $this->plugin_text_domain),
272
  'reason' => 'It\'s a temporary deactivation.'
273
  ),
274
+ 10 => array(
275
  'title' => esc_html__('Other', $this->plugin_text_domain),
276
  'reason' => 'Other',
277
  'details' => esc_html__('Please share the reason', $this->plugin_text_domain),
loader.php CHANGED
@@ -394,6 +394,8 @@ if(!class_exists('FlycartWooDiscountRules')){
394
  }
395
  }
396
 
 
 
397
  add_action( 'woocommerce_checkout_create_order_line_item', array( $this->pricingRules, 'onCreateWoocommerceOrderLineItem'), 10, 4);
398
  $display_you_saved_text = $this->discountBase->getConfigData('display_you_saved_text', 'no');
399
  if(in_array($display_you_saved_text, array('on_each_line_item', 'both_line_item_and_after_total'))){
@@ -477,6 +479,24 @@ if(!class_exists('FlycartWooDiscountRules')){
477
  }
478
 
479
  add_filter('woocommerce_get_shop_coupon_data', array('FlycartWooDiscountRulesGeneralHelper', 'addVirtualCoupon'), 9, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  }
481
 
482
  /**
394
  }
395
  }
396
 
397
+ add_action('woo_discount_rules_run_auto_add_bogo_product', array($this->pricingRules, 'handleBOGODiscountAfterApplyCoupon'), 10);
398
+
399
  add_action( 'woocommerce_checkout_create_order_line_item', array( $this->pricingRules, 'onCreateWoocommerceOrderLineItem'), 10, 4);
400
  $display_you_saved_text = $this->discountBase->getConfigData('display_you_saved_text', 'no');
401
  if(in_array($display_you_saved_text, array('on_each_line_item', 'both_line_item_and_after_total'))){
479
  }
480
 
481
  add_filter('woocommerce_get_shop_coupon_data', array('FlycartWooDiscountRulesGeneralHelper', 'addVirtualCoupon'), 9, 2);
482
+
483
+ $show_promotion_messages = $this->discountBase->getConfigData('show_promotion_messages', array());
484
+ if(!empty($show_promotion_messages) && is_array($show_promotion_messages)){
485
+ if(in_array('shop_page', $show_promotion_messages)){
486
+ add_action('woocommerce_before_shop_loop', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessages'), 10);
487
+ }
488
+ if(in_array('product_page', $show_promotion_messages)){
489
+ add_action('woocommerce_before_single_product', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessages'), 10);
490
+ }
491
+ if(in_array('cart_page', $show_promotion_messages)){
492
+ add_action('woocommerce_before_cart', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessages'), 10);
493
+ }
494
+ if(in_array('checkout_page', $show_promotion_messages)){
495
+ add_action('woocommerce_before_checkout_form', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessagesInCheckoutContainer'), 10);
496
+ add_action('woocommerce_review_order_before_cart_contents', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessagesInCheckout'), 10);
497
+ }
498
+ }
499
+ add_action('woo_discount_rules_load_promotion_messages', array('FlycartWooDiscountRulesGeneralHelper', 'displayPromotionMessages'));
500
  }
501
 
502
  /**
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: flycart
3
  Donate link: https://flycart.org/
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
- Tested up to: 5.2
7
- Stable tag: 1.8.1
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -336,6 +336,16 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
336
 
337
  == Changelog ==
338
 
 
 
 
 
 
 
 
 
 
 
339
  = 1.8.1 - 21/10/19 =
340
  * Feature - First order option in Purchase history.
341
  * Feature - Category exclude option in cart rules.
3
  Donate link: https://flycart.org/
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
+ Tested up to: 5.3
7
+ Stable tag: 1.8.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
336
 
337
  == Changelog ==
338
 
339
+ = 1.8.2 - 14/11/19 =
340
+ * Feature - Option to display promotion message in cart about the upcoming discount (Subtotal based).
341
+ * Improvement - Upgrading to pro option in deactivation survey.
342
+ * Improvement - WordPress 5.3 UI improvement.
343
+ * Fix - PHP Fatal error Call to a member function get() on null while apply coupon through third-party plugin(On renewal subscription).
344
+ * Fix - Wrong subtotal calculation while having tax settings as excluding tax and display by including tax.
345
+ * Fix - Auto add free product on subtotal matches in price rule.
346
+ * Fix - Dynamic coupon removed, while remove third party coupon option is enabled.
347
+ * Fix - Loading trashed coupon in the selected coupon fields while having large number of coupons.
348
+
349
  = 1.8.1 - 21/10/19 =
350
  * Feature - First order option in Purchase history.
351
  * Feature - Category exclude option in cart rules.
view/settings_promotion.php CHANGED
@@ -119,4 +119,30 @@ if (!defined('ABSPATH')) exit; // Exit if accessed directly
119
  </div>
120
  </div>
121
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </div>
119
  </div>
120
  </div>
121
  </div>
122
+ <div class="row form-group">
123
+ <div class="col-md-2">
124
+ <label>
125
+ <?php esc_html_e('Subtotal based promo text (available only in cart rules -> subtotal based discounts)', 'woo-discount-rules'); ?>
126
+ </label>
127
+ </div>
128
+ <?php $data['show_promotion_messages'] = (isset($data['show_promotion_messages']) ? $data['show_promotion_messages'] : array());
129
+ if(!is_array($data['show_promotion_messages'])) $data['show_promotion_messages'] = array();
130
+ ?>
131
+ <div class="col-md-6">
132
+ <select class="selectpicker" name="show_promotion_messages[]" multiple id="show_promotion_messages" title="<?php esc_html_e('Disabled', 'woo-discount-rules'); ?>">
133
+ <option <?php if (in_array("shop_page", $data['show_promotion_messages'])) { ?> selected=selected <?php } ?>
134
+ value="shop_page"><?php esc_html_e('Shop page', 'woo-discount-rules'); ?>
135
+ </option>
136
+ <option <?php if (in_array("product_page", $data['show_promotion_messages'])) { ?> selected=selected <?php } ?>
137
+ value="product_page"><?php esc_html_e('Product page', 'woo-discount-rules'); ?>
138
+ </option>
139
+ <option <?php if (in_array("cart_page", $data['show_promotion_messages'])) { ?> selected=selected <?php } ?>
140
+ value="cart_page"><?php esc_html_e('Cart page', 'woo-discount-rules'); ?>
141
+ </option>
142
+ <option <?php if (in_array("checkout_page", $data['show_promotion_messages'])) { ?> selected=selected <?php } ?>
143
+ value="checkout_page"><?php esc_html_e('Checkout page', 'woo-discount-rules'); ?>
144
+ </option>
145
+ </select>
146
+ </div>
147
+ </div>
148
  </div>
view/view-cart-rules.php CHANGED
@@ -706,6 +706,44 @@ $has_large_no_of_coupon = FlycartWooDiscountBase::hasLargeNumberOfCoupon();
706
  }
707
  ?>
708
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
  </div>
710
  <div align="right">
711
  <input type="button" class="btn btn-warning general_tab" value="<?php esc_attr_e('Previous', 'woo-discount-rules'); ?>">
706
  }
707
  ?>
708
  </div>
709
+ <?php $show_promotion_messages = $woo_settings->getConfigData('show_promotion_messages', array());
710
+ if((!empty($show_promotion_messages)) || apply_filters('woo_discount_rules_load_promotion_messages_manually', false)){
711
+ ?>
712
+ <div class="show_promotion_message_cart_block">
713
+ <h4><?php esc_html_e('Promotion message', 'woo-discount-rules'); ?></h4>
714
+ <div class="show_promotion_message_fields_con">
715
+ <div class="form-group">
716
+ <div class="row promotion_subtotal_from_con">
717
+ <div class="col-md-3">
718
+ <label> <?php esc_html_e('Subtotal from', 'woo-discount-rules'); ?> </label>
719
+ </div>
720
+ <div class="col-md-9">
721
+ <div class="form-group">
722
+ <?php $promotion_subtotal_from = (isset($data->promotion_subtotal_from))? $data->promotion_subtotal_from : '' ?>
723
+ <input class="form-control" type="text" name="promotion_subtotal_from" id="promotion_subtotal_from" value="<?php echo $promotion_subtotal_from; ?>" />
724
+ <span class="wdr_desc_text"><?php echo __('Set a threshold from which you want to start showing the promotion message<br>Example: Let\'s say, you offer a 10% discount for $1000 and above. You may want to set 900 here. So that the customer can see the promo text when his cart subtotal reaches 900','woo-discount-rules'); ?></span>
725
+ </div>
726
+ </div>
727
+ </div>
728
+ <div class="row">
729
+ <div class="col-md-3">
730
+ <label> <?php esc_html_e('Message', 'woo-discount-rules'); ?> </label>
731
+ </div>
732
+ <div class="col-md-9">
733
+ <div class="form-group">
734
+ <?php $promotion_message = (isset($data->promotion_message))? $data->promotion_message : '' ?>
735
+ <textarea class="form-control" name="promotion_message" id="promotion_message" placeholder="<?php esc_html_e('Spend {{difference_amount}} more and get 10% discount', 'woo-discount-rules'); ?>"><?php echo $promotion_message; ?></textarea>
736
+ <span class="wdr_desc_text">
737
+ <?php esc_html_e('{{difference_amount}} -> Difference amount to get discount', 'woo-discount-rules'); ?><br>
738
+ <?php _e('<b>Eg:</b> Spend {{difference_amount}} more and get 10% discount', 'woo-discount-rules'); ?>
739
+ </span>
740
+ </div>
741
+ </div>
742
+ </div>
743
+ </div>
744
+ </div>
745
+ </div>
746
+ <?php }?>
747
  </div>
748
  <div align="right">
749
  <input type="button" class="btn btn-warning general_tab" value="<?php esc_attr_e('Previous', 'woo-discount-rules'); ?>">
view/view-pricing-rules.php CHANGED
@@ -672,7 +672,7 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
672
  <div class="set_discount_with_range_warning">
673
  <div class="notice inline notice-warning notice-alt">
674
  <p>
675
- <?php esc_html_e('Package / bundle deals should NOT be mixed with any other adjustment types when adding ranges. Example: If your first range\'s adjustment type is Package / Bundle deal, other ranges should also be same type.', 'woo-discount-rules'); ?>
676
  </p>
677
  </div>
678
  <br>
672
  <div class="set_discount_with_range_warning">
673
  <div class="notice inline notice-warning notice-alt">
674
  <p>
675
+ <?php esc_html_e('Bundle (Set) Discount should NOT be mixed with any other adjustment types when adding ranges. Example: If your first range\'s adjustment type is Bundle (Set) Discount, other ranges should also be same type.', 'woo-discount-rules'); ?>
676
  </p>
677
  </div>
678
  <br>
woo-discount-rules.php CHANGED
@@ -5,13 +5,13 @@
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
- * Version: 1.8.1
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 2.4
14
- * WC tested up to: 3.7
15
  */
16
 
17
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 1.8.2
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 2.4
14
+ * WC tested up to: 3.8
15
  */
16
 
17
  if (!defined('ABSPATH')) exit; // Exit if accessed directly