Discount Rules for WooCommerce - Version 2.3.0

Version Description

  • 14/10/20 =
  • Feature - Discount table for variants while changing variant options
  • Fix - Fatal error because of get_posts method.
  • Fix - Tax calculation in discount fee.
  • Fix - Wrong discount in BOGO while having apply all matched rules option.
  • Fix - Coupon name not displaying in cart.
  • Fix - Metorik API not working with Discount Rules.
  • Fix - SKU based rule not displays in onsale page.
  • Fix - Strikeout doesn't displays when Suppress third party discount plugins option is enabled.
  • Improvement - Cart strikeout improvements.
  • Improvement - Improved discount info in order meta.
  • Improvement - UI for RTL.
Download this release

Release Info

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

Code changes from version 2.2.2 to 2.3.0

i18n/languages/woo-discount-rules.pot CHANGED
@@ -13,8 +13,8 @@ msgstr ""
13
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;"
14
 
15
  #: common.php:9 v2/App/Controllers/Admin/Tabs/Statistics.php:118
16
- #: v2/App/Controllers/Admin/WDRAjax.php:51
17
  #: v2/App/Controllers/Admin/WDRAjax.php:54
 
18
  msgid "Authentication required"
19
  msgstr ""
20
 
@@ -183,13 +183,13 @@ msgstr ""
183
 
184
  #: v1/helper/general-helper.php:797
185
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:10
186
- #: v2/App/Views/Admin/Rules/Manage.php:134
187
- #: v2/App/Views/Admin/Rules/Manage.php:135
188
- #: v2/App/Views/Admin/Rules/Manage.php:136
189
- #: v2/App/Views/Admin/Rules/Manage.php:137
190
- #: v2/App/Views/Admin/Rules/Manage.php:138
191
- #: v2/App/Views/Admin/Rules/Manage.php:139
192
- #: v2/App/Views/Admin/Rules/Manage.php:140
193
  #: v2/App/Views/Admin/Tabs/settings.php:24
194
  #: v2/App/Views/Admin/Tabs/settings.php:64
195
  #: v2/App/Views/Admin/Tabs/settings.php:121
@@ -201,11 +201,11 @@ msgid "Read Docs"
201
  msgstr ""
202
 
203
  #: v1/helper/general-helper.php:1034 v1/view/view-cart-rules.php:697
204
- #: v1/view/view-pricing-rules.php:433 v2/App/Helpers/Woocommerce.php:1492
205
  msgid "Coupon already exists in WooCommerce. Please select another name"
206
  msgstr ""
207
 
208
- #: v1/helper/general-helper.php:1266 v2/App/Helpers/Helper.php:321
209
  msgid "Invalid token"
210
  msgstr ""
211
 
@@ -754,7 +754,7 @@ msgid "Action"
754
  msgstr ""
755
 
756
  #: v1/includes/discount-base.php:1169 v1/view/settings.php:33
757
- #: v1/view/settings_taxonomy.php:21 v2/App/Views/Admin/Rules/Manage.php:87
758
  msgid "Save"
759
  msgstr ""
760
 
@@ -1017,7 +1017,7 @@ msgid ""
1017
  msgstr ""
1018
 
1019
  #: v1/includes/discount-base.php:1302
1020
- #: v2/App/Controllers/ManageDiscount.php:1111
1021
  #, php-format
1022
  msgid ""
1023
  "Sorry, it is not possible to apply coupon <b>\"%s\"</b> as you already have "
@@ -1281,7 +1281,7 @@ msgstr ""
1281
 
1282
  #: v1/view/cart-rules.php:104 v1/view/cart-rules.php:214
1283
  #: v1/view/pricing-rules.php:134 v1/view/pricing-rules.php:244
1284
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:208
1285
  msgid "Language"
1286
  msgstr ""
1287
 
@@ -1438,7 +1438,7 @@ msgstr ""
1438
  #: v1/view/template/discount-table.php:42 v1/view/view-cart-rules.php:756
1439
  #: v1/view/view-pricing-rules.php:708 v2/App/Controllers/Admin/Settings.php:443
1440
  #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:59
1441
- #: v2/App/Views/Admin/Rules/Manage.php:195
1442
  msgid "Discount"
1443
  msgstr ""
1444
 
@@ -2104,7 +2104,7 @@ msgid "To"
2104
  msgstr ""
2105
 
2106
  #: v1/view/view-cart-rules.php:140 v1/view/view-pricing-rules.php:149
2107
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:140
2108
  #, php-format
2109
  msgid "Current date and time: %s"
2110
  msgstr ""
@@ -2689,7 +2689,7 @@ msgid "Filter (Buy)"
2689
  msgstr ""
2690
 
2691
  #: v2/App/Controllers/Admin/Settings.php:440
2692
- #: v2/App/Views/Admin/Rules/Manage.php:149
2693
  msgid "Filter"
2694
  msgstr ""
2695
 
@@ -3024,21 +3024,23 @@ msgstr ""
3024
  msgid "Bulk Discount"
3025
  msgstr ""
3026
 
3027
- #: v2/App/Controllers/ManageDiscount.php:678
3028
- #: v2/App/Controllers/ManageDiscount.php:873 v2/App/Helpers/Helper.php:268
 
 
3029
  msgid "Cart discount"
3030
  msgstr ""
3031
 
3032
- #: v2/App/Controllers/ManageDiscount.php:1125
3033
  msgid "Coupon code applied successfully."
3034
  msgstr ""
3035
 
3036
- #: v2/App/Controllers/ManageDiscount.php:1532
3037
  #: v2/App/Views/Admin/Tabs/settings.php:409
3038
  msgid "Discount <strong>{{title}}</strong> has been applied to your cart."
3039
  msgstr ""
3040
 
3041
- #: v2/App/Controllers/ManageDiscount.php:1641
3042
  msgid "You saved {{total_discount}}"
3043
  msgstr ""
3044
 
@@ -3114,11 +3116,11 @@ msgid ""
3114
  "Medium, 6 of Product A - Large, then the count will be: 6+4+2 = 12\n"
3115
  msgstr ""
3116
 
3117
- #: v2/App/Helpers/Helper.php:335
3118
  msgid "Update now"
3119
  msgstr ""
3120
 
3121
- #: v2/App/Helpers/Helper.php:340
3122
  #, php-format
3123
  msgid ""
3124
  "You are using a lower version of our <b>Woo Discount Rules PRO 2.0</b> "
@@ -3291,176 +3293,176 @@ msgstr ""
3291
  msgid "Bundle (Set) Discount - PRO -"
3292
  msgstr ""
3293
 
3294
- #: v2/App/Helpers/Rule.php:1178 v2/App/Helpers/Rule.php:1189
3295
  msgid "discount"
3296
  msgstr ""
3297
 
3298
- #: v2/App/Helpers/Rule.php:1249 v2/App/Helpers/Rule.php:1349
3299
  #: v2/App/Views/Admin/Tabs/ImportExport.php:99
3300
  msgid "Untitled Rule"
3301
  msgstr ""
3302
 
3303
- #: v2/App/Helpers/Validation.php:139 v2/App/Helpers/Validation.php:144
3304
- #: v2/App/Helpers/Validation.php:310
3305
  msgid "Invalid characters"
3306
  msgstr ""
3307
 
3308
- #: v2/App/Helpers/Validation.php:140
3309
  msgid ""
3310
  "Accepts only letters a-z, numbers 0-9 and spaces with special characters"
3311
  msgstr ""
3312
 
3313
- #: v2/App/Helpers/Validation.php:141
3314
  msgid "Accepts only numbers 0-9 and one dot"
3315
  msgstr ""
3316
 
3317
- #: v2/App/Helpers/Validation.php:142
3318
  msgid "Accepts only 0 or 1"
3319
  msgstr ""
3320
 
3321
- #: v2/App/Helpers/Validation.php:143
3322
  msgid "Accepts only hex color code"
3323
  msgstr ""
3324
 
3325
- #: v2/App/Helpers/Validation.php:311
3326
  msgid "Accept only yes, on, 1, true"
3327
  msgstr ""
3328
 
3329
- #: v2/App/Helpers/Validation.php:312
3330
  msgid "Should not contain any tags"
3331
  msgstr ""
3332
 
3333
- #: v2/App/Helpers/Validation.php:313
3334
  msgid "Should not contain any tags and special characters"
3335
  msgstr ""
3336
 
3337
- #: v2/App/Helpers/Validation.php:436
3338
  msgid "Validation error"
3339
  msgstr ""
3340
 
3341
- #: v2/App/Helpers/Woocommerce.php:922
3342
  msgid "Sunday"
3343
  msgstr ""
3344
 
3345
- #: v2/App/Helpers/Woocommerce.php:923
3346
  msgid "Monday"
3347
  msgstr ""
3348
 
3349
- #: v2/App/Helpers/Woocommerce.php:924
3350
  msgid "Tuesday"
3351
  msgstr ""
3352
 
3353
- #: v2/App/Helpers/Woocommerce.php:925
3354
  msgid "Wednesday"
3355
  msgstr ""
3356
 
3357
- #: v2/App/Helpers/Woocommerce.php:926
3358
  msgid "Thursday"
3359
  msgstr ""
3360
 
3361
- #: v2/App/Helpers/Woocommerce.php:927
3362
  msgid "Friday"
3363
  msgstr ""
3364
 
3365
- #: v2/App/Helpers/Woocommerce.php:928
3366
  msgid "Saturday"
3367
  msgstr ""
3368
 
3369
- #: v2/App/Helpers/Woocommerce.php:939
3370
  msgid ""
3371
  "Woocommerce before main content(Archive / Shop / Cat Pages / single product)"
3372
  msgstr ""
3373
 
3374
- #: v2/App/Helpers/Woocommerce.php:940
3375
  msgid "Woocommerce archive description(Archive / Shop / Cat Pages)"
3376
  msgstr ""
3377
 
3378
- #: v2/App/Helpers/Woocommerce.php:941
3379
  msgid "Woocommerce before shop loop(Archive / Shop / Cat Pages)"
3380
  msgstr ""
3381
 
3382
- #: v2/App/Helpers/Woocommerce.php:942
3383
  msgid "Woocommerce after shop loop(Archive / Shop / Cat Pages)"
3384
  msgstr ""
3385
 
3386
- #: v2/App/Helpers/Woocommerce.php:943
3387
  msgid ""
3388
  "Woocommerce after main content(Archive / Shop / Cat Pages / single product)"
3389
  msgstr ""
3390
 
3391
- #: v2/App/Helpers/Woocommerce.php:944 v2/App/Views/Admin/Tabs/settings.php:194
3392
  #: v2/App/Views/Admin/Tabs/settings.php:212
3393
  msgid "Woocommerce before single product"
3394
  msgstr ""
3395
 
3396
- #: v2/App/Helpers/Woocommerce.php:945 v2/App/Views/Admin/Tabs/settings.php:196
3397
  #: v2/App/Views/Admin/Tabs/settings.php:214
3398
  msgid "Woocommerce before single product summary"
3399
  msgstr ""
3400
 
3401
- #: v2/App/Helpers/Woocommerce.php:946 v2/App/Views/Admin/Tabs/settings.php:195
3402
  #: v2/App/Views/Admin/Tabs/settings.php:213
3403
  msgid "Woocommerce after single product summary"
3404
  msgstr ""
3405
 
3406
- #: v2/App/Helpers/Woocommerce.php:947 v2/App/Views/Admin/Tabs/settings.php:193
3407
  #: v2/App/Views/Admin/Tabs/settings.php:211
3408
  msgid "Woocommerce after single product"
3409
  msgstr ""
3410
 
3411
- #: v2/App/Helpers/Woocommerce.php:948
3412
  msgid "Woocommerce before cart"
3413
  msgstr ""
3414
 
3415
- #: v2/App/Helpers/Woocommerce.php:949
3416
  msgid "Woocommerce before cart table"
3417
  msgstr ""
3418
 
3419
- #: v2/App/Helpers/Woocommerce.php:950
3420
  msgid "Woocommerce before cart contents"
3421
  msgstr ""
3422
 
3423
- #: v2/App/Helpers/Woocommerce.php:951
3424
  msgid "Woocommerce cart contents"
3425
  msgstr ""
3426
 
3427
- #: v2/App/Helpers/Woocommerce.php:952
3428
  msgid "Woocommerce after cart contents"
3429
  msgstr ""
3430
 
3431
- #: v2/App/Helpers/Woocommerce.php:953
3432
  msgid "Woocommerce after cart table"
3433
  msgstr ""
3434
 
3435
- #: v2/App/Helpers/Woocommerce.php:954
3436
  msgid "Woocommerce after cart"
3437
  msgstr ""
3438
 
3439
- #: v2/App/Helpers/Woocommerce.php:955
3440
  msgid "Woocommerce before checkout form"
3441
  msgstr ""
3442
 
3443
- #: v2/App/Helpers/Woocommerce.php:957
3444
  msgid "Woocommerce before checkout billing form"
3445
  msgstr ""
3446
 
3447
- #: v2/App/Helpers/Woocommerce.php:958
3448
  msgid "Woocommerce after checkout billing form"
3449
  msgstr ""
3450
 
3451
- #: v2/App/Helpers/Woocommerce.php:959
3452
  msgid "Woocommerce before checkout shipping form"
3453
  msgstr ""
3454
 
3455
- #: v2/App/Helpers/Woocommerce.php:960
3456
  msgid "Woocommerce after checkout shipping form"
3457
  msgstr ""
3458
 
3459
- #: v2/App/Helpers/Woocommerce.php:961
3460
  msgid "Woocommerce before order notes"
3461
  msgstr ""
3462
 
3463
- #: v2/App/Helpers/Woocommerce.php:962
3464
  msgid "Woocommerce after order notes"
3465
  msgstr ""
3466
 
@@ -3540,62 +3542,62 @@ msgid "Conditions Relationship "
3540
  msgstr ""
3541
 
3542
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:27
3543
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:116
3544
  msgid "Match All"
3545
  msgstr ""
3546
 
3547
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:29
3548
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:118
3549
  msgid "Match Any"
3550
  msgstr ""
3551
 
3552
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:77
3553
  #: v2/App/Views/Admin/Rules/Others/CommonTemplates.php:87
3554
  msgid "Condition Type"
3555
  msgstr ""
3556
 
3557
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:106
3558
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:126
3559
  msgid "Add condition"
3560
  msgstr ""
3561
 
3562
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:114
3563
  msgid "Conditions Relationship"
3564
  msgstr ""
3565
 
3566
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:138
3567
  msgid "Rule Limits"
3568
  msgstr ""
3569
 
3570
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:143
3571
  msgid "Rule Used: "
3572
  msgstr ""
3573
 
3574
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:153
3575
  msgid "Unlimited"
3576
  msgstr ""
3577
 
3578
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:160
3579
  msgid "Maximum usage limit"
3580
  msgstr ""
3581
 
3582
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:168
3583
  msgid "Rule Vaild From"
3584
  msgstr ""
3585
 
3586
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:173
3587
  msgid "Vaild from"
3588
  msgstr ""
3589
 
3590
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:180
3591
  msgid "Rule Valid To"
3592
  msgstr ""
3593
 
3594
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:184
3595
  msgid "Vaild to"
3596
  msgstr ""
3597
 
3598
- #: v2/App/Views/Admin/Rules/Conditions/Main.php:195
3599
  msgid "Select values"
3600
  msgstr ""
3601
 
@@ -3736,16 +3738,16 @@ msgstr ""
3736
  msgid "Discount Type"
3737
  msgstr ""
3738
 
3739
- #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:67
3740
  #: v2/App/Views/Admin/Tabs/settings.php:596
3741
  msgid "Discount Value"
3742
  msgstr ""
3743
 
3744
- #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:72
3745
  msgid "Label"
3746
  msgstr ""
3747
 
3748
- #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:76
3749
  msgid "Title column For Bulk Table"
3750
  msgstr ""
3751
 
@@ -3859,8 +3861,8 @@ msgstr ""
3859
  msgid "Add Range"
3860
  msgstr ""
3861
 
3862
- #: v2/App/Views/Admin/Rules/Discounts/Main.php:94
3863
- #: v2/App/Views/Admin/Rules/Discounts/simple.php:40
3864
  msgid "Show discount in cart as coupon instead of changing the product price ?"
3865
  msgstr ""
3866
 
@@ -3960,45 +3962,47 @@ msgstr ""
3960
  msgid " Validity expired"
3961
  msgstr ""
3962
 
3963
- #: v2/App/Views/Admin/Rules/Manage.php:64
 
3964
  msgid "Enable?"
3965
  msgstr ""
3966
 
3967
- #: v2/App/Views/Admin/Rules/Manage.php:73
 
3968
  msgid "Apply this rule if matched and ignore all other rules"
3969
  msgstr ""
3970
 
3971
- #: v2/App/Views/Admin/Rules/Manage.php:82
3972
  msgid "#Rule ID: "
3973
  msgstr ""
3974
 
3975
- #: v2/App/Views/Admin/Rules/Manage.php:89
3976
  msgid "Save & Close"
3977
  msgstr ""
3978
 
3979
- #: v2/App/Views/Admin/Rules/Manage.php:92
3980
  msgid "Cancel"
3981
  msgstr ""
3982
 
3983
- #: v2/App/Views/Admin/Rules/Manage.php:101
3984
  msgid "Choose a discount type"
3985
  msgstr ""
3986
 
3987
- #: v2/App/Views/Admin/Rules/Manage.php:105
3988
  msgid "Select Discount Type"
3989
  msgstr ""
3990
 
3991
- #: v2/App/Views/Admin/Rules/Manage.php:151
3992
  msgid ""
3993
  "Choose which <b>gets</b> discount (products/categories/attributes/SKU and so "
3994
  "on )"
3995
  msgstr ""
3996
 
3997
- #: v2/App/Views/Admin/Rules/Manage.php:152
3998
  msgid "Note : You can also exclude products/categories."
3999
  msgstr ""
4000
 
4001
- #: v2/App/Views/Admin/Rules/Manage.php:197
4002
  msgid "Select discount type and its value (percentage/price/fixed price)"
4003
  msgstr ""
4004
 
@@ -4574,7 +4578,7 @@ msgstr ""
4574
  #: v2/App/Views/Admin/Tabs/settings.php:682
4575
  #: v2/App/Views/Admin/Tabs/settings.php:728
4576
  #: v2/App/Views/Admin/Tabs/settings.php:795
4577
- #: v2/App/Views/Templates/discount_table.php:116
4578
  msgid " flat"
4579
  msgstr ""
4580
 
@@ -4643,6 +4647,6 @@ msgstr ""
4643
  msgid "15"
4644
  msgstr ""
4645
 
4646
- #: v2/App/Views/Templates/discount_table.php:111
4647
  msgid " (in cart)"
4648
  msgstr ""
13
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;"
14
 
15
  #: common.php:9 v2/App/Controllers/Admin/Tabs/Statistics.php:118
 
16
  #: v2/App/Controllers/Admin/WDRAjax.php:54
17
+ #: v2/App/Controllers/Admin/WDRAjax.php:57
18
  msgid "Authentication required"
19
  msgstr ""
20
 
183
 
184
  #: v1/helper/general-helper.php:797
185
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:10
186
+ #: v2/App/Views/Admin/Rules/Manage.php:148
187
+ #: v2/App/Views/Admin/Rules/Manage.php:149
188
+ #: v2/App/Views/Admin/Rules/Manage.php:150
189
+ #: v2/App/Views/Admin/Rules/Manage.php:151
190
+ #: v2/App/Views/Admin/Rules/Manage.php:152
191
+ #: v2/App/Views/Admin/Rules/Manage.php:153
192
+ #: v2/App/Views/Admin/Rules/Manage.php:154
193
  #: v2/App/Views/Admin/Tabs/settings.php:24
194
  #: v2/App/Views/Admin/Tabs/settings.php:64
195
  #: v2/App/Views/Admin/Tabs/settings.php:121
201
  msgstr ""
202
 
203
  #: v1/helper/general-helper.php:1034 v1/view/view-cart-rules.php:697
204
+ #: v1/view/view-pricing-rules.php:433 v2/App/Helpers/Woocommerce.php:1500
205
  msgid "Coupon already exists in WooCommerce. Please select another name"
206
  msgstr ""
207
 
208
+ #: v1/helper/general-helper.php:1266 v2/App/Helpers/Helper.php:322
209
  msgid "Invalid token"
210
  msgstr ""
211
 
754
  msgstr ""
755
 
756
  #: v1/includes/discount-base.php:1169 v1/view/settings.php:33
757
+ #: v1/view/settings_taxonomy.php:21 v2/App/Views/Admin/Rules/Manage.php:101
758
  msgid "Save"
759
  msgstr ""
760
 
1017
  msgstr ""
1018
 
1019
  #: v1/includes/discount-base.php:1302
1020
+ #: v2/App/Controllers/ManageDiscount.php:1141
1021
  #, php-format
1022
  msgid ""
1023
  "Sorry, it is not possible to apply coupon <b>\"%s\"</b> as you already have "
1281
 
1282
  #: v1/view/cart-rules.php:104 v1/view/cart-rules.php:214
1283
  #: v1/view/pricing-rules.php:134 v1/view/pricing-rules.php:244
1284
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:211
1285
  msgid "Language"
1286
  msgstr ""
1287
 
1438
  #: v1/view/template/discount-table.php:42 v1/view/view-cart-rules.php:756
1439
  #: v1/view/view-pricing-rules.php:708 v2/App/Controllers/Admin/Settings.php:443
1440
  #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:59
1441
+ #: v2/App/Views/Admin/Rules/Manage.php:209
1442
  msgid "Discount"
1443
  msgstr ""
1444
 
2104
  msgstr ""
2105
 
2106
  #: v1/view/view-cart-rules.php:140 v1/view/view-pricing-rules.php:149
2107
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:143
2108
  #, php-format
2109
  msgid "Current date and time: %s"
2110
  msgstr ""
2689
  msgstr ""
2690
 
2691
  #: v2/App/Controllers/Admin/Settings.php:440
2692
+ #: v2/App/Views/Admin/Rules/Manage.php:163
2693
  msgid "Filter"
2694
  msgstr ""
2695
 
3024
  msgid "Bulk Discount"
3025
  msgstr ""
3026
 
3027
+ #: v2/App/Controllers/ManageDiscount.php:694
3028
+ #: v2/App/Controllers/ManageDiscount.php:897
3029
+ #: v2/App/Controllers/ManageDiscount.php:900 v2/App/Helpers/Helper.php:268
3030
+ #: v2/App/Helpers/Helper.php:269
3031
  msgid "Cart discount"
3032
  msgstr ""
3033
 
3034
+ #: v2/App/Controllers/ManageDiscount.php:1155
3035
  msgid "Coupon code applied successfully."
3036
  msgstr ""
3037
 
3038
+ #: v2/App/Controllers/ManageDiscount.php:1570
3039
  #: v2/App/Views/Admin/Tabs/settings.php:409
3040
  msgid "Discount <strong>{{title}}</strong> has been applied to your cart."
3041
  msgstr ""
3042
 
3043
+ #: v2/App/Controllers/ManageDiscount.php:1695
3044
  msgid "You saved {{total_discount}}"
3045
  msgstr ""
3046
 
3116
  "Medium, 6 of Product A - Large, then the count will be: 6+4+2 = 12\n"
3117
  msgstr ""
3118
 
3119
+ #: v2/App/Helpers/Helper.php:336
3120
  msgid "Update now"
3121
  msgstr ""
3122
 
3123
+ #: v2/App/Helpers/Helper.php:341
3124
  #, php-format
3125
  msgid ""
3126
  "You are using a lower version of our <b>Woo Discount Rules PRO 2.0</b> "
3293
  msgid "Bundle (Set) Discount - PRO -"
3294
  msgstr ""
3295
 
3296
+ #: v2/App/Helpers/Rule.php:1201 v2/App/Helpers/Rule.php:1212
3297
  msgid "discount"
3298
  msgstr ""
3299
 
3300
+ #: v2/App/Helpers/Rule.php:1272 v2/App/Helpers/Rule.php:1372
3301
  #: v2/App/Views/Admin/Tabs/ImportExport.php:99
3302
  msgid "Untitled Rule"
3303
  msgstr ""
3304
 
3305
+ #: v2/App/Helpers/Validation.php:146 v2/App/Helpers/Validation.php:151
3306
+ #: v2/App/Helpers/Validation.php:317
3307
  msgid "Invalid characters"
3308
  msgstr ""
3309
 
3310
+ #: v2/App/Helpers/Validation.php:147
3311
  msgid ""
3312
  "Accepts only letters a-z, numbers 0-9 and spaces with special characters"
3313
  msgstr ""
3314
 
3315
+ #: v2/App/Helpers/Validation.php:148
3316
  msgid "Accepts only numbers 0-9 and one dot"
3317
  msgstr ""
3318
 
3319
+ #: v2/App/Helpers/Validation.php:149
3320
  msgid "Accepts only 0 or 1"
3321
  msgstr ""
3322
 
3323
+ #: v2/App/Helpers/Validation.php:150
3324
  msgid "Accepts only hex color code"
3325
  msgstr ""
3326
 
3327
+ #: v2/App/Helpers/Validation.php:318
3328
  msgid "Accept only yes, on, 1, true"
3329
  msgstr ""
3330
 
3331
+ #: v2/App/Helpers/Validation.php:319
3332
  msgid "Should not contain any tags"
3333
  msgstr ""
3334
 
3335
+ #: v2/App/Helpers/Validation.php:320
3336
  msgid "Should not contain any tags and special characters"
3337
  msgstr ""
3338
 
3339
+ #: v2/App/Helpers/Validation.php:443
3340
  msgid "Validation error"
3341
  msgstr ""
3342
 
3343
+ #: v2/App/Helpers/Woocommerce.php:930
3344
  msgid "Sunday"
3345
  msgstr ""
3346
 
3347
+ #: v2/App/Helpers/Woocommerce.php:931
3348
  msgid "Monday"
3349
  msgstr ""
3350
 
3351
+ #: v2/App/Helpers/Woocommerce.php:932
3352
  msgid "Tuesday"
3353
  msgstr ""
3354
 
3355
+ #: v2/App/Helpers/Woocommerce.php:933
3356
  msgid "Wednesday"
3357
  msgstr ""
3358
 
3359
+ #: v2/App/Helpers/Woocommerce.php:934
3360
  msgid "Thursday"
3361
  msgstr ""
3362
 
3363
+ #: v2/App/Helpers/Woocommerce.php:935
3364
  msgid "Friday"
3365
  msgstr ""
3366
 
3367
+ #: v2/App/Helpers/Woocommerce.php:936
3368
  msgid "Saturday"
3369
  msgstr ""
3370
 
3371
+ #: v2/App/Helpers/Woocommerce.php:947
3372
  msgid ""
3373
  "Woocommerce before main content(Archive / Shop / Cat Pages / single product)"
3374
  msgstr ""
3375
 
3376
+ #: v2/App/Helpers/Woocommerce.php:948
3377
  msgid "Woocommerce archive description(Archive / Shop / Cat Pages)"
3378
  msgstr ""
3379
 
3380
+ #: v2/App/Helpers/Woocommerce.php:949
3381
  msgid "Woocommerce before shop loop(Archive / Shop / Cat Pages)"
3382
  msgstr ""
3383
 
3384
+ #: v2/App/Helpers/Woocommerce.php:950
3385
  msgid "Woocommerce after shop loop(Archive / Shop / Cat Pages)"
3386
  msgstr ""
3387
 
3388
+ #: v2/App/Helpers/Woocommerce.php:951
3389
  msgid ""
3390
  "Woocommerce after main content(Archive / Shop / Cat Pages / single product)"
3391
  msgstr ""
3392
 
3393
+ #: v2/App/Helpers/Woocommerce.php:952 v2/App/Views/Admin/Tabs/settings.php:194
3394
  #: v2/App/Views/Admin/Tabs/settings.php:212
3395
  msgid "Woocommerce before single product"
3396
  msgstr ""
3397
 
3398
+ #: v2/App/Helpers/Woocommerce.php:953 v2/App/Views/Admin/Tabs/settings.php:196
3399
  #: v2/App/Views/Admin/Tabs/settings.php:214
3400
  msgid "Woocommerce before single product summary"
3401
  msgstr ""
3402
 
3403
+ #: v2/App/Helpers/Woocommerce.php:954 v2/App/Views/Admin/Tabs/settings.php:195
3404
  #: v2/App/Views/Admin/Tabs/settings.php:213
3405
  msgid "Woocommerce after single product summary"
3406
  msgstr ""
3407
 
3408
+ #: v2/App/Helpers/Woocommerce.php:955 v2/App/Views/Admin/Tabs/settings.php:193
3409
  #: v2/App/Views/Admin/Tabs/settings.php:211
3410
  msgid "Woocommerce after single product"
3411
  msgstr ""
3412
 
3413
+ #: v2/App/Helpers/Woocommerce.php:956
3414
  msgid "Woocommerce before cart"
3415
  msgstr ""
3416
 
3417
+ #: v2/App/Helpers/Woocommerce.php:957
3418
  msgid "Woocommerce before cart table"
3419
  msgstr ""
3420
 
3421
+ #: v2/App/Helpers/Woocommerce.php:958
3422
  msgid "Woocommerce before cart contents"
3423
  msgstr ""
3424
 
3425
+ #: v2/App/Helpers/Woocommerce.php:959
3426
  msgid "Woocommerce cart contents"
3427
  msgstr ""
3428
 
3429
+ #: v2/App/Helpers/Woocommerce.php:960
3430
  msgid "Woocommerce after cart contents"
3431
  msgstr ""
3432
 
3433
+ #: v2/App/Helpers/Woocommerce.php:961
3434
  msgid "Woocommerce after cart table"
3435
  msgstr ""
3436
 
3437
+ #: v2/App/Helpers/Woocommerce.php:962
3438
  msgid "Woocommerce after cart"
3439
  msgstr ""
3440
 
3441
+ #: v2/App/Helpers/Woocommerce.php:963
3442
  msgid "Woocommerce before checkout form"
3443
  msgstr ""
3444
 
3445
+ #: v2/App/Helpers/Woocommerce.php:965
3446
  msgid "Woocommerce before checkout billing form"
3447
  msgstr ""
3448
 
3449
+ #: v2/App/Helpers/Woocommerce.php:966
3450
  msgid "Woocommerce after checkout billing form"
3451
  msgstr ""
3452
 
3453
+ #: v2/App/Helpers/Woocommerce.php:967
3454
  msgid "Woocommerce before checkout shipping form"
3455
  msgstr ""
3456
 
3457
+ #: v2/App/Helpers/Woocommerce.php:968
3458
  msgid "Woocommerce after checkout shipping form"
3459
  msgstr ""
3460
 
3461
+ #: v2/App/Helpers/Woocommerce.php:969
3462
  msgid "Woocommerce before order notes"
3463
  msgstr ""
3464
 
3465
+ #: v2/App/Helpers/Woocommerce.php:970
3466
  msgid "Woocommerce after order notes"
3467
  msgstr ""
3468
 
3542
  msgstr ""
3543
 
3544
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:27
3545
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:119
3546
  msgid "Match All"
3547
  msgstr ""
3548
 
3549
  #: v2/App/Views/Admin/Rules/Conditions/Main.php:29
3550
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:121
3551
  msgid "Match Any"
3552
  msgstr ""
3553
 
3554
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:78
3555
  #: v2/App/Views/Admin/Rules/Others/CommonTemplates.php:87
3556
  msgid "Condition Type"
3557
  msgstr ""
3558
 
3559
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:109
3560
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:129
3561
  msgid "Add condition"
3562
  msgstr ""
3563
 
3564
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:117
3565
  msgid "Conditions Relationship"
3566
  msgstr ""
3567
 
3568
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:141
3569
  msgid "Rule Limits"
3570
  msgstr ""
3571
 
3572
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:146
3573
  msgid "Rule Used: "
3574
  msgstr ""
3575
 
3576
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:156
3577
  msgid "Unlimited"
3578
  msgstr ""
3579
 
3580
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:163
3581
  msgid "Maximum usage limit"
3582
  msgstr ""
3583
 
3584
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:171
3585
  msgid "Rule Vaild From"
3586
  msgstr ""
3587
 
3588
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:176
3589
  msgid "Vaild from"
3590
  msgstr ""
3591
 
3592
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:183
3593
  msgid "Rule Valid To"
3594
  msgstr ""
3595
 
3596
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:187
3597
  msgid "Vaild to"
3598
  msgstr ""
3599
 
3600
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:198
3601
  msgid "Select values"
3602
  msgstr ""
3603
 
3738
  msgid "Discount Type"
3739
  msgstr ""
3740
 
3741
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:63
3742
  #: v2/App/Views/Admin/Tabs/settings.php:596
3743
  msgid "Discount Value"
3744
  msgstr ""
3745
 
3746
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:68
3747
  msgid "Label"
3748
  msgstr ""
3749
 
3750
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:72
3751
  msgid "Title column For Bulk Table"
3752
  msgstr ""
3753
 
3861
  msgid "Add Range"
3862
  msgstr ""
3863
 
3864
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:95
3865
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:41
3866
  msgid "Show discount in cart as coupon instead of changing the product price ?"
3867
  msgstr ""
3868
 
3962
  msgid " Validity expired"
3963
  msgstr ""
3964
 
3965
+ #: v2/App/Views/Admin/Rules/Manage.php:66
3966
+ #: v2/App/Views/Admin/Rules/Manage.php:82
3967
  msgid "Enable?"
3968
  msgstr ""
3969
 
3970
+ #: v2/App/Views/Admin/Rules/Manage.php:75
3971
+ #: v2/App/Views/Admin/Rules/Manage.php:89
3972
  msgid "Apply this rule if matched and ignore all other rules"
3973
  msgstr ""
3974
 
3975
+ #: v2/App/Views/Admin/Rules/Manage.php:96
3976
  msgid "#Rule ID: "
3977
  msgstr ""
3978
 
3979
+ #: v2/App/Views/Admin/Rules/Manage.php:103
3980
  msgid "Save & Close"
3981
  msgstr ""
3982
 
3983
+ #: v2/App/Views/Admin/Rules/Manage.php:106
3984
  msgid "Cancel"
3985
  msgstr ""
3986
 
3987
+ #: v2/App/Views/Admin/Rules/Manage.php:115
3988
  msgid "Choose a discount type"
3989
  msgstr ""
3990
 
3991
+ #: v2/App/Views/Admin/Rules/Manage.php:119
3992
  msgid "Select Discount Type"
3993
  msgstr ""
3994
 
3995
+ #: v2/App/Views/Admin/Rules/Manage.php:165
3996
  msgid ""
3997
  "Choose which <b>gets</b> discount (products/categories/attributes/SKU and so "
3998
  "on )"
3999
  msgstr ""
4000
 
4001
+ #: v2/App/Views/Admin/Rules/Manage.php:166
4002
  msgid "Note : You can also exclude products/categories."
4003
  msgstr ""
4004
 
4005
+ #: v2/App/Views/Admin/Rules/Manage.php:211
4006
  msgid "Select discount type and its value (percentage/price/fixed price)"
4007
  msgstr ""
4008
 
4578
  #: v2/App/Views/Admin/Tabs/settings.php:682
4579
  #: v2/App/Views/Admin/Tabs/settings.php:728
4580
  #: v2/App/Views/Admin/Tabs/settings.php:795
4581
+ #: v2/App/Views/Templates/discount_table.php:118
4582
  msgid " flat"
4583
  msgstr ""
4584
 
4647
  msgid "15"
4648
  msgstr ""
4649
 
4650
+ #: v2/App/Views/Templates/discount_table.php:113
4651
  msgid " (in cart)"
4652
  msgstr ""
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.5
7
- Stable tag: 2.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -237,9 +237,9 @@ More information could be found in the documentation
237
 
238
  = Minimum Requirements =
239
 
240
- * WordPress 4.4.1 or greater
241
- * WooCommerce 2.6.1 or greater
242
- * PHP version 5.5.0 or greater
243
  * MySQL version 5.0 or greater
244
 
245
  == Frequently asked questions ==
@@ -329,6 +329,8 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
329
  3. Creating a price rule
330
  4. Example Promotion Offers created using Discount rules
331
  5. Discounted price is applied in the Cart
 
 
332
 
333
  == Credits ==
334
 
@@ -336,6 +338,19 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
336
 
337
  == Changelog ==
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  = 2.2.2 - 24/09/20 =
340
  * Feature - Apply as coupon option.
341
  * Fix - You saved message not showing on backend order page.
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.5
7
+ Stable tag: 2.3.0
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
237
 
238
  = Minimum Requirements =
239
 
240
+ * WordPress 4.6.1 or greater
241
+ * WooCommerce 3.0.0 or greater
242
+ * PHP version 5.6.0 or greater
243
  * MySQL version 5.0 or greater
244
 
245
  == Frequently asked questions ==
329
  3. Creating a price rule
330
  4. Example Promotion Offers created using Discount rules
331
  5. Discounted price is applied in the Cart
332
+ 6. Creating a Buy X get Y rule
333
+ 7. Free product auto added in cart
334
 
335
  == Credits ==
336
 
338
 
339
  == Changelog ==
340
 
341
+ = 2.3.0 - 14/10/20 =
342
+ * Feature - Discount table for variants while changing variant options
343
+ * Fix - Fatal error because of get_posts method.
344
+ * Fix - Tax calculation in discount fee.
345
+ * Fix - Wrong discount in BOGO while having apply all matched rules option.
346
+ * Fix - Coupon name not displaying in cart.
347
+ * Fix - Metorik API not working with Discount Rules.
348
+ * Fix - SKU based rule not displays in onsale page.
349
+ * Fix - Strikeout doesn't displays when Suppress third party discount plugins option is enabled.
350
+ * Improvement - Cart strikeout improvements.
351
+ * Improvement - Improved discount info in order meta.
352
+ * Improvement - UI for RTL.
353
+
354
  = 2.2.2 - 24/09/20 =
355
  * Feature - Apply as coupon option.
356
  * Fix - You saved message not showing on backend order page.
v2/App/Controllers/Admin/WDRAjax.php CHANGED
@@ -18,6 +18,7 @@ if (!defined('ABSPATH')) exit;
18
  class WDRAjax extends Base
19
  {
20
  public static $wdr_rules_table;
 
21
  public $search_result_limit = 20;
22
 
23
  /**
@@ -26,13 +27,15 @@ class WDRAjax extends Base
26
  public function __construct()
27
  {
28
  parent::__construct();
 
29
  self::$wdr_rules_table = (isset(self::$wdr_rules_table) && !empty(self::$wdr_rules_table)) ? self::$wdr_rules_table : WDR_PLUGIN_PREFIX.'rules';
30
  $this->search_result_limit = apply_filters('advanced_woo_discount_rules_select_search_limit', $this->search_result_limit);
31
  }
32
 
33
  protected function frontEndMethods(){
34
  return array(
35
- 'get_price_html'
 
36
  );
37
  }
38
 
@@ -595,7 +598,6 @@ class WDRAjax extends Base
595
  */
596
  public function wdr_ajax_get_price_html()
597
  {
598
- $manage_discount = new ManageDiscount();
599
  $product = $this->input->post('product_id', '');
600
  $product = intval($product);
601
  $product_qty = $this->input->post('qty', '');
@@ -605,11 +607,28 @@ class WDRAjax extends Base
605
  $product = self::$woocommerce_helper->getProduct($product);
606
  if($product){
607
  $price_html = "<div class='price'></div>";
608
- $price_html = $manage_discount->getPriceHtml($price_html, $product, $product_qty, true);
609
  $original_html = self::$woocommerce_helper->getPriceHtml($product);
610
  }
611
  }
612
 
613
  wp_send_json(array('price_html'=>$price_html, 'original_price_html' => $original_html));
614
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
  }
18
  class WDRAjax extends Base
19
  {
20
  public static $wdr_rules_table;
21
+ public static $manage_discount;
22
  public $search_result_limit = 20;
23
 
24
  /**
27
  public function __construct()
28
  {
29
  parent::__construct();
30
+ self::$manage_discount = (isset(self::$manage_discount) && !empty(self::$manage_discount)) ? self::$manage_discount : new ManageDiscount();
31
  self::$wdr_rules_table = (isset(self::$wdr_rules_table) && !empty(self::$wdr_rules_table)) ? self::$wdr_rules_table : WDR_PLUGIN_PREFIX.'rules';
32
  $this->search_result_limit = apply_filters('advanced_woo_discount_rules_select_search_limit', $this->search_result_limit);
33
  }
34
 
35
  protected function frontEndMethods(){
36
  return array(
37
+ 'get_price_html',
38
+ 'get_variable_product_bulk_table'
39
  );
40
  }
41
 
598
  */
599
  public function wdr_ajax_get_price_html()
600
  {
 
601
  $product = $this->input->post('product_id', '');
602
  $product = intval($product);
603
  $product_qty = $this->input->post('qty', '');
607
  $product = self::$woocommerce_helper->getProduct($product);
608
  if($product){
609
  $price_html = "<div class='price'></div>";
610
+ $price_html = self::$manage_discount->getPriceHtml($price_html, $product, $product_qty, true);
611
  $original_html = self::$woocommerce_helper->getPriceHtml($product);
612
  }
613
  }
614
 
615
  wp_send_json(array('price_html'=>$price_html, 'original_price_html' => $original_html));
616
  }
617
+
618
+ /**
619
+ * get variable product bulk table
620
+ */
621
+ public function wdr_ajax_get_variable_product_bulk_table(){
622
+ $product_id = $this->input->post('product_id', '');
623
+ Helper::validateRequest('awdr_ajax_front_end');
624
+ $product_id = intval($product_id);
625
+ if($product_id){
626
+ $product = self::$woocommerce_helper->getProduct($product_id);
627
+ $bulk_table = self::$manage_discount->showBulkTableInPositionManually($product, $get_variable_product_table = true);
628
+ wp_send_json(array('bulk_table' => $bulk_table));
629
+ }else{
630
+ wp_send_json_error();
631
+ }
632
+
633
+ }
634
  }
v2/App/Controllers/DiscountCalculator.php CHANGED
@@ -3,13 +3,14 @@
3
  namespace Wdr\App\Controllers;
4
 
5
  use Wdr\App\Helpers\Helper;
 
6
  use Wdr\App\Helpers\Woocommerce;
7
 
8
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
9
 
10
  class DiscountCalculator extends Base
11
  {
12
- public static $filtered_exclusive_rule = false, $rules, $applied_rules = array(), $total_discounts = array(), $cart_adjustments = array(), $price_discount_apply_as_cart_discount = array(), $tax_display_type = NULL;
13
  public $is_cart = false;
14
 
15
  /**
@@ -50,28 +51,14 @@ class DiscountCalculator extends Base
50
  /**
51
  * get default layout messages by rules to display discount table
52
  * @param $product
 
53
  * @return array
54
  */
55
- function getDefaultLayoutMessagesByRules($product)
56
  {
57
  $response_ranges = array();
58
  if ((!empty(self::$rules) && !empty($product))) {
59
  $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
60
- if ($calculate_discount_from == 'regular_price') {
61
- $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
62
- if (empty($product_price)) {
63
- $variable_product = self::$woocommerce_helper->productTypeIs($product, 'variable');
64
- if ($variable_product) {
65
- $product_price = self::$woocommerce_helper->getProductPrice($product);
66
- }
67
- }
68
- } else {
69
- $product_price = self::$woocommerce_helper->getProductPrice($product);
70
- }
71
- if(empty($product_price)){
72
- return array();
73
- }
74
-
75
  $language_helper_object = self::$language_helper;
76
  $discount_calculator = $this;
77
  foreach (self::$rules as $rule) {
@@ -90,17 +77,22 @@ class DiscountCalculator extends Base
90
  continue;
91
  }
92
  }
 
 
93
  $rule_id = $rule->getId();
94
  $has_bulk_discount = $rule->hasBulkDiscount();
 
 
 
 
 
 
95
  if ($has_bulk_discount) {
96
- if ($rule->isFilterPassed($product, true)) {
97
- $hasFilter = $rule->hasFilter();
98
- $filters = $rule->getFilter();
99
- $product_price = apply_filters('advanced_woo_discount_rules_bulk_table_product_price', $product_price, $product, $calculate_discount_from, $hasFilter, $filters);
100
  $bulk_adjustments = $rule->getBulkAdjustments();
101
  if (isset($bulk_adjustments) && !empty($bulk_adjustments) && isset($bulk_adjustments->ranges) && !empty($bulk_adjustments->ranges)) {
102
  foreach ($bulk_adjustments->ranges as $range) {
103
- if (isset($range->value) && !empty($range->value)) {
104
  $discount_type = (isset($range->type) && !empty($range->type)) ? $range->type : 0;
105
  $from = intval((isset($range->from) && !empty($range->from)) ? $range->from : 0);
106
  $to = intval((isset($range->to) && !empty($range->to)) ? $range->to : 0);
@@ -108,11 +100,22 @@ class DiscountCalculator extends Base
108
  continue;
109
  } else {
110
  $discount_price = $rule->calculator($discount_type, $product_price, $range->value);
 
 
 
111
  $discounted_price = $product_price - $discount_price;
112
  if ($discounted_price < 0) {
113
  $discounted_price = 0;
114
  }
115
- $discounted_price = $this->mayHaveTax($product, $discounted_price);
 
 
 
 
 
 
 
 
116
  $rule_title = isset($range->label) && !empty($range->label) ? $range->label : $rule->getTitle();
117
  $discount_value = $range->value;
118
  $discount_method = 'bulk';
@@ -133,6 +136,117 @@ class DiscountCalculator extends Base
133
  return $response_ranges;
134
  }
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  /**
137
  * @param $response_ranges
138
  * @param $from
@@ -161,6 +275,63 @@ class DiscountCalculator extends Base
161
  );
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  /**
165
  * get default layout messages by rules to display discount table
166
  * @param $product
@@ -564,6 +735,9 @@ class DiscountCalculator extends Base
564
  }
565
  }
566
  }
 
 
 
567
  if($apply_rule_to == "all"){
568
  $apply_discount_subsequently = self::$config->getConfig('apply_discount_subsequently', 0);
569
  }
@@ -671,6 +845,9 @@ class DiscountCalculator extends Base
671
  $process_discount = apply_filters('advanced_woo_discount_rules_process_discount_for_product_which_do_not_matched_filters', false, $product, $rule, $cart_item);
672
  if($process_discount){
673
  $discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart);
 
 
 
674
  }
675
  }
676
  if($discounted_price > 0){
@@ -682,9 +859,6 @@ class DiscountCalculator extends Base
682
  self::$total_discounts[$matched_item_key][$rule_id] = array();
683
  }
684
  self::$total_discounts[$matched_item_key][$rule_id] = apply_filters('advanced_woo_discount_rules_calculated_discounts_of_each_rule', self::$total_discounts[$matched_item_key][$rule_id], $product_id, $rule_id, $filter_passed, $cart_item, $is_cart, $rule);
685
- if ($rule->isExclusive()) {
686
- array_push($exclusive_rules, $rule_id);
687
- }
688
  $discounts[$rule_id] = $discounted_price;
689
  }
690
  }
@@ -709,10 +883,9 @@ class DiscountCalculator extends Base
709
  return false;
710
  }
711
  //If exclusive rules is not empty then apply only exclusive rule
712
-
713
  $rules = $this->pickRule($exclusive_rules, $discounts, $apply_rule_to);
714
  $discount_price = 0;
715
- $valid_discounts = array();
716
  if (isset($rules) && !empty($rules) && !empty($discounts)) {
717
  foreach ($rules as $rule_id) {
718
  if(isset(self::$total_discounts[$matched_item_key]) && isset(self::$total_discounts[$matched_item_key][$rule_id])){
@@ -727,7 +900,12 @@ class DiscountCalculator extends Base
727
  }else{
728
  if (isset(self::$rules[$rule_id]) && isset($discounts[$rule_id])) {
729
  if(!empty($discounts[$rule_id])){
730
- $discount_price += $discounts[$rule_id];
 
 
 
 
 
731
  }
732
  self::$applied_rules[$rule_id] = self::$rules[$rule_id];
733
  }
@@ -739,7 +917,8 @@ class DiscountCalculator extends Base
739
  self::$total_discounts[$matched_item_key] = $valid_discounts[$matched_item_key];
740
  }
741
  $product_price = floatval($product_price);
742
- $discounted_price = $product_price - $discount_price;
 
743
  if ($discounted_price < 0 ) {
744
  $discounted_price = 0;
745
  }
@@ -752,12 +931,131 @@ class DiscountCalculator extends Base
752
  'total_discount_details' => self::$total_discounts,
753
  'cart_discount_details' => $this->getCartDiscountPrices($cart, true),
754
  'apply_as_cart_rule' => $show_stike_out_depends_cart_rule,
 
755
  );
756
  return apply_filters('advanced_woo_discount_rules_discount_prices_of_product', $discount_prices, $product, $quantity, $cart_item);
757
  }
758
  return false;
759
  }
760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
  /**
762
  * Calculate tax for products
763
  * @param $product
3
  namespace Wdr\App\Controllers;
4
 
5
  use Wdr\App\Helpers\Helper;
6
+ use Wdr\App\Helpers\Rule;
7
  use Wdr\App\Helpers\Woocommerce;
8
 
9
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
 
11
  class DiscountCalculator extends Base
12
  {
13
+ public static $original_price_of_product = array(), $filtered_exclusive_rule = false, $rules, $applied_rules = array(), $total_discounts = array(), $cart_adjustments = array(), $price_discount_apply_as_cart_discount = array(), $tax_display_type = NULL;
14
  public $is_cart = false;
15
 
16
  /**
51
  /**
52
  * get default layout messages by rules to display discount table
53
  * @param $product
54
+ * @param $get_variable_product_table
55
  * @return array
56
  */
57
+ function getDefaultLayoutMessagesByRules($product, $get_variable_product_table = false)
58
  {
59
  $response_ranges = array();
60
  if ((!empty(self::$rules) && !empty($product))) {
61
  $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  $language_helper_object = self::$language_helper;
63
  $discount_calculator = $this;
64
  foreach (self::$rules as $rule) {
77
  continue;
78
  }
79
  }
80
+ $hasFilter = $rule->hasFilter();
81
+ $filters = $rule->getFilter();
82
  $rule_id = $rule->getId();
83
  $has_bulk_discount = $rule->hasBulkDiscount();
84
+ $get_variant_product = $this->getVariantProduct($product, $rule, $filters, $hasFilter);
85
+ $is_filter_passed = isset($get_variant_product['is_filter_passed'])? $get_variant_product['is_filter_passed'] : false;
86
+ $product = isset($get_variant_product['product'])? $get_variant_product['product'] : false;
87
+ $is_variable_product = isset($get_variant_product['is_variable_product'])? $get_variant_product['is_variable_product'] : false;
88
+ $product_price = $this->getProductPriceFromConfig($product, $calculate_discount_from, $is_variable_product);
89
+ $product_price = apply_filters('advanced_woo_discount_rules_bulk_table_product_price', $product_price, $product, $calculate_discount_from, $hasFilter, $filters);
90
  if ($has_bulk_discount) {
91
+ if ($is_filter_passed) {
 
 
 
92
  $bulk_adjustments = $rule->getBulkAdjustments();
93
  if (isset($bulk_adjustments) && !empty($bulk_adjustments) && isset($bulk_adjustments->ranges) && !empty($bulk_adjustments->ranges)) {
94
  foreach ($bulk_adjustments->ranges as $range) {
95
+ if (isset($range->value) && $range->value != '') {
96
  $discount_type = (isset($range->type) && !empty($range->type)) ? $range->type : 0;
97
  $from = intval((isset($range->from) && !empty($range->from)) ? $range->from : 0);
98
  $to = intval((isset($range->to) && !empty($range->to)) ? $range->to : 0);
100
  continue;
101
  } else {
102
  $discount_price = $rule->calculator($discount_type, $product_price, $range->value);
103
+ if( $calculate_discount_from != 'sale_price' && Woocommerce::productTypeIs($product, array('variable')) && $discount_type == 'flat'){
104
+ $discount_price = $this->mayHaveTax($product, $discount_price);
105
+ }
106
  $discounted_price = $product_price - $discount_price;
107
  if ($discounted_price < 0) {
108
  $discounted_price = 0;
109
  }
110
+
111
+ if($calculate_discount_from != 'sale_price' && Woocommerce::productTypeIs($product, array('variable'))) {
112
+ /*Process lowest regular price of variant*/
113
+ if($discount_type == 'fixed_price'){
114
+ $discounted_price = $this->mayHaveTax($product, $discounted_price);
115
+ }
116
+ }else{
117
+ $discounted_price = $this->mayHaveTax($product, $discounted_price);
118
+ }
119
  $rule_title = isset($range->label) && !empty($range->label) ? $range->label : $rule->getTitle();
120
  $discount_value = $range->value;
121
  $discount_method = 'bulk';
136
  return $response_ranges;
137
  }
138
 
139
+ /**
140
+ * get Product Price From Configuration
141
+ * @param $product
142
+ * @param $calculate_discount_from
143
+ * @param $is_variable_product
144
+ * @return bool
145
+ */
146
+ function getProductPriceFromConfig($product, $calculate_discount_from, $is_variable_product){
147
+ $product_price = 0;
148
+ if ($calculate_discount_from == 'regular_price') {
149
+ $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
150
+ if (empty($product_price) && $is_variable_product) {
151
+ $variant_regular_price = array();
152
+ $available_variations = Woocommerce::availableProductVariations($product);
153
+ foreach ($available_variations as $variant){
154
+ $variant_id = isset($variant['variation_id']) ? $variant['variation_id'] : 0;
155
+ $regular_price = isset($variant['display_regular_price']) ? $variant['display_regular_price'] : 0;
156
+ $variant_regular_price[$variant_id] = $regular_price;
157
+ }
158
+ $product_price = min($variant_regular_price);
159
+ }
160
+ if(empty($product_price)){
161
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
162
+ }
163
+ } else {
164
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
165
+ }
166
+ return $product_price;
167
+ }
168
+
169
+ /**
170
+ * get Variant Product
171
+ *
172
+ * @param $product
173
+ * @param $rule
174
+ * @param $filters
175
+ * @param $hasFilter
176
+ * @return array
177
+ */
178
+ function getVariantProduct($product, $rule, $filters, $hasFilter){
179
+ $is_variable_product = Woocommerce::productTypeIs($product, array('variable', 'variation', 'subscription_variation', 'variable-subscription'));
180
+ $is_filter_passed = $rule->isFilterPassed($product);
181
+ $available_variations = Woocommerce::availableProductVariations($product);
182
+ $rule_id = $rule->getId();
183
+
184
+ if($is_filter_passed && $is_variable_product){
185
+ foreach ($filters as $filter_val) {
186
+ $filter_type = isset($filter_val->type) ? $filter_val->type : '';
187
+ $filter_value = isset($filter_val->value) ? $filter_val->value : array();
188
+ $filter_method = isset($filter_val->method) ? $filter_val->method : '';
189
+ $term_id = $attribute_details = array();
190
+ if ($filter_type == 'product_attributes' && $is_variable_product) {
191
+ $parent_product_id = Woocommerce::getProductParentId($product);
192
+ if (empty($parent_product_id)) {
193
+ $variation_id = $this->haveDefaultVariant($product, $available_variations);
194
+ } else {
195
+ $parent_product = Woocommerce::getProduct($parent_product_id);
196
+ $variation_id = Woocommerce::getProductId($product);
197
+ $available_variations = Woocommerce::availableProductVariations($parent_product);
198
+ }
199
+ $attribute_details = $this->getProductAttributeDetails($available_variations);
200
+ if(isset($attribute_details[$variation_id])){
201
+ foreach ($attribute_details[$variation_id] as $key => $attribute_taxonomy){
202
+ $terms = get_terms( array(
203
+ 'taxonomy' => $attribute_taxonomy,
204
+ 'hide_empty' => false,
205
+ ) );
206
+ foreach ($terms as $term){
207
+ if($key == $term->slug){
208
+ $term_id[] = $term->term_id;
209
+ }
210
+ }
211
+ }
212
+ $term_id = array_unique($term_id);
213
+ if(count(array_intersect($filter_value, $term_id)) > 0){
214
+ $is_attribute_filter_passed = true;
215
+ }else{
216
+ $is_attribute_filter_passed = false;
217
+ }
218
+ }else{
219
+ $is_attribute_filter_passed = false;
220
+ }
221
+ }
222
+ }
223
+ }
224
+ if(!$is_filter_passed && $is_variable_product){
225
+ //$variation_ids = array();
226
+ $default_variation_id = 0;
227
+ $available_variations = Woocommerce::availableProductVariations($product);
228
+ /* Default variation id get by product variants */
229
+ $default_variation_id = $this->haveDefaultVariant($product, $available_variations);
230
+
231
+ if(!empty($default_variation_id)){
232
+ $product = Woocommerce::getProduct($default_variation_id);
233
+ if($rule->isFilterPassed($product)){
234
+ $is_filter_passed = true;
235
+ }
236
+ $is_filter_passed = apply_filters('advanced_woo_discount_rules_current_product_default_variation', $is_filter_passed, $rule_id, $rule);
237
+ }
238
+ }
239
+ if(isset($is_attribute_filter_passed) && !$is_attribute_filter_passed){
240
+ $is_filter_passed = false;
241
+ }
242
+ $is_filter_passed = apply_filters('advanced_woo_discount_rules_enable_bulk_table_for_products', $is_filter_passed, $rule_id, $rule, $product);
243
+ return array(
244
+ 'is_filter_passed' => $is_filter_passed,
245
+ 'is_variable_product' => $is_variable_product,
246
+ 'product' => $product,
247
+ );
248
+ }
249
+
250
  /**
251
  * @param $response_ranges
252
  * @param $from
275
  );
276
  }
277
 
278
+ /**
279
+ * Get default variant id
280
+ * @param $product
281
+ * @param $available_variations
282
+ * @return int
283
+ */
284
+ function haveDefaultVariant($product, $available_variations){
285
+ $default_variation_id = 0;
286
+ if(!empty($available_variations)) {
287
+ foreach($available_variations as $variation_values ){
288
+ $is_default_variation_passed = array();
289
+ if(isset($variation_values['attributes']) && !empty($variation_values['attributes'])){
290
+ $variation_attributes = $variation_values['attributes'];
291
+ foreach($variation_attributes as $key => $attribute_value ){
292
+ $attribute_name = str_replace( 'attribute_', '', $key );
293
+ $default_value = Woocommerce::getProductVariationDefaultAttribute($product,$attribute_name);
294
+ if(!empty($default_value)){
295
+ if( $default_value == $attribute_value ){
296
+ $is_default_variation_passed[] = 1;
297
+ } else {
298
+ $is_default_variation_passed[] = 2;
299
+ }
300
+ }
301
+ }
302
+ $is_default_variation_passed = array_unique($is_default_variation_passed);
303
+ }
304
+
305
+ if( !empty($is_default_variation_passed) && isset($is_default_variation_passed[0]) && count($is_default_variation_passed) == 1 && $is_default_variation_passed[0] == 1){
306
+ $default_variation_id = isset($variation_values['variation_id']) ? $variation_values['variation_id'] : 0;
307
+ break;
308
+ }
309
+ }
310
+ }
311
+ return $default_variation_id;
312
+ }
313
+
314
+ /**
315
+ * get product attributes details for variant products
316
+ * @param $available_variations
317
+ * @return array
318
+ */
319
+ function getProductAttributeDetails($available_variations){
320
+ $attribute_details = array();
321
+ if(!empty($available_variations)){
322
+ foreach($available_variations as $variation_values ){
323
+ if(isset($variation_values['attributes']) && !empty($variation_values['attributes'])){
324
+ $variation_attributes = $variation_values['attributes'];
325
+ $variation_id = isset($variation_values['variation_id']) ? $variation_values['variation_id'] : 0;
326
+ foreach($variation_attributes as $key => $attribute_value ){
327
+ $attribute_details[$variation_id][$attribute_value] = str_replace( 'attribute_', '', $key );
328
+ }
329
+ }
330
+ }
331
+ }
332
+ return $attribute_details;
333
+ }
334
+
335
  /**
336
  * get default layout messages by rules to display discount table
337
  * @param $product
735
  }
736
  }
737
  }
738
+ if ($discounted_price > 0 && $rule->isExclusive()) {
739
+ array_push($exclusive_rules, $rule_id);
740
+ }
741
  if($apply_rule_to == "all"){
742
  $apply_discount_subsequently = self::$config->getConfig('apply_discount_subsequently', 0);
743
  }
845
  $process_discount = apply_filters('advanced_woo_discount_rules_process_discount_for_product_which_do_not_matched_filters', false, $product, $rule, $cart_item);
846
  if($process_discount){
847
  $discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart);
848
+ if ($discounted_price > 0 && $rule->isExclusive()) {
849
+ array_push($exclusive_rules, $rule_id);
850
+ }
851
  }
852
  }
853
  if($discounted_price > 0){
859
  self::$total_discounts[$matched_item_key][$rule_id] = array();
860
  }
861
  self::$total_discounts[$matched_item_key][$rule_id] = apply_filters('advanced_woo_discount_rules_calculated_discounts_of_each_rule', self::$total_discounts[$matched_item_key][$rule_id], $product_id, $rule_id, $filter_passed, $cart_item, $is_cart, $rule);
 
 
 
862
  $discounts[$rule_id] = $discounted_price;
863
  }
864
  }
883
  return false;
884
  }
885
  //If exclusive rules is not empty then apply only exclusive rule
 
886
  $rules = $this->pickRule($exclusive_rules, $discounts, $apply_rule_to);
887
  $discount_price = 0;
888
+ $price_discounts = $valid_discounts = array();
889
  if (isset($rules) && !empty($rules) && !empty($discounts)) {
890
  foreach ($rules as $rule_id) {
891
  if(isset(self::$total_discounts[$matched_item_key]) && isset(self::$total_discounts[$matched_item_key][$rule_id])){
900
  }else{
901
  if (isset(self::$rules[$rule_id]) && isset($discounts[$rule_id])) {
902
  if(!empty($discounts[$rule_id])){
903
+ //$discount_price += $discounts[$rule_id];
904
+ $matched_price_discounts = $this->getDiscountForMatchedItemAndRule(self::$total_discounts[$matched_item_key][$rule_id]);
905
+ if(!empty($matched_price_discounts)){
906
+ $price_discounts = array_merge($price_discounts, $matched_price_discounts);
907
+ }
908
+
909
  }
910
  self::$applied_rules[$rule_id] = self::$rules[$rule_id];
911
  }
917
  self::$total_discounts[$matched_item_key] = $valid_discounts[$matched_item_key];
918
  }
919
  $product_price = floatval($product_price);
920
+ $discount_values = $this->calculateDiscountFromMatchedRule($product_price, $matched_item_key, $quantity, $price_discounts);
921
+ $discounted_price = $product_price - $discount_values['discount_price'];
922
  if ($discounted_price < 0 ) {
923
  $discounted_price = 0;
924
  }
931
  'total_discount_details' => self::$total_discounts,
932
  'cart_discount_details' => $this->getCartDiscountPrices($cart, true),
933
  'apply_as_cart_rule' => $show_stike_out_depends_cart_rule,
934
+ 'discount_lines' => $discount_values['discount_lines'],
935
  );
936
  return apply_filters('advanced_woo_discount_rules_discount_prices_of_product', $discount_prices, $product, $quantity, $cart_item);
937
  }
938
  return false;
939
  }
940
 
941
+ /**
942
+ * Merge additional discounts
943
+ * @param $price_discounts array
944
+ * @return array
945
+ * */
946
+ protected function mergeAdditionalDiscounts($price_discounts){
947
+ $price_discounts_new = array();
948
+ foreach ($price_discounts as $price_discount){
949
+ $price_discounts_new[] = $price_discount;
950
+ if(isset($price_discount['additional_discounts']) && !empty($price_discount['additional_discounts'])){
951
+ $price_discounts_new = array_merge($price_discounts_new, $price_discount['additional_discounts']);
952
+ }
953
+ }
954
+
955
+ return $price_discounts_new;
956
+ }
957
+
958
+ /**
959
+ * Calculate discount from matched rule
960
+ *
961
+ * @param $product_price int/float
962
+ * @param $matched_item_key string
963
+ * @param $quantity int
964
+ * @param $price_discounts int/float
965
+ * @return array
966
+ * */
967
+ protected function calculateDiscountFromMatchedRule($product_price, $matched_item_key, $quantity, $price_discounts){
968
+ if(isset(self::$original_price_of_product[$matched_item_key])){
969
+ $product_price = self::$original_price_of_product[$matched_item_key];
970
+ } else {
971
+ self::$original_price_of_product[$matched_item_key] = $product_price;
972
+ }
973
+ $rule = new Rule();
974
+ $apply_rule_to = self::$config->getConfig('apply_product_discount_to', 'biggest_discount');
975
+ $apply_subsequently = false;
976
+ if($apply_rule_to == "all"){
977
+ $apply_discount_subsequently = self::$config->getConfig('apply_discount_subsequently', 0);
978
+ if($apply_discount_subsequently) $apply_subsequently = true;
979
+ }
980
+ $discount_price = 0;
981
+ $discount_lines = array();
982
+ $discount_lines['non_applied'] = array('quantity' => $quantity, 'discount' => 0, 'price' => $product_price);
983
+ $price_discounts = $this->mergeAdditionalDiscounts($price_discounts);
984
+ foreach ($price_discounts as $price_discount){
985
+ // $discount_price = $discount_price+($price_discount['discount_price']);
986
+ $remaining_qty = $discount_qty = $price_discount['discount_quantity'];
987
+ $available_qty = $discount_lines['non_applied']['quantity'];
988
+ $applied_qty = 0;
989
+ if($available_qty > 0 && $discount_qty <= $available_qty){
990
+ $current_product_price = $discount_lines['non_applied']['price'];
991
+ $available_qty = $discount_lines['non_applied']['quantity'];
992
+ $discount_lines['non_applied']['quantity'] = $available_qty - $discount_qty;
993
+ $current_discount_amount = $rule->calculator($price_discount['discount_type'], $current_product_price, $price_discount['discount_value']);
994
+ if($apply_subsequently === true) $current_product_price = $current_product_price - $current_discount_amount;
995
+ $remaining_qty -= $discount_qty;
996
+ $applied_qty += $discount_qty;
997
+ $discount_lines[] = array('quantity' => $discount_qty, 'discount' => $current_discount_amount, 'original_price' => $product_price, 'discounted_price' => ($product_price-$current_discount_amount));
998
+ } else {
999
+ if(!empty($discount_lines)){
1000
+ foreach ($discount_lines as $key_f => $discount_line){
1001
+ if($key_f !== 'non_applied'){
1002
+ if($apply_subsequently === true){
1003
+ $current_product_price = $discount_lines['non_applied']['price'] - $discount_lines[$key_f]['discount'];
1004
+ } else {
1005
+ $current_product_price = $discount_lines['non_applied']['price'];
1006
+ }
1007
+ $available_qty = $discount_lines[$key_f]['quantity'];
1008
+ if($available_qty > $discount_qty){
1009
+ $new_row = $discount_lines[$key_f];
1010
+ $new_row['quantity'] = $available_qty-$discount_qty;
1011
+ $available_qty = $discount_lines[$key_f]['quantity'] = $discount_qty;
1012
+ $discount_lines[] = $new_row;
1013
+ }
1014
+
1015
+ $remaining_qty -= $available_qty;
1016
+ $applied_qty += $available_qty;
1017
+ $discount_lines['non_applied']['quantity'] = $available_qty - $discount_qty;
1018
+ $current_discount_amount = $rule->calculator($price_discount['discount_type'], $current_product_price, $price_discount['discount_value']);
1019
+ $discount_lines[$key_f]['discount'] = $discount_lines[$key_f]['discount']+$current_discount_amount;
1020
+ $discount_lines[$key_f]['discounted_price'] = $product_price - $discount_lines[$key_f]['discount'];
1021
+ }
1022
+ }
1023
+ if($remaining_qty > 0){
1024
+ $available_qty = $quantity-$applied_qty;
1025
+ if($remaining_qty <= $available_qty){
1026
+ $current_product_price = $discount_lines['non_applied']['price'];
1027
+ $discount_lines['non_applied']['quantity'] = $available_qty - $remaining_qty;
1028
+ $current_discount_amount = $rule->calculator($price_discount['discount_type'], $current_product_price, $price_discount['discount_value']);
1029
+ if($apply_subsequently === true) $current_product_price = $current_product_price - $current_discount_amount;
1030
+ $discount_lines[] = array('quantity' => $remaining_qty, 'discount' => $current_discount_amount, 'original_price' => $product_price, 'discounted_price' => ($product_price-$current_discount_amount));
1031
+ $remaining_qty -= $remaining_qty;
1032
+ $applied_qty += $remaining_qty;
1033
+ }
1034
+ }
1035
+ }
1036
+ }
1037
+ }
1038
+ $discount_amount = 0;
1039
+ foreach ($discount_lines as $discount_line){
1040
+ $discount_amount += $discount_line['discount']*$discount_line['quantity'];
1041
+ }
1042
+ $discount_price = $discount_amount/$quantity;
1043
+
1044
+ return array('discount_price' => $discount_price, 'discount_lines' => $discount_lines);
1045
+ }
1046
+
1047
+ protected function getDiscountForMatchedItemAndRule($matched_discounts){
1048
+ $matched_items = array();
1049
+ foreach ($matched_discounts as $key => $matched_discount){
1050
+ if(isset($matched_discount['discount_price']) && $matched_discount['discount_price'] > 0){
1051
+ $matched_discount['discount_rule_type'] = $key;
1052
+ $matched_items[] = $matched_discount;
1053
+ }
1054
+ }
1055
+
1056
+ return $matched_items;
1057
+ }
1058
+
1059
  /**
1060
  * Calculate tax for products
1061
  * @param $product
v2/App/Controllers/ManageDiscount.php CHANGED
@@ -43,16 +43,21 @@ class ManageDiscount extends Base
43
  */
44
  function loadAssets()
45
  {
 
46
  $ajax_update_price = self::$config->getConfig('show_strikeout_when', 'show_when_matched');
47
  wp_enqueue_style(WDR_SLUG . '-customize-table-ui-css', WDR_PLUGIN_URL . 'Assets/Css/customize-table.css', array(), WDR_VERSION);
48
  wp_enqueue_script('awdr-main', WDR_PLUGIN_URL . 'Assets/Js/site_main.js', array('jquery'), WDR_VERSION);
49
  $awdr_front_end_script = array(
50
  'ajaxurl' => admin_url('admin-ajax.php'),
 
51
  'enable_update_price_with_qty' => $ajax_update_price,
52
  'refresh_order_review' => self::$config->getConfig('refresh_order_review', 0),
53
  'custom_target_simple_product' => apply_filters('advanced_woo_discount_rules_custom_target_for_simple_product_on_qty_update', ""),
54
  'custom_target_variable_product' => apply_filters('advanced_woo_discount_rules_custom_target_for_variable_product_on_qty_update', ""),
55
  'js_init_trigger' => apply_filters('advanced_woo_discount_rules_update_discount_price_init_trigger', ""),
 
 
 
56
  );
57
  wp_enqueue_script('awdr-dynamic-price', WDR_PLUGIN_URL . 'Assets/Js/awdr-dynamic-price.js', array('jquery'), WDR_VERSION);
58
  wp_localize_script('awdr-main', 'awdr_params', $awdr_front_end_script);
@@ -247,7 +252,6 @@ class ManageDiscount extends Base
247
  //Calculate the product price
248
  $prices = self::calculateInitialAndDiscountedPrice($product, $quantity, $is_cart = false, $ajax_price);
249
  $apply_as_cart_rule = isset($prices['apply_as_cart_rule']) ? $prices['apply_as_cart_rule'] : array('no');
250
- //echo "<pre>"; print_r($apply_as_cart_rule); echo "</pre>";
251
  if(!in_array('no', $apply_as_cart_rule)){
252
  return $price_html;
253
  }
@@ -263,7 +267,7 @@ class ManageDiscount extends Base
263
  }
264
  return $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product, $price_html = true, $quantity, $ajax_price);
265
  }else{
266
- return false;
267
  }
268
  }else {
269
  if (!$prices) {
@@ -399,6 +403,10 @@ class ManageDiscount extends Base
399
  return $price_html;
400
  }
401
 
 
 
 
 
402
  if (is_product() && empty(self::$config->getConfig('modify_price_at_product_page', 1))) {
403
  return $price_html;
404
  }
@@ -661,7 +669,7 @@ class ManageDiscount extends Base
661
  if ($discount_value > 0) {
662
  if (empty($combine_all_discounts)) {
663
  $discount_value = -1 * $discount_value;
664
- Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $discount_value, $cart));
665
  }else{
666
  $total_combined_discounts += $discount_value;
667
  }
@@ -674,7 +682,7 @@ class ManageDiscount extends Base
674
  if(empty($combine_all_discounts)){
675
  $discount_value = -1 * $discount['value'];
676
  $label = $discount['label'];
677
- Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $discount_value, $cart));
678
  }else{
679
  $total_combined_discounts += $discount['value'];
680
  }
@@ -687,7 +695,7 @@ class ManageDiscount extends Base
687
  $label = Helper::getCleanHtml($label);
688
  if ($discount_apply_type == 'fee') {
689
  $total_combined_discounts = -1 * $total_combined_discounts;
690
- self::$woocommerce_helper->addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $total_combined_discounts, $cart));
691
  }
692
  }
693
  DiscountCalculator::$price_discount_apply_as_cart_discount = array();
@@ -751,33 +759,36 @@ class ManageDiscount extends Base
751
  */
752
  function checkCouponToApply($response, $coupon_code)
753
  {
754
- $rule_helper = new Rule();
755
- $available_coupons = $rule_helper->getAllDynamicCoupons();
756
- if (in_array($coupon_code, $available_coupons)) {
757
- $amount = 0;
758
- $coupon = array(
759
- 'id' => time() . rand(2, 9),
760
- 'amount' => $amount,
761
- 'individual_use' => false,
762
- 'product_ids' => array(),
763
- 'exclude_product_ids' => array(),
764
- 'usage_limit' => '',
765
- 'usage_limit_per_user' => '',
766
- 'limit_usage_to_x_items' => '',
767
- 'usage_count' => '',
768
- 'expiry_date' => '',
769
- 'apply_before_tax' => 'yes',
770
- 'free_shipping' => false,
771
- 'product_categories' => array(),
772
- 'exclude_product_categories' => array(),
773
- 'exclude_sale_items' => false,
774
- 'minimum_amount' => '',
775
- 'maximum_amount' => '',
776
- 'customer_email' => '',
777
- 'discount_type' => 'percent'
778
- );
779
- return $coupon;
 
 
780
  }
 
781
  return $response;
782
  }
783
 
@@ -830,11 +841,11 @@ class ManageDiscount extends Base
830
  $combine_all_discounts = self::$config->getConfig('combine_all_cart_discounts', 0);
831
  $total_combined_discounts = 0;
832
  $combined_discounts_cart_items = array();
833
- DiscountCalculator::$price_discount_apply_as_cart_discount = array();
834
  if(function_exists('WC')){
835
  $this->applyCartProductDiscount(WC()->cart);
836
  }
837
  $apply_as_cart_fee_details = DiscountCalculator::$price_discount_apply_as_cart_discount;
 
838
  $apply_as_cart_fee_details = self::removeDuplicateValues($apply_as_cart_fee_details);
839
  $flat_in_subtotal = array();
840
  if(!empty($apply_as_cart_fee_details)){
@@ -885,6 +896,9 @@ class ManageDiscount extends Base
885
  if (!empty($total_combined_discounts) && !empty($combine_all_discounts)) {
886
  $label = self::$config->getConfig('discount_label_for_combined_discounts', __('Cart discount', WDR_TEXT_DOMAIN));
887
  $label = Helper::getCleanHtml($label);
 
 
 
888
  self::setCartCouponValues($label, $discount_value, $combined_discounts_cart_items);
889
  $this->applyFakeCouponsForCartRules($label);
890
  }
@@ -963,70 +977,72 @@ class ManageDiscount extends Base
963
  */
964
  function validateVirtualCouponForCartRules($response, $coupon_data)
965
  {
966
- $discount_apply_type = self::$config->getConfig('apply_cart_discount_as', 'fee');
967
- if($discount_apply_type == "coupon"){
968
- if(empty(self::$apply_as_coupon_values)){
969
- remove_filter('woocommerce_get_shop_coupon_data', array($this, 'validateVirtualCouponForCartRules'), 10);
970
- $this->applyVirtualCouponForCartRules();
971
- add_filter('woocommerce_get_shop_coupon_data', array($this, 'validateVirtualCouponForCartRules'), 10, 2);
972
- }
973
-
974
- if(!empty(self::$apply_as_coupon_values)){
975
- if(array_key_exists($coupon_data, self::$apply_as_coupon_values)){
976
- $coupon_code = $coupon_data;
977
- $amount = self::$apply_as_coupon_values[$coupon_code]['value'];
978
- $cart_item_keys = self::$apply_as_coupon_values[$coupon_code]['cart_item_keys'];
979
- $product_ids = self::getProductIdsFromCartKey($cart_item_keys);
980
- $discount_in_percentage = self::getPercentageFromCartKey($product_ids, $amount);
 
 
 
 
981
  } else {
 
982
  return $response;
983
  }
984
- } else {
985
- add_filter('woocommerce_coupon_error', '\Wdr\App\Helpers\Helper::removeErrorMessageForOurCoupons', 10, 3);
986
- return $response;
987
- }
988
 
989
- // Getting Coupon Remove status from Session.
990
- if(isset(WC()->session) && is_object(WC()->session) && method_exists(WC()->session, 'get')) {
991
- $is_removed = WC()->session->get('woo_coupon_removed', '');
992
- // If Both are same, then it won't added.
993
- if(!empty($is_removed)){
994
- if ($coupon_code == $is_removed) return $response;
 
995
  }
996
- }
997
 
998
- if ($coupon_data == $coupon_code || wc_strtolower($coupon_data) == wc_strtolower($coupon_code)) {
999
 
1000
- //if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
1001
- if(empty($product_ids)){
1002
- $discount_type = 'fixed_cart';
1003
- } else {
1004
- $discount_type = 'percent';
1005
- $amount = $discount_in_percentage;
1006
- }
1007
 
1008
- $coupon = array(
1009
- 'id' => time().rand(2, 9),
1010
- 'amount' => $amount,
1011
- 'individual_use' => false,
1012
- 'product_ids' => $product_ids,
1013
- 'exclude_product_ids' => array(),
1014
- 'usage_limit' => '',
1015
- 'usage_limit_per_user' => '',
1016
- 'limit_usage_to_x_items' => '',
1017
- 'usage_count' => '',
1018
- 'expiry_date' => '',
1019
- 'apply_before_tax' => 'yes',
1020
- 'free_shipping' => false,
1021
- 'product_categories' => array(),
1022
- 'exclude_product_categories' => array(),
1023
- 'exclude_sale_items' => false,
1024
- 'minimum_amount' => '',
1025
- 'maximum_amount' => '',
1026
- 'customer_email' => '',
1027
- );
1028
- $coupon['discount_type'] = $discount_type;
1029
- return $coupon;
 
1030
  }
1031
  }
1032
 
@@ -1193,17 +1209,7 @@ class ManageDiscount extends Base
1193
  $discounted_price = self::$calculated_cart_item_discount[$key]['discounted_price'];
1194
  $calculator = self::$calculator;
1195
  $total_discounts = $calculator::$total_discounts;
1196
- //get discount details per product
1197
- $discount_details = (isset($total_discounts[$key])) ? $total_discounts[$key] : array();
1198
- $item_price = $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product_obj, $price_html = false, $item_quantity);
1199
- if ($item_price !== false) {
1200
- $price = $item_price;
1201
- $saved_amount = (($initial_price-$item_price)*$item_quantity);
1202
- self::$calculated_cart_item_discount[$key]['saved_amount'] = $saved_amount;
1203
- self::$calculated_cart_item_discount[$key]['saved_amount_with_tax'] = $calculator->mayHaveTax($product_obj, $saved_amount);
1204
- } else {
1205
- $price = self::$calculated_cart_item_discount[$key]['discounted_price'];
1206
- }
1207
  $price = apply_filters('advanced_woo_discount_rules_discounted_price_of_cart_item', $price, $cart_item, $cart_object, self::$calculated_cart_item_discount[$key]);
1208
  $do_apply_price_rules = apply_filters('advanced_woo_discount_rules_do_apply_price_discount', true, $price, $cart_item, $cart_object, self::$calculated_cart_item_discount[$key]);
1209
  if($do_apply_price_rules){
@@ -1277,16 +1283,26 @@ class ManageDiscount extends Base
1277
 
1278
  /**
1279
  * laod the bulk table discount message manually
 
 
 
1280
  */
1281
- function showBulkTableInPositionManually($product)
1282
  {
1283
  if (!empty($product)) {
1284
- $bulk_discounts_ranges = self::$calculator->getDefaultLayoutMessagesByRules($product);
 
 
 
 
1285
  $override_path = get_theme_file_path('advanced_woo_discount_rules/discount_table.php');
1286
  $bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
1287
  if (file_exists($override_path)) {
1288
  $bulk_table_template_path = $override_path;
1289
  }
 
 
 
1290
  self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper, 'base' => $this))->display();
1291
  }
1292
  }
@@ -1369,9 +1385,17 @@ class ManageDiscount extends Base
1369
  $cart_shipping = (isset($cart_discount_details[$rule_id]['cart_shipping']) && !empty($cart_discount_details[$rule_id]['cart_shipping'])) ? $cart_discount_details[$rule_id]['cart_shipping'] : 'no';
1370
  $cart_discount_label = isset($cart_discount_details[$rule_id]['cart_discount_label']) ? $cart_discount_details[$rule_id]['cart_discount_label'] : '';
1371
  $simple_discount = isset($value['simple_discount']) ? $value['simple_discount'] : 0;
1372
- $simple_discount = $simple_discount * $cart_quantity;
 
 
 
 
1373
  $bulk_discount = isset($value['bulk_discount']) ? $value['bulk_discount'] : 0;
1374
- $bulk_discount = $bulk_discount * $cart_quantity;
 
 
 
 
1375
  $set_discount = isset($value['set_discount']['discount_value']) ? $value['set_discount']['discount_value'] : 0;
1376
  $set_discounted_price_quantity = isset($value['set_discount']['discounted_price_quantity']) ? $value['set_discount']['discounted_price_quantity'] : 0;
1377
  if(!empty($set_discounted_price_quantity)){
@@ -1585,43 +1609,59 @@ class ManageDiscount extends Base
1585
  * @param $cart_item_key
1586
  * @return mixed|void
1587
  */
1588
- function getCartProductPriceHtml($item_price, $cart_item, $cart_item_key)
1589
- {
1590
- $original_price_html = $item_price;
1591
- if (isset(self::$calculated_cart_item_discount[$cart_item_key])) {
1592
- $discounted_price = self::$calculated_cart_item_discount[$cart_item_key]['discounted_price'];
1593
- //$discounted_price = self::$calculator->mayHaveTax($product_obj, $discounted_price);
1594
-
1595
- $show_strikeout_on_cart = self::$config->getConfig('show_strikeout_on_cart', 1);
1596
- if (!empty($show_strikeout_on_cart)) {
1597
- $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
1598
- $cart_item_qty = isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
1599
- $product_id = self::$woocommerce_helper->getProductId($product_obj);
1600
- //product price
1601
  $initial_price = self::$calculated_cart_item_discount[$cart_item_key]['initial_price'];
1602
- // $initial_price = self::$calculator->mayHaveTax($product_obj, $initial_price);
1603
- $calculator = self::$calculator;
1604
- $total_discounts = $calculator::$total_discounts;
1605
- //get discount details per product
1606
- $discount_details = (isset($total_discounts[$cart_item_key])) ? $total_discounts[$cart_item_key] : array();
1607
- $price = $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product_obj, $price_html = true, $cart_item_qty);
1608
- if ($price) {
1609
- $item_price = $price;
1610
- } else {
1611
  $initial_price_with_tax_call = $discounted_price_with_tax_call = 0;
1612
  if(!empty($initial_price)){
1613
  $initial_price_with_tax_call = $calculator->mayHaveTax($product_obj, $initial_price);
1614
  }
1615
- if(!empty($discounted_price)){
1616
- $discounted_price_with_tax_call = $calculator->mayHaveTax($product_obj, $discounted_price);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1617
  }
1618
- $item_price = $this->getStrikeoutPrice($initial_price_with_tax_call, $discounted_price_with_tax_call);
1619
  }
1620
- } else {
1621
- $item_price = self::$woocommerce_helper->formatPrice($discounted_price);
 
1622
  }
1623
  }
1624
- return apply_filters('advanced_woo_discount_rules_cart_strikeout_price_html', $item_price, $original_price_html, $cart_item, $cart_item_key);
 
1625
  }
1626
 
1627
  /**
@@ -1668,13 +1708,32 @@ class ManageDiscount extends Base
1668
  */
1669
  function getDiscountPerItem($discount_details)
1670
  {
1671
- if(isset($discount_details['saved_amount_with_tax'])){
1672
- if ($discount_details['saved_amount_with_tax'] > 0) {
1673
- return $discount_details['saved_amount_with_tax'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1674
  }
1675
  }
1676
- $discounted_price = isset($discount_details['discounted_price_with_tax']) ? $discount_details['discounted_price_with_tax'] : 0;
1677
- $initial_price = isset($discount_details['initial_price_with_tax']) ? $discount_details['initial_price_with_tax'] : 0;
1678
  $cart_quantity = isset($discount_details['cart_quantity']) ? $discount_details['cart_quantity'] : 0;
1679
  $total_discount_per_quantity = $initial_price - $discounted_price;
1680
  if ($discounted_price >= 0 && $total_discount_per_quantity > 0) {
@@ -1738,6 +1797,15 @@ class ManageDiscount extends Base
1738
  }
1739
  }
1740
  }
 
 
 
 
 
 
 
 
 
1741
  self::$woocommerce_helper->setOrderItemMeta($item, '_advanced_woo_discount_item_total_discount', $meta_discount_details);
1742
  }
1743
  }
@@ -1868,9 +1936,18 @@ class ManageDiscount extends Base
1868
  }
1869
 
1870
  //simple discounted price
1871
- $simple_discount = isset($detail['simple_discount']) ? $detail['simple_discount'] : 0;
 
 
 
 
1872
  //bulk discounted price
1873
- $bulk_discounts = isset($detail['bulk_discount']) ? $detail['bulk_discount'] : 0;
 
 
 
 
 
1874
 
1875
  //set discounted price quantity
1876
  $total_discount_price += $discounted_price_per_set + $simple_discount + $bulk_discounts + $bogo_cheapest_discount;
@@ -2063,7 +2140,7 @@ class ManageDiscount extends Base
2063
  function removeOnSaleFlashEvent(){
2064
  $allowed_hooks = array(
2065
  //Filters
2066
- "woocommerce_sale_flash" => array( "Wdr\App\Controllers\ManageDiscount|replaceSaleTagText" ),
2067
  );
2068
 
2069
  $this->removeOtherEvents($allowed_hooks);
@@ -2081,7 +2158,7 @@ class ManageDiscount extends Base
2081
  "woocommerce_product_get_sale_price" => array(),
2082
  "woocommerce_product_get_regular_price" => array(),
2083
  "woocommerce_variable_price_html" => array("Wdr\App\Controllers\ManageDiscount|getVariablePriceHtml"),
2084
- "woocommerce_cart_item_price" => array("Wdr\App\Controllers\ManageDiscount|getCartProductPriceHtml"),
2085
  "woocommerce_cart_item_subtotal" => array("Wdr\App\Controllers\ManageDiscount|getCartProductSubtotalPriceHtml"),
2086
  //Actions
2087
  "woocommerce_checkout_order_processed" => array(),
@@ -2368,4 +2445,22 @@ class ManageDiscount extends Base
2368
  }
2369
  echo $save_text;
2370
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2371
  }
43
  */
44
  function loadAssets()
45
  {
46
+ $bulk_table_on_off = self::$config->getConfig('show_bulk_table', 0);
47
  $ajax_update_price = self::$config->getConfig('show_strikeout_when', 'show_when_matched');
48
  wp_enqueue_style(WDR_SLUG . '-customize-table-ui-css', WDR_PLUGIN_URL . 'Assets/Css/customize-table.css', array(), WDR_VERSION);
49
  wp_enqueue_script('awdr-main', WDR_PLUGIN_URL . 'Assets/Js/site_main.js', array('jquery'), WDR_VERSION);
50
  $awdr_front_end_script = array(
51
  'ajaxurl' => admin_url('admin-ajax.php'),
52
+ 'nonce' => Helper::create_nonce('awdr_ajax_front_end'),
53
  'enable_update_price_with_qty' => $ajax_update_price,
54
  'refresh_order_review' => self::$config->getConfig('refresh_order_review', 0),
55
  'custom_target_simple_product' => apply_filters('advanced_woo_discount_rules_custom_target_for_simple_product_on_qty_update', ""),
56
  'custom_target_variable_product' => apply_filters('advanced_woo_discount_rules_custom_target_for_variable_product_on_qty_update', ""),
57
  'js_init_trigger' => apply_filters('advanced_woo_discount_rules_update_discount_price_init_trigger', ""),
58
+ 'awdr_opacity_to_bulk_table' => apply_filters('advanced_woo_discount_rules_opacity_to_bulk_table', ""),
59
+ 'awdr_dynamic_bulk_table_status' => $bulk_table_on_off,
60
+ 'awdr_dynamic_bulk_table_off' => apply_filters('advanced_woo_discount_rules_disable_load_dynamic_bulk_table', "on"),
61
  );
62
  wp_enqueue_script('awdr-dynamic-price', WDR_PLUGIN_URL . 'Assets/Js/awdr-dynamic-price.js', array('jquery'), WDR_VERSION);
63
  wp_localize_script('awdr-main', 'awdr_params', $awdr_front_end_script);
252
  //Calculate the product price
253
  $prices = self::calculateInitialAndDiscountedPrice($product, $quantity, $is_cart = false, $ajax_price);
254
  $apply_as_cart_rule = isset($prices['apply_as_cart_rule']) ? $prices['apply_as_cart_rule'] : array('no');
 
255
  if(!in_array('no', $apply_as_cart_rule)){
256
  return $price_html;
257
  }
267
  }
268
  return $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product, $price_html = true, $quantity, $ajax_price);
269
  }else{
270
+ return $price_html;
271
  }
272
  }else {
273
  if (!$prices) {
403
  return $price_html;
404
  }
405
 
406
+ if(empty(self::$config->getConfig('modify_price_at_product_page', 1)) && empty(self::$config->getConfig('modify_price_at_shop_page', 1)) && empty(self::$config->getConfig('modify_price_at_category_page', 1))){
407
+ return $price_html;
408
+ }
409
+
410
  if (is_product() && empty(self::$config->getConfig('modify_price_at_product_page', 1))) {
411
  return $price_html;
412
  }
669
  if ($discount_value > 0) {
670
  if (empty($combine_all_discounts)) {
671
  $discount_value = -1 * $discount_value;
672
+ Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_amount', $discount_value, $cart));
673
  }else{
674
  $total_combined_discounts += $discount_value;
675
  }
682
  if(empty($combine_all_discounts)){
683
  $discount_value = -1 * $discount['value'];
684
  $label = $discount['label'];
685
+ Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_amount', $discount_value, $cart));
686
  }else{
687
  $total_combined_discounts += $discount['value'];
688
  }
695
  $label = Helper::getCleanHtml($label);
696
  if ($discount_apply_type == 'fee') {
697
  $total_combined_discounts = -1 * $total_combined_discounts;
698
+ self::$woocommerce_helper->addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_amount', $total_combined_discounts, $cart));
699
  }
700
  }
701
  DiscountCalculator::$price_discount_apply_as_cart_discount = array();
759
  */
760
  function checkCouponToApply($response, $coupon_code)
761
  {
762
+ if($coupon_code !== false && $coupon_code !== 0){
763
+ $rule_helper = new Rule();
764
+ $available_coupons = $rule_helper->getAllDynamicCoupons();
765
+ if (in_array($coupon_code, $available_coupons)) {
766
+ $amount = 0;
767
+ $coupon = array(
768
+ 'id' => time() . rand(2, 9),
769
+ 'amount' => $amount,
770
+ 'individual_use' => false,
771
+ 'product_ids' => array(),
772
+ 'exclude_product_ids' => array(),
773
+ 'usage_limit' => '',
774
+ 'usage_limit_per_user' => '',
775
+ 'limit_usage_to_x_items' => '',
776
+ 'usage_count' => '',
777
+ 'expiry_date' => '',
778
+ 'apply_before_tax' => 'yes',
779
+ 'free_shipping' => false,
780
+ 'product_categories' => array(),
781
+ 'exclude_product_categories' => array(),
782
+ 'exclude_sale_items' => false,
783
+ 'minimum_amount' => '',
784
+ 'maximum_amount' => '',
785
+ 'customer_email' => '',
786
+ 'discount_type' => 'percent'
787
+ );
788
+ return $coupon;
789
+ }
790
  }
791
+
792
  return $response;
793
  }
794
 
841
  $combine_all_discounts = self::$config->getConfig('combine_all_cart_discounts', 0);
842
  $total_combined_discounts = 0;
843
  $combined_discounts_cart_items = array();
 
844
  if(function_exists('WC')){
845
  $this->applyCartProductDiscount(WC()->cart);
846
  }
847
  $apply_as_cart_fee_details = DiscountCalculator::$price_discount_apply_as_cart_discount;
848
+ DiscountCalculator::$price_discount_apply_as_cart_discount = array();
849
  $apply_as_cart_fee_details = self::removeDuplicateValues($apply_as_cart_fee_details);
850
  $flat_in_subtotal = array();
851
  if(!empty($apply_as_cart_fee_details)){
896
  if (!empty($total_combined_discounts) && !empty($combine_all_discounts)) {
897
  $label = self::$config->getConfig('discount_label_for_combined_discounts', __('Cart discount', WDR_TEXT_DOMAIN));
898
  $label = Helper::getCleanHtml($label);
899
+ if(empty($label)){
900
+ $label = __('Cart discount', WDR_TEXT_DOMAIN);
901
+ }
902
  self::setCartCouponValues($label, $discount_value, $combined_discounts_cart_items);
903
  $this->applyFakeCouponsForCartRules($label);
904
  }
977
  */
978
  function validateVirtualCouponForCartRules($response, $coupon_data)
979
  {
980
+ if($coupon_data !== false && $coupon_data !== 0){
981
+ $discount_apply_type = self::$config->getConfig('apply_cart_discount_as', 'fee');
982
+ if($discount_apply_type == "coupon"){
983
+ if(empty(self::$apply_as_coupon_values)){
984
+ remove_filter('woocommerce_get_shop_coupon_data', array($this, 'validateVirtualCouponForCartRules'), 10);
985
+ $this->applyVirtualCouponForCartRules();
986
+ add_filter('woocommerce_get_shop_coupon_data', array($this, 'validateVirtualCouponForCartRules'), 10, 2);
987
+ }
988
+
989
+ if(!empty(self::$apply_as_coupon_values)){
990
+ if(array_key_exists($coupon_data, self::$apply_as_coupon_values)){
991
+ $coupon_code = $coupon_data;
992
+ $amount = self::$apply_as_coupon_values[$coupon_code]['value'];
993
+ $cart_item_keys = self::$apply_as_coupon_values[$coupon_code]['cart_item_keys'];
994
+ $product_ids = self::getProductIdsFromCartKey($cart_item_keys);
995
+ $discount_in_percentage = self::getPercentageFromCartKey($product_ids, $amount);
996
+ } else {
997
+ return $response;
998
+ }
999
  } else {
1000
+ add_filter('woocommerce_coupon_error', '\Wdr\App\Helpers\Helper::removeErrorMessageForOurCoupons', 10, 3);
1001
  return $response;
1002
  }
 
 
 
 
1003
 
1004
+ // Getting Coupon Remove status from Session.
1005
+ if(isset(WC()->session) && is_object(WC()->session) && method_exists(WC()->session, 'get')) {
1006
+ $is_removed = WC()->session->get('woo_coupon_removed', '');
1007
+ // If Both are same, then it won't added.
1008
+ if(!empty($is_removed)){
1009
+ if ($coupon_code == $is_removed) return $response;
1010
+ }
1011
  }
 
1012
 
1013
+ if ($coupon_data == $coupon_code || wc_strtolower($coupon_data) == wc_strtolower($coupon_code)) {
1014
 
1015
+ //if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
1016
+ if(empty($product_ids)){
1017
+ $discount_type = 'fixed_cart';
1018
+ } else {
1019
+ $discount_type = 'percent';
1020
+ $amount = $discount_in_percentage;
1021
+ }
1022
 
1023
+ $coupon = array(
1024
+ 'id' => time().rand(2, 9),
1025
+ 'amount' => $amount,
1026
+ 'individual_use' => false,
1027
+ 'product_ids' => $product_ids,
1028
+ 'exclude_product_ids' => array(),
1029
+ 'usage_limit' => '',
1030
+ 'usage_limit_per_user' => '',
1031
+ 'limit_usage_to_x_items' => '',
1032
+ 'usage_count' => '',
1033
+ 'expiry_date' => '',
1034
+ 'apply_before_tax' => 'yes',
1035
+ 'free_shipping' => false,
1036
+ 'product_categories' => array(),
1037
+ 'exclude_product_categories' => array(),
1038
+ 'exclude_sale_items' => false,
1039
+ 'minimum_amount' => '',
1040
+ 'maximum_amount' => '',
1041
+ 'customer_email' => '',
1042
+ );
1043
+ $coupon['discount_type'] = $discount_type;
1044
+ return $coupon;
1045
+ }
1046
  }
1047
  }
1048
 
1209
  $discounted_price = self::$calculated_cart_item_discount[$key]['discounted_price'];
1210
  $calculator = self::$calculator;
1211
  $total_discounts = $calculator::$total_discounts;
1212
+ $price = $discounted_price;
 
 
 
 
 
 
 
 
 
 
1213
  $price = apply_filters('advanced_woo_discount_rules_discounted_price_of_cart_item', $price, $cart_item, $cart_object, self::$calculated_cart_item_discount[$key]);
1214
  $do_apply_price_rules = apply_filters('advanced_woo_discount_rules_do_apply_price_discount', true, $price, $cart_item, $cart_object, self::$calculated_cart_item_discount[$key]);
1215
  if($do_apply_price_rules){
1283
 
1284
  /**
1285
  * laod the bulk table discount message manually
1286
+ * @param $product
1287
+ * @param false $get_variable_product_table
1288
+ * @return false|string
1289
  */
1290
+ function showBulkTableInPositionManually($product, $get_variable_product_table = false)
1291
  {
1292
  if (!empty($product)) {
1293
+ $bulk_discounts_ranges = self::$calculator->getDefaultLayoutMessagesByRules($product, $get_variable_product_table);
1294
+ if(empty($bulk_discounts_ranges)){
1295
+ $bulk_discounts_ranges['layout']['type'] = 'default';
1296
+ $bulk_discounts_ranges['layout']['bulk_variant_table'] = 'default_variant_empty';
1297
+ }
1298
  $override_path = get_theme_file_path('advanced_woo_discount_rules/discount_table.php');
1299
  $bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
1300
  if (file_exists($override_path)) {
1301
  $bulk_table_template_path = $override_path;
1302
  }
1303
+ if($get_variable_product_table){
1304
+ return self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper, 'base' => $this))->render();
1305
+ }
1306
  self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper, 'base' => $this))->display();
1307
  }
1308
  }
1385
  $cart_shipping = (isset($cart_discount_details[$rule_id]['cart_shipping']) && !empty($cart_discount_details[$rule_id]['cart_shipping'])) ? $cart_discount_details[$rule_id]['cart_shipping'] : 'no';
1386
  $cart_discount_label = isset($cart_discount_details[$rule_id]['cart_discount_label']) ? $cart_discount_details[$rule_id]['cart_discount_label'] : '';
1387
  $simple_discount = isset($value['simple_discount']) ? $value['simple_discount'] : 0;
1388
+ if(is_array($simple_discount)){
1389
+ $simple_discount = $simple_discount['discount_price'] * $cart_quantity;
1390
+ } else {
1391
+ $simple_discount = $simple_discount * $cart_quantity;
1392
+ }
1393
  $bulk_discount = isset($value['bulk_discount']) ? $value['bulk_discount'] : 0;
1394
+ if(is_array($bulk_discount)){
1395
+ $bulk_discount = $bulk_discount['discount_price'] * $cart_quantity;
1396
+ } else {
1397
+ $bulk_discount = $bulk_discount * $cart_quantity;
1398
+ }
1399
  $set_discount = isset($value['set_discount']['discount_value']) ? $value['set_discount']['discount_value'] : 0;
1400
  $set_discounted_price_quantity = isset($value['set_discount']['discounted_price_quantity']) ? $value['set_discount']['discounted_price_quantity'] : 0;
1401
  if(!empty($set_discounted_price_quantity)){
1609
  * @param $cart_item_key
1610
  * @return mixed|void
1611
  */
1612
+ function getCartPriceHtml($item_price, $cart_item, $cart_item_key){
1613
+ $show_strikeout_on_cart = self::$config->getConfig('show_strikeout_on_cart', 1);
1614
+ if (!empty($show_strikeout_on_cart)) {
1615
+ $new_item_price_html = '';
1616
+ if (isset(self::$calculated_cart_item_discount[$cart_item_key])) {
 
 
 
 
 
 
 
 
1617
  $initial_price = self::$calculated_cart_item_discount[$cart_item_key]['initial_price'];
1618
+ $discounted_price = self::$calculated_cart_item_discount[$cart_item_key]['discounted_price'];
1619
+ $discount_lines = self::$calculated_cart_item_discount[$cart_item_key]['discount_lines'];
1620
+ if(!empty($discount_lines)){
1621
+ $calculator = self::$calculator;
1622
+ $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
1623
+
 
 
 
1624
  $initial_price_with_tax_call = $discounted_price_with_tax_call = 0;
1625
  if(!empty($initial_price)){
1626
  $initial_price_with_tax_call = $calculator->mayHaveTax($product_obj, $initial_price);
1627
  }
1628
+ $has_non_applied_lines = false;
1629
+ if(isset($discount_lines['non_applied']) && !empty($discount_lines['non_applied'])){
1630
+ if(isset($discount_lines['non_applied']['quantity']) && $discount_lines['non_applied']['quantity'] > 0){
1631
+ $has_non_applied_lines = true;
1632
+ }
1633
+ }
1634
+ $discount_line_count = count($discount_lines);
1635
+ $has_multiple_strikeout_lines = false;
1636
+ foreach ($discount_lines as $key => $discount_line){
1637
+ if($key !== 'non_applied'){
1638
+ $has_multiple_strikeout_lines = true;
1639
+ $discounted_price = $discount_line['discounted_price'];
1640
+ $discounted_qty = $discount_line['quantity'];
1641
+ $discounted_price_with_tax_call = $calculator->mayHaveTax($product_obj, $discounted_price);
1642
+ if($has_non_applied_lines == false && $discount_line_count === 2){
1643
+ $new_item_price_html .= '<div class="awdr_cart_strikeout_line">'.$this->getStrikeoutPrice($initial_price_with_tax_call, $discounted_price_with_tax_call).'</div>';
1644
+ } else {
1645
+ $new_item_price_html .= '<div class="awdr_cart_strikeout_line">'.$this->getStrikeoutPrice($initial_price_with_tax_call, $discounted_price_with_tax_call).'&nbsp;x&nbsp;'.$discounted_qty.'</div>';
1646
+ }
1647
+ }
1648
+ }
1649
+ if($has_multiple_strikeout_lines){
1650
+ if(isset($discount_lines['non_applied']) && !empty($discount_lines['non_applied'])){
1651
+ if(isset($discount_lines['non_applied']['quantity']) && $discount_lines['non_applied']['quantity'] > 0){
1652
+ $discounted_qty = $discount_lines['non_applied']['quantity'];
1653
+ $new_item_price_html .= '<div class="awdr_cart_strikeout_line">'.self::$woocommerce_helper->formatPrice($initial_price_with_tax_call).'&nbsp;x&nbsp;'.$discounted_qty.'</div>';
1654
+ }
1655
+ }
1656
  }
 
1657
  }
1658
+ if($new_item_price_html !== ''){
1659
+ return apply_filters('advanced_woo_discount_rules_cart_strikeout_price_html', $new_item_price_html, $item_price, $cart_item, $cart_item_key);
1660
+ }
1661
  }
1662
  }
1663
+
1664
+ return $item_price;
1665
  }
1666
 
1667
  /**
1708
  */
1709
  function getDiscountPerItem($discount_details)
1710
  {
1711
+ /**
1712
+ * Field name changed. For backward compatible we have to check the key exists
1713
+ * saved_amount_with_tax => saved_amount_based_on_tax_settings
1714
+ * initial_price_with_tax => initial_price_based_on_tax_settings (only for orders)
1715
+ * discounted_price_with_tax => discounted_price_based_on_tax_settings (only for orders)
1716
+ * */
1717
+ $saved_amount_with_tax_field_name = 'saved_amount_with_tax';
1718
+ $initial_price_with_tax_field_name = 'initial_price_with_tax';
1719
+ $discounted_price_with_tax_field_name = 'discounted_price_with_tax';
1720
+ if(isset($discount_details['saved_amount_based_on_tax_settings'])){
1721
+ $saved_amount_with_tax_field_name = 'saved_amount_based_on_tax_settings';
1722
+ }
1723
+ if(isset($discount_details['initial_price_based_on_tax_settings'])){
1724
+ $initial_price_with_tax_field_name = 'initial_price_based_on_tax_settings';
1725
+ }
1726
+ if(isset($discount_details['discounted_price_based_on_tax_settings'])){
1727
+ $discounted_price_with_tax_field_name = 'discounted_price_based_on_tax_settings';
1728
+ }
1729
+
1730
+ if(isset($discount_details[$saved_amount_with_tax_field_name])){
1731
+ if ($discount_details[$saved_amount_with_tax_field_name] > 0) {
1732
+ return $discount_details[$saved_amount_with_tax_field_name];
1733
  }
1734
  }
1735
+ $discounted_price = isset($discount_details[$discounted_price_with_tax_field_name]) ? $discount_details[$discounted_price_with_tax_field_name] : 0;
1736
+ $initial_price = isset($discount_details[$initial_price_with_tax_field_name]) ? $discount_details[$initial_price_with_tax_field_name] : 0;
1737
  $cart_quantity = isset($discount_details['cart_quantity']) ? $discount_details['cart_quantity'] : 0;
1738
  $total_discount_per_quantity = $initial_price - $discounted_price;
1739
  if ($discounted_price >= 0 && $total_discount_per_quantity > 0) {
1797
  }
1798
  }
1799
  }
1800
+ if(isset($meta_discount_details['initial_price_with_tax'])){
1801
+ $meta_discount_details['initial_price_based_on_tax_settings'] = $meta_discount_details['initial_price_with_tax'];
1802
+ unset($meta_discount_details['initial_price_with_tax']);
1803
+ }
1804
+ if(isset($meta_discount_details['discounted_price_with_tax'])){
1805
+ $meta_discount_details['discounted_price_based_on_tax_settings'] = $meta_discount_details['discounted_price_with_tax'];
1806
+ unset($meta_discount_details['discounted_price_with_tax']);
1807
+ }
1808
+
1809
  self::$woocommerce_helper->setOrderItemMeta($item, '_advanced_woo_discount_item_total_discount', $meta_discount_details);
1810
  }
1811
  }
1936
  }
1937
 
1938
  //simple discounted price
1939
+ if(isset($detail['simple_discount']) && is_array($detail['simple_discount'])){
1940
+ $simple_discount = isset($detail['simple_discount']['discount_price']) ? $detail['simple_discount']['discount_price'] : 0;
1941
+ } else {
1942
+ $simple_discount = isset($detail['simple_discount']) ? $detail['simple_discount'] : 0;
1943
+ }
1944
  //bulk discounted price
1945
+ if(isset($detail['bulk_discount']) && is_array($detail['bulk_discount'])){
1946
+ $bulk_discounts = isset($detail['bulk_discount']['discount_price']) ? $detail['bulk_discount']['discount_price'] : 0;
1947
+ } else {
1948
+ $bulk_discounts = isset($detail['bulk_discount']) ? $detail['bulk_discount'] : 0;
1949
+ }
1950
+
1951
 
1952
  //set discounted price quantity
1953
  $total_discount_price += $discounted_price_per_set + $simple_discount + $bulk_discounts + $bogo_cheapest_discount;
2140
  function removeOnSaleFlashEvent(){
2141
  $allowed_hooks = array(
2142
  //Filters
2143
+ "woocommerce_sale_flash" => array( "Wdr\App\Controllers\ManageDiscount|replaceSaleTagText" ),
2144
  );
2145
 
2146
  $this->removeOtherEvents($allowed_hooks);
2158
  "woocommerce_product_get_sale_price" => array(),
2159
  "woocommerce_product_get_regular_price" => array(),
2160
  "woocommerce_variable_price_html" => array("Wdr\App\Controllers\ManageDiscount|getVariablePriceHtml"),
2161
+ "woocommerce_cart_item_price" => array("Wdr\App\Controllers\ManageDiscount|getCartPriceHtml"),
2162
  "woocommerce_cart_item_subtotal" => array("Wdr\App\Controllers\ManageDiscount|getCartProductSubtotalPriceHtml"),
2163
  //Actions
2164
  "woocommerce_checkout_order_processed" => array(),
2445
  }
2446
  echo $save_text;
2447
  }
2448
+
2449
+ /**
2450
+ * Include tax in fee
2451
+ * */
2452
+ public function applyTaxInFee($fee, $cart){
2453
+ if(Woocommerce::isEnteredPriceIncludeTax()){
2454
+ if(class_exists('\WC_Tax')){
2455
+ $fee_taxs = \WC_Tax::calc_tax( $fee, \WC_Tax::get_rates( '', \WC()->cart->get_customer() ), true );
2456
+ if(!empty($fee_taxs)){
2457
+ foreach ($fee_taxs as $key => $val){
2458
+ $fee = $fee - $val;
2459
+ }
2460
+ }
2461
+ }
2462
+ }
2463
+
2464
+ return $fee;
2465
+ }
2466
  }
v2/App/Controllers/OnSaleShortCode.php CHANGED
@@ -384,7 +384,8 @@ class OnSaleShortCode extends ManageDiscount
384
 
385
  function setSkuQueryArguments(&$query_arguments, $query_type, $values)
386
  {
387
- $values = array_map('absint', $values);
 
388
  if($query_type == 'include'){
389
  $operator = 'IN';
390
  } else {
384
 
385
  function setSkuQueryArguments(&$query_arguments, $query_type, $values)
386
  {
387
+ /* It might has string values so we can't convert it to integer */
388
+ /*$values = array_map('absint', $values);*/
389
  if($query_type == 'include'){
390
  $operator = 'IN';
391
  } else {
v2/App/Controllers/ShortCodeManager.php CHANGED
@@ -339,124 +339,9 @@ class ShortCodeManager extends ManageDiscount
339
  ), $short_code_attributes);
340
  $paged = $this->input->get('product-page', 1);
341
  $order_by = $this->input->get('orderby', 'title');
342
- /*$exclude_categories = $exclude_products = $exclude_tags = $exclude_attributes = $exclude_skus = $exclude_custom_taxonomies = array();
343
- $categories = $products = $tags = $attributes = $skus = $custom_taxonomies = array();
344
- $all_products = $on_sale_products = '';
345
- $query_arguments = array(
346
- 'post_type' => 'product',
347
- 'post_status' => 'publish',
348
- 'paged' => $paged,
349
- 'posts_per_page' => $short_code_attributes['per_page'],
350
- 'orderby' => $short_code_attributes['orderby'],
351
- 'order' => $short_code_attributes['order'],
352
- );
353
- $this->modifyFilterArguments($query_arguments, $order_by);
354
- foreach (self::$available_rules as $rule) {
355
- $discount_type = $rule->getRuleDiscountType();
356
- if($discount_type == 'wdr_buy_x_get_y_discount'){
357
- $get_y = $rule->getBuyXGetYAdjustment();
358
- $type = (isset($get_y->type) && !empty($get_y->type)) ? $get_y->type : '';
359
- $parent_id = array();
360
- foreach ($get_y->ranges as $range){
361
- $get_y_products = isset($range->products) ? $range->products : array();
362
- $get_y_parent_ids = isset($range->product_variants_for_sale_badge) ? $range->product_variants_for_sale_badge : array();
363
- foreach ($get_y_parent_ids as $get_y_parent_id){
364
- $get_y_parent_id_array = isset($get_y_parent_id) ? $get_y_parent_id : array();
365
- $parent_id = array_merge($parent_id, $get_y_parent_id_array);
366
- }
367
- if(!empty($type)){
368
- if($type == 'bxgy_product' && isset($range->products) && !empty($range->products)){
369
- if(!empty($parent_id)){
370
- $get_y_products = array_merge($get_y_products, $parent_id);
371
- }
372
- $products = array_merge($products, $get_y_products);
373
- $products = array_unique($products);
374
- }
375
- if($type == 'bxgy_category' && isset($range->categories) && !empty($range->categories)){
376
- $categories = array_merge($categories, $range->categories);
377
- }
378
- }
379
- }
380
- }
381
- $filters = $rule->getFilter();
382
- foreach ($filters as $filter) {
383
- $type = $rule->getFilterType($filter);
384
- $values = (array)$rule->getFilterOptionValue($filter);
385
- $parent_product_id = (array)$rule->getFilterOptionParentValue($filter);
386
- $method = $rule->getFilterMethod($filter);
387
- switch ($type) {
388
- case "all_products":
389
- $all_products = 'yes';
390
- break;
391
- case "product_on_sale":
392
- $on_sale_products = $method;
393
- break;
394
- case "product_category":
395
- if ($method == "in_list") {
396
- $categories = array_merge($categories, $values);
397
- $categories = array_unique($categories);
398
- } else {
399
- $exclude_categories = array_merge($exclude_categories, $values);
400
- }
401
- break;
402
- case "products":
403
- if ($method == "in_list") {
404
- if(!empty($parent_product_id)){
405
- $values = array_merge($values, $parent_product_id);
406
- }
407
- $products = array_merge($products, $values);
408
- $products = array_unique($products);
409
- } else {
410
- $exclude_products = array_merge($exclude_products, $values);
411
- }
412
- break;
413
- case "product_tags":
414
- if ($method == "in_list") {
415
- $tags = array_merge($tags, $values);
416
- } else {
417
- $exclude_tags = array_merge($exclude_tags, $values);
418
- }
419
- break;
420
- case "product_attributes":
421
- if ($method == "in_list") {
422
- $attributes = array_merge($attributes, $values);
423
- } else {
424
- $exclude_attributes = array_merge($exclude_attributes, $values);
425
- }
426
- break;
427
- case "product_sku":
428
- if ($method == "in_list") {
429
- $skus = array_merge($skus, $values);
430
- } else {
431
- $exclude_skus = array_merge($exclude_skus, $values);
432
- }
433
- break;
434
- default:
435
- if ($method == "in_list") {
436
- $custom_taxonomies[$type] = isset($custom_taxonomies[$type]) ? array_merge($custom_taxonomies[$type], $values) : $values;
437
- } else {
438
- $exclude_custom_taxonomies[$type] = isset($exclude_custom_taxonomies[$type]) ? array_merge($exclude_custom_taxonomies[$type], $values) : $values;
439
- }
440
- break;
441
- }
442
- }
443
- }
444
 
445
- $this->setCategoriesQueryArguments($query_arguments, $categories, $exclude_categories, $all_products);
446
- $this->setTagsQueryArguments($query_arguments, $tags, $exclude_tags, $all_products);
447
- $this->setAttributesQueryArguments($query_arguments, $attributes, $exclude_attributes, $all_products);
448
- $this->setSkuQueryArguments($query_arguments, $skus, $exclude_skus, $all_products);
449
- $this->setOnSaleQueryArguments($query_arguments, $on_sale_products, $all_products);
450
- $this->setCustomTaxonomyQueryArguments($query_arguments, $custom_taxonomies, $exclude_custom_taxonomies, $all_products);
451
- $this->setProductsQueryArguments($query_arguments, $products, $exclude_products, $all_products);
452
- $this->setQueryRelationship($query_arguments);
453
- // echo "<pre>"; print_r($query_arguments); echo "</pre>"; die;*/
454
  ob_start();
455
  $onsale_list = OnSaleShortCode::getOnSaleList();
456
- // echo "<pre>";
457
- // print_r($onsale_list);
458
- // echo "</pre>";
459
- // exit;
460
  if(!empty($onsale_list)){
461
  $query_arguments = array(
462
  'post_type' => 'product',
@@ -637,7 +522,6 @@ class ShortCodeManager extends ManageDiscount
637
  $this->setCustomTaxonomyQueryArguments($query_arguments, $custom_taxonomies, $exclude_custom_taxonomies, $all_products);
638
  $this->setProductsQueryArguments($query_arguments, $products, $exclude_products, $all_products);
639
  $this->setQueryRelationship($query_arguments);
640
- // echo "<pre>"; print_r($query_arguments); echo "</pre>"; die;
641
  ob_start();
642
  $products = new \WP_Query($query_arguments);
643
  $columns = absint($short_code_attributes['columns']);
339
  ), $short_code_attributes);
340
  $paged = $this->input->get('product-page', 1);
341
  $order_by = $this->input->get('orderby', 'title');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
 
 
 
 
 
 
 
 
 
 
343
  ob_start();
344
  $onsale_list = OnSaleShortCode::getOnSaleList();
 
 
 
 
345
  if(!empty($onsale_list)){
346
  $query_arguments = array(
347
  'post_type' => 'product',
522
  $this->setCustomTaxonomyQueryArguments($query_arguments, $custom_taxonomies, $exclude_custom_taxonomies, $all_products);
523
  $this->setProductsQueryArguments($query_arguments, $products, $exclude_products, $all_products);
524
  $this->setQueryRelationship($query_arguments);
 
525
  ob_start();
526
  $products = new \WP_Query($query_arguments);
527
  $columns = absint($short_code_attributes['columns']);
v2/App/Helpers/Filter.php CHANGED
@@ -118,7 +118,7 @@ class Filter
118
  }
119
  }
120
  }
121
- // echo "<pre>"; var_dump($status); echo "</pre>"; die;
122
  return $status;
123
  }
124
 
118
  }
119
  }
120
  }
121
+
122
  return $status;
123
  }
124
 
v2/App/Helpers/Helper.php CHANGED
@@ -265,7 +265,8 @@ class Helper
265
  }
266
  }
267
  }
268
- $coupon_names[] = Configuration::getInstance()->getConfig('discount_label_for_combined_discounts', __('Cart discount', WDR_TEXT_DOMAIN));
 
269
  foreach ($coupon_names as $key => $coupon_name){
270
  $coupon_names[$key] = apply_filters('woocommerce_coupon_code', $coupon_name);
271
  }
@@ -328,9 +329,9 @@ class Helper
328
 
329
  public static function displayCompatibleCheckMessages()
330
  {
331
- if (version_compare(WDR_VERSION, '2.2.2', '>=')) {
332
  if (defined('WDR_PRO_VERSION')) {
333
- if (version_compare(WDR_PRO_VERSION, '2.2.2', '<')) {
334
  $url = admin_url() . "plugins.php";
335
  $plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', WDR_TEXT_DOMAIN) . '</a>';
336
  ?>
265
  }
266
  }
267
  }
268
+ $coupon_name_from_config = Configuration::getInstance()->getConfig('discount_label_for_combined_discounts', __('Cart discount', WDR_TEXT_DOMAIN));
269
+ $coupon_names[] = (empty($coupon_name_from_config))? __('Cart discount', WDR_TEXT_DOMAIN): $coupon_name_from_config;
270
  foreach ($coupon_names as $key => $coupon_name){
271
  $coupon_names[$key] = apply_filters('woocommerce_coupon_code', $coupon_name);
272
  }
329
 
330
  public static function displayCompatibleCheckMessages()
331
  {
332
+ if (version_compare(WDR_VERSION, '2.3.0', '>=')) {
333
  if (defined('WDR_PRO_VERSION')) {
334
+ if (version_compare(WDR_PRO_VERSION, '2.3.0', '<')) {
335
  $url = admin_url() . "plugins.php";
336
  $plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', WDR_TEXT_DOMAIN) . '</a>';
337
  ?>
v2/App/Helpers/Input.php CHANGED
@@ -261,6 +261,11 @@ class Input
261
  */
262
  protected function _clean_input_data($str)
263
  {
 
 
 
 
 
264
  if (is_array($str)) {
265
  $new_array = array();
266
  foreach (array_keys($str) as $key) {
@@ -268,6 +273,9 @@ class Input
268
  }
269
  return $new_array;
270
  }
 
 
 
271
  /* We strip slashes if magic quotes is on to keep things consistent
272
 
273
  NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
@@ -401,6 +409,11 @@ class Input
401
  */
402
  function xss_clean($str, $is_image = FALSE)
403
  {
 
 
 
 
 
404
  // Is the string an array?
405
  if (is_array($str)) {
406
  foreach ($str as $key => &$value) {
@@ -831,16 +844,15 @@ class Input
831
  try {
832
  // The cast is required to avoid TypeError
833
  return random_bytes((int)$length);
834
- } catch (Exception $e) {
835
  // If random_bytes() can't do the job, we can't either ...
836
  // There's no point in using fallbacks.
837
- log_message('error', $e->getMessage());
838
  return FALSE;
839
  }
840
  }
841
  if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
842
  // Try not to waste entropy ...
843
- is_php('5.4') && stream_set_chunk_size($fp, $length);
844
  $output = fread($fp, $length);
845
  fclose($fp);
846
  if ($output !== FALSE) {
261
  */
262
  protected function _clean_input_data($str)
263
  {
264
+ //if it is an object, just return.
265
+ if(is_object($str)) {
266
+ return $str;
267
+ }
268
+
269
  if (is_array($str)) {
270
  $new_array = array();
271
  foreach (array_keys($str) as $key) {
273
  }
274
  return $new_array;
275
  }
276
+ if(is_object($str)){
277
+ return $str;
278
+ }
279
  /* We strip slashes if magic quotes is on to keep things consistent
280
 
281
  NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
409
  */
410
  function xss_clean($str, $is_image = FALSE)
411
  {
412
+ //is this an object, then return it.
413
+ if(is_object($str)) {
414
+ return $str;
415
+ }
416
+
417
  // Is the string an array?
418
  if (is_array($str)) {
419
  foreach ($str as $key => &$value) {
844
  try {
845
  // The cast is required to avoid TypeError
846
  return random_bytes((int)$length);
847
+ } catch (\Exception $e) {
848
  // If random_bytes() can't do the job, we can't either ...
849
  // There's no point in using fallbacks.
 
850
  return FALSE;
851
  }
852
  }
853
  if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
854
  // Try not to waste entropy ...
855
+ $this->is_php('5.4') && stream_set_chunk_size($fp, $length);
856
  $output = fread($fp, $length);
857
  fclose($fp);
858
  if ($output !== FALSE) {
v2/App/Helpers/Rule.php CHANGED
@@ -645,6 +645,8 @@ class Rule
645
  self::$bulk_discounts[$product_id] = $product_bulk_discount;
646
  }
647
  $rule = $this;
 
 
648
  $discounts = array(
649
  'product_discount' => $product_discount,
650
  'product_bulk_discount' => $product_bulk_discount
@@ -688,6 +690,7 @@ class Rule
688
  */
689
  function calculateProductDiscount($price, $quantity, $product, $product_id, $price_display_condition, $is_cart, $manual_request = false)
690
  {
 
691
  $cart_quantity = 0;
692
  if($manual_request === false){
693
  $quantity = 0;
@@ -726,7 +729,14 @@ class Rule
726
  }
727
 
728
  if ( $quantity > 0) {
729
- return $this->calculator($discount->type, $price, $discount->value);
 
 
 
 
 
 
 
730
  } else {
731
  return 0;
732
  }
@@ -769,6 +779,7 @@ class Rule
769
  */
770
  function getMatchedBulkDiscount( $product, $price, $operator, $ranges, $quantity, $bulk_discount_data, $price_display_condition, $is_cart, $manual_request = false)
771
  {
 
772
  if (empty($ranges)) {
773
  return 0;
774
  }
@@ -813,7 +824,15 @@ class Rule
813
  $type = (isset($matched_row->type) && !empty($matched_row->type)) ? $matched_row->type : false;
814
  $value = (isset($matched_row->value) && !empty($matched_row->value)) ? $matched_row->value : 0;
815
  if ($type && !empty($value)) {
816
- return $this->calculator($matched_row->type, $price, $matched_row->value);
 
 
 
 
 
 
 
 
817
  }
818
  return 0;
819
  }
645
  self::$bulk_discounts[$product_id] = $product_bulk_discount;
646
  }
647
  $rule = $this;
648
+ if(is_array($product_discount)) $product_discount = $product_discount['discount_price'];
649
+ if(is_array($product_bulk_discount)) $product_bulk_discount = $product_bulk_discount['discount_price'];
650
  $discounts = array(
651
  'product_discount' => $product_discount,
652
  'product_bulk_discount' => $product_bulk_discount
690
  */
691
  function calculateProductDiscount($price, $quantity, $product, $product_id, $price_display_condition, $is_cart, $manual_request = false)
692
  {
693
+ $original_qty = $quantity;
694
  $cart_quantity = 0;
695
  if($manual_request === false){
696
  $quantity = 0;
729
  }
730
 
731
  if ( $quantity > 0) {
732
+ $discount_price = $this->calculator($discount->type, $price, $discount->value);
733
+ return array(
734
+ 'discount_type' => $discount->type,
735
+ 'discount_value' => $discount->value,
736
+ 'discount_quantity' => $original_qty,
737
+ 'discount_price_per_quantity' => $discount_price,
738
+ 'discount_price' => $discount_price,
739
+ );
740
  } else {
741
  return 0;
742
  }
779
  */
780
  function getMatchedBulkDiscount( $product, $price, $operator, $ranges, $quantity, $bulk_discount_data, $price_display_condition, $is_cart, $manual_request = false)
781
  {
782
+ $original_qty = $quantity;
783
  if (empty($ranges)) {
784
  return 0;
785
  }
824
  $type = (isset($matched_row->type) && !empty($matched_row->type)) ? $matched_row->type : false;
825
  $value = (isset($matched_row->value) && !empty($matched_row->value)) ? $matched_row->value : 0;
826
  if ($type && !empty($value)) {
827
+ //return $this->calculator($matched_row->type, $price, $matched_row->value);
828
+ $discount_price = $this->calculator($matched_row->type, $price, $matched_row->value);
829
+ return array(
830
+ 'discount_type' => $matched_row->type,
831
+ 'discount_value' => $matched_row->value,
832
+ 'discount_quantity' => $original_qty,
833
+ 'discount_price_per_quantity' => $discount_price,
834
+ 'discount_price' => $discount_price,
835
+ );
836
  }
837
  return 0;
838
  }
v2/App/Helpers/Template.php CHANGED
@@ -63,13 +63,6 @@ class Template
63
  ob_start();
64
  if (file_exists($this->getPath())) {
65
  extract($this->data);
66
- /*if(isset($condition_site_languages)){
67
- echo '<pre>';print_r($condition_site_languages);echo'</pre>';
68
- $render_saved_condition =false;
69
- echo $this->getPath();
70
- include $this->getPath();
71
- die;
72
- }*/
73
  include $this->getPath();
74
  }
75
  return ob_get_clean();
63
  ob_start();
64
  if (file_exists($this->getPath())) {
65
  extract($this->data);
 
 
 
 
 
 
 
66
  include $this->getPath();
67
  }
68
  return ob_get_clean();
v2/App/Helpers/Validation.php CHANGED
@@ -5,6 +5,13 @@ namespace Wdr\App\Helpers;
5
  use Valitron\Validator;
6
 
7
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
 
 
 
 
 
 
 
8
  class Validation
9
  {
10
  static $is_condition_value_valid = NULL;
@@ -164,6 +171,7 @@ class Validation
164
  $input_validator->rule('conditionValues',
165
  array(
166
  'conditions.*.options.value',
 
167
  )
168
  );
169
  //exclude our short code
@@ -179,7 +187,6 @@ class Validation
179
  'product_adjustments.type',
180
  'filters.*.type',
181
  'filters.*.method',
182
- 'filters.*.value.*',
183
  'cart_adjustments.type',
184
  'bulk_adjustments.operator',
185
  'bulk_adjustments.ranges.*.type',
5
  use Valitron\Validator;
6
 
7
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
8
+
9
+ /**
10
+ * Validation
11
+ * https://github.com/vlucas/valitron
12
+ * Class Validation
13
+ * @package Wdr\App\Helpers
14
+ */
15
  class Validation
16
  {
17
  static $is_condition_value_valid = NULL;
171
  $input_validator->rule('conditionValues',
172
  array(
173
  'conditions.*.options.value',
174
+ 'filters.*.value.*',
175
  )
176
  );
177
  //exclude our short code
187
  'product_adjustments.type',
188
  'filters.*.type',
189
  'filters.*.method',
 
190
  'cart_adjustments.type',
191
  'bulk_adjustments.operator',
192
  'bulk_adjustments.ranges.*.type',
v2/App/Helpers/Woocommerce.php CHANGED
@@ -718,7 +718,7 @@ class Woocommerce
718
  {
719
  if (method_exists($cart, 'add_fee')) {
720
  if(apply_filters('advanced_discount_rules_do_add_fee', true, $cart)){
721
- if(!apply_filters('advanced_discount_rules_calculate_tax_with_fee', false, $name, $cart)){
722
  add_filter('woocommerce_cart_totals_get_fees_from_cart_taxes', function ($fee_taxes, $fee, $cart) use ($name) {
723
  if(isset($fee->object->name)){
724
  if($fee->object->name == $name) {
@@ -736,6 +736,14 @@ class Woocommerce
736
  return array();
737
  }
738
 
 
 
 
 
 
 
 
 
739
  /**
740
  * get coupon code from coupon object
741
  * @param $coupon
@@ -1579,4 +1587,46 @@ class Woocommerce
1579
  }
1580
  return $html;
1581
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1582
  }
718
  {
719
  if (method_exists($cart, 'add_fee')) {
720
  if(apply_filters('advanced_discount_rules_do_add_fee', true, $cart)){
721
+ if(!apply_filters('advanced_discount_rules_calculate_tax_with_fee', true, $name, $cart)){
722
  add_filter('woocommerce_cart_totals_get_fees_from_cart_taxes', function ($fee_taxes, $fee, $cart) use ($name) {
723
  if(isset($fee->object->name)){
724
  if($fee->object->name == $name) {
736
  return array();
737
  }
738
 
739
+ static function isEnteredPriceIncludeTax(){
740
+ if(get_option('woocommerce_prices_include_tax', 'no') == 'no'){
741
+ return false;
742
+ } else {
743
+ return true;
744
+ }
745
+ }
746
+
747
  /**
748
  * get coupon code from coupon object
749
  * @param $coupon
1587
  }
1588
  return $html;
1589
  }
1590
+
1591
+ /**
1592
+ * check is rtl function
1593
+ * @return bool
1594
+ */
1595
+ public static function isRTLEnable(){
1596
+ if(function_exists('is_rtl') && is_rtl()){
1597
+ return true;
1598
+ }
1599
+ return false;
1600
+ }
1601
+
1602
+
1603
+
1604
+ /**
1605
+ * get available product variations
1606
+ * @param $product
1607
+ * @return array
1608
+ */
1609
+ public static function availableProductVariations($product){
1610
+ $available_variations = array();
1611
+ $is_variable_product = self::productTypeIs($product, 'variable');
1612
+ if ($is_variable_product && method_exists($product, 'get_available_variations')){
1613
+ $available_variations = $product->get_available_variations();
1614
+ }
1615
+ return $available_variations;
1616
+ }
1617
+
1618
+ /**
1619
+ * get default attribute of variable product
1620
+ * @param $product
1621
+ * @param $attribute_name
1622
+ * @return string
1623
+ */
1624
+ public static function getProductVariationDefaultAttribute($product, $attribute_name){
1625
+ $default_value = '';
1626
+ $is_variable_product = self::productTypeIs($product, 'variable');
1627
+ if ($is_variable_product && method_exists($product, 'get_variation_default_attribute')){
1628
+ $default_value = $product->get_variation_default_attribute($attribute_name);
1629
+ }
1630
+ return $default_value;
1631
+ }
1632
  }
v2/App/Router.php CHANGED
@@ -143,7 +143,7 @@ class Router
143
  add_action('woocommerce_before_mini_cart', array(self::$manage_discount, 'reCalculateCartTotal'), 10);
144
  //cart
145
  add_action('woocommerce_before_calculate_totals', array(self::$manage_discount, 'applyCartProductDiscount'), 1000);
146
- add_action('woocommerce_cart_item_price', array(self::$manage_discount, 'getCartProductPriceHtml'), 1000, 3);
147
  add_filter('woocommerce_cart_totals_coupon_label', array(self::$manage_discount, 'overwriteCouponLabel'), 10, 2);
148
  add_action('woocommerce_cart_calculate_fees', array(self::$manage_discount, 'applyCartDiscount'));
149
  add_filter('woocommerce_get_shop_coupon_data', array(self::$manage_discount, 'checkCouponToApply'), 10, 2);
@@ -192,5 +192,8 @@ class Router
192
  }
193
 
194
  add_action('advanced_woo_discount_rules_after_initialize', array(self::$manage_discount, 'awdrExportCsv'));
 
 
 
195
  }
196
  }
143
  add_action('woocommerce_before_mini_cart', array(self::$manage_discount, 'reCalculateCartTotal'), 10);
144
  //cart
145
  add_action('woocommerce_before_calculate_totals', array(self::$manage_discount, 'applyCartProductDiscount'), 1000);
146
+ add_action('woocommerce_cart_item_price', array(self::$manage_discount, 'getCartPriceHtml'), 1000, 3);
147
  add_filter('woocommerce_cart_totals_coupon_label', array(self::$manage_discount, 'overwriteCouponLabel'), 10, 2);
148
  add_action('woocommerce_cart_calculate_fees', array(self::$manage_discount, 'applyCartDiscount'));
149
  add_filter('woocommerce_get_shop_coupon_data', array(self::$manage_discount, 'checkCouponToApply'), 10, 2);
192
  }
193
 
194
  add_action('advanced_woo_discount_rules_after_initialize', array(self::$manage_discount, 'awdrExportCsv'));
195
+
196
+ //Deprecated the event advanced_woo_discount_rules_additional_fee_value
197
+ add_filter('advanced_woo_discount_rules_additional_fee_amount', array(self::$manage_discount, 'applyTaxInFee'), 10, 2);
198
  }
199
  }
v2/App/Views/Admin/Rules/Discounts/Bulk.php CHANGED
@@ -59,11 +59,7 @@ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
59
  placeholder="<?php _e('Discount', WDR_TEXT_DOMAIN); ?>"
60
  min="0"
61
  step="any"
62
- value="<?php if (isset($range_value->value) && !empty($range_value->value)) {
63
- echo $range_value->value;
64
- }else{
65
- echo 0;
66
- } ?>">
67
  <span class="wdr_desc_text"><?php _e('Discount Value', WDR_TEXT_DOMAIN); ?></span>
68
  </div>
69
  <div class="bulk_amount">
59
  placeholder="<?php _e('Discount', WDR_TEXT_DOMAIN); ?>"
60
  min="0"
61
  step="any"
62
+ value="<?php echo (isset($range_value->value) && !empty($range_value->value)) ? $range_value->value : 0;?>">
 
 
 
 
63
  <span class="wdr_desc_text"><?php _e('Discount Value', WDR_TEXT_DOMAIN); ?></span>
64
  </div>
65
  <div class="bulk_amount">
v2/App/Views/Admin/Rules/Discounts/Main.php CHANGED
@@ -86,15 +86,16 @@ If a customer buys 2 of Product A - Small, 4 of Product A - Medium, 6 of Prod
86
  data-append="bulk_range_setter"><?php _e('Add Range', WDR_TEXT_DOMAIN) ?></button>
87
  </div>
88
  <div class="apply_discount_as_cart_section">
89
- <div class="page__toggle apply_as_cart_checkbox">
90
- <label class="toggle">
91
- <input class="toggle__input apply_fee_coupon_checkbox" type="checkbox"
 
92
  name="bulk_adjustments[apply_as_cart_rule]" <?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? 'checked' : '' ?> value="1">
93
- <span class="toggle__label"><span
94
- class="toggle__text toggle_tic"><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
95
  </label>
96
  </div>
97
- <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? '' : 'display: none;' ?>">
98
  <input name="bulk_adjustments[cart_label]"
99
  type="text"
100
  value="<?php echo (isset($bulk_adj_as_cart_label)) ? $bulk_adj_as_cart_label : ''; ?>"
86
  data-append="bulk_range_setter"><?php _e('Add Range', WDR_TEXT_DOMAIN) ?></button>
87
  </div>
88
  <div class="apply_discount_as_cart_section">
89
+ <?php $is_enabled_rtl = \Wdr\App\Helpers\Woocommerce::isRTLEnable();?>
90
+ <div class="apply_as_cart_checkbox awdr_rtl_compatible <?php echo (!$is_enabled_rtl) ? 'page__toggle' : ''; ?> ">
91
+ <label class="<?php echo (!$is_enabled_rtl) ? 'toggle' : ''; ?>">
92
+ <input class="<?php echo (!$is_enabled_rtl) ? 'toggle__input' : ''; ?> apply_fee_coupon_checkbox" type="checkbox"
93
  name="bulk_adjustments[apply_as_cart_rule]" <?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? 'checked' : '' ?> value="1">
94
+ <span class="<?php echo (!$is_enabled_rtl) ? 'toggle__label' : ''; ?>"><span
95
+ class="<?php echo (!$is_enabled_rtl) ? 'toggle__text toggle_tic' : ''; ?> "><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
96
  </label>
97
  </div>
98
+ <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
99
  <input name="bulk_adjustments[cart_label]"
100
  type="text"
101
  value="<?php echo (isset($bulk_adj_as_cart_label)) ? $bulk_adj_as_cart_label : ''; ?>"
v2/App/Views/Admin/Rules/Discounts/simple.php CHANGED
@@ -30,17 +30,18 @@ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
30
  placeholder="0.00" min="0" step="any" style="width: 100%;">
31
  <span class="wdr_desc_text"><?php _e('Value', WDR_TEXT_DOMAIN); ?></span>
32
  </div>
33
- </div>
 
34
  <div class="apply_discount_as_cart_section">
35
- <div class="page__toggle apply_as_cart_checkbox">
36
- <label class="toggle">
37
- <input class="toggle__input apply_fee_coupon_checkbox" type="checkbox"
38
  name="product_adjustments[apply_as_cart_rule]" <?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? 'checked' : '' ?> value="1">
39
- <span class="toggle__label"><span
40
- class="toggle__text toggle_tic"><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
41
  </label>
42
  </div>
43
- <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? '' : 'display: none;' ?>">
44
  <input name="product_adjustments[cart_label]"
45
  type="text"
46
  value="<?php echo (isset($product_adjustments->cart_label)) ? $product_adjustments->cart_label : ''; ?>"
30
  placeholder="0.00" min="0" step="any" style="width: 100%;">
31
  <span class="wdr_desc_text"><?php _e('Value', WDR_TEXT_DOMAIN); ?></span>
32
  </div>
33
+ </div><?php
34
+ $is_enabled_rtl = \Wdr\App\Helpers\Woocommerce::isRTLEnable();?>
35
  <div class="apply_discount_as_cart_section">
36
+ <div class="apply_as_cart_checkbox awdr_rtl_compatible <?php echo (!$is_enabled_rtl) ? 'page__toggle' : ''; ?>">
37
+ <label class="<?php echo (!$is_enabled_rtl) ? 'toggle' : ''; ?>">
38
+ <input class="<?php echo (!$is_enabled_rtl) ? 'toggle__input' : ''; ?> apply_fee_coupon_checkbox" type="checkbox"
39
  name="product_adjustments[apply_as_cart_rule]" <?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? 'checked' : '' ?> value="1">
40
+ <span class="<?php echo (!$is_enabled_rtl) ? 'toggle__label' : ''; ?>"><span
41
+ class="<?php echo (!$is_enabled_rtl) ? 'toggle__text toggle_tic' : ''; ?> "><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
42
  </label>
43
  </div>
44
+ <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? '' : 'display: none;' ?> <?php echo ($is_enabled_rtl) ? 'padding-top: 0px !important;' : ''; ?>">
45
  <input name="product_adjustments[cart_label]"
46
  type="text"
47
  value="<?php echo (isset($product_adjustments->cart_label)) ? $product_adjustments->cart_label : ''; ?>"
v2/App/Views/Admin/Rules/Manage.php CHANGED
@@ -55,28 +55,42 @@
55
  <div class="wdr-field-title" style="width: 45%">
56
  <input class="wdr-title" type="text" name="title" placeholder="Rule Title"
57
  value="<?php echo esc_attr($rule->getTitle()); ?>"><!--awdr-clear-both-->
58
- </div>
59
- <div class="page__toggle">
60
- <label class="toggle">
61
- <input class="toggle__input" type="checkbox"
62
- name="enabled" <?php echo ($rule->isEnabled()) ? 'checked' : '' ?> value="1">
63
- <span class="toggle__label"><span
64
- class="toggle__text"><?php _e('Enable?', WDR_TEXT_DOMAIN); ?></span></span>
65
- </label>
 
 
66
 
67
- </div>
68
- <div class="page__toggle">
69
- <label class="toggle">
70
- <input class="toggle__input" type="checkbox"
71
- name="exclusive" <?php echo ($rule->isExclusive()) ? 'checked' : '' ?> value="1">
72
- <span class="toggle__label"><span
73
- class="toggle__text"><?php _e('Apply this rule if matched and ignore all other rules', WDR_TEXT_DOMAIN); ?></span></span>
74
- </label>
75
 
76
- </div>
 
 
 
 
 
77
 
 
 
 
 
 
 
 
 
78
 
79
- <?php
80
  if (isset($rule_id) && !empty($rule_id)) { ?>
81
  <span class="wdr_desc_text awdr_valide_date_in_desc">
82
  <?php esc_html_e('#Rule ID: ', WDR_TEXT_DOMAIN); ?><b><?php echo $rule_id; ?></b>
@@ -170,7 +184,7 @@
170
  <?php
171
  //product adjustments
172
  $product_adjustments = ($rule->getProductAdjustments()) ? $rule->getProductAdjustments() : false;
173
- //echo "<pre>"; print_r($product_adjustments); echo "</pre>";
174
  //cart adjustments
175
  $cart_adjustment = $rule->getCartAdjustments();
176
  //Bulk adjustments
55
  <div class="wdr-field-title" style="width: 45%">
56
  <input class="wdr-title" type="text" name="title" placeholder="Rule Title"
57
  value="<?php echo esc_attr($rule->getTitle()); ?>"><!--awdr-clear-both-->
58
+ </div><?php
59
+ $is_rtl_enabled = \Wdr\App\Helpers\Woocommerce::isRTLEnable();
60
+ if(!$is_rtl_enabled){?>
61
+ <div class="page__toggle">
62
+ <label class="toggle">
63
+ <input class="toggle__input" type="checkbox"
64
+ name="enabled" <?php echo ($rule->isEnabled()) ? 'checked' : '' ?> value="1">
65
+ <span class="toggle__label"><span
66
+ class="toggle__text"><?php _e('Enable?', WDR_TEXT_DOMAIN); ?></span></span>
67
+ </label>
68
 
69
+ </div>
70
+ <div class="page__toggle">
71
+ <label class="toggle">
72
+ <input class="toggle__input" type="checkbox"
73
+ name="exclusive" <?php echo ($rule->isExclusive()) ? 'checked' : '' ?> value="1">
74
+ <span class="toggle__label"><span
75
+ class="toggle__text"><?php _e('Apply this rule if matched and ignore all other rules', WDR_TEXT_DOMAIN); ?></span></span>
76
+ </label>
77
 
78
+ </div><?php
79
+ }else{?>
80
+ <div class="awdr_normal_enable_check_box">
81
+ <label>
82
+ <input type="checkbox" name="enabled" class="awdr_enable_check_box_html" <?php echo ($rule->isEnabled()) ? 'checked' : '' ?> value="1"><?php _e('Enable?', WDR_TEXT_DOMAIN); ?>
83
+ </label>
84
 
85
+ </div>
86
+ <div class="awdr_normal_exclusive_check_box">
87
+ <label>
88
+ <input class="awdr_exclusive_check_box_html" type="checkbox"name="exclusive" <?php echo ($rule->isExclusive()) ? 'checked' : '' ?> value="1">
89
+ <?php _e('Apply this rule if matched and ignore all other rules', WDR_TEXT_DOMAIN); ?>
90
+ </label>
91
+ </div><?php
92
+ }
93
 
 
94
  if (isset($rule_id) && !empty($rule_id)) { ?>
95
  <span class="wdr_desc_text awdr_valide_date_in_desc">
96
  <?php esc_html_e('#Rule ID: ', WDR_TEXT_DOMAIN); ?><b><?php echo $rule_id; ?></b>
184
  <?php
185
  //product adjustments
186
  $product_adjustments = ($rule->getProductAdjustments()) ? $rule->getProductAdjustments() : false;
187
+
188
  //cart adjustments
189
  $cart_adjustment = $rule->getCartAdjustments();
190
  //Bulk adjustments
v2/App/Views/Templates/discount_table.php CHANGED
@@ -42,137 +42,141 @@ if (!empty($ranges) && !empty($woocommerce)) {
42
  <?php
43
  }
44
  } elseif ($ranges['layout']['type'] == 'default') {
45
- $tbl_title = $base::$config->getConfig('customize_bulk_table_title', 0);
46
- $tbl_discount = $base::$config->getConfig('customize_bulk_table_discount', 2);
47
- $tbl_range = $base::$config->getConfig('customize_bulk_table_range', 1);
 
 
 
48
 
49
- $tbl_title_text = $base::$config->getConfig('table_title_column_name', 'Title');
50
- $tbl_title_text = \Wdr\App\Helpers\Helper::getCleanHtml($tbl_title_text);
51
- $tbl_discount_text = $base::$config->getConfig('table_discount_column_name', 'Discount');
52
- $tbl_discount_text = \Wdr\App\Helpers\Helper::getCleanHtml($tbl_discount_text);
53
- $tbl_range_text = $base::$config->getConfig('table_range_column_name', 'Range');
54
- $tbl_range_text = \Wdr\App\Helpers\Helper::getCleanHtml($tbl_range_text);
55
 
56
- $table_sort_by_columns = array(
57
- 'tbl_title' => $tbl_title,
58
- 'tbl_discount' => $tbl_discount,
59
- 'tbl_range' => $tbl_range,
60
- );
61
- asort($table_sort_by_columns); ?>
62
- <table id="sort_customizable_table" class="wdr_bulk_table_msg sar-table">
63
- <thead class="wdr_bulk_table_thead">
64
- <tr class="wdr_bulk_table_tr wdr_bulk_table_thead" style="<?php echo (!$base::$config->getConfig('table_column_header', 1) ? 'display:none' : '')?>">
65
- <?php foreach ($table_sort_by_columns as $column => $order) {
66
- if ($column == "tbl_title") {
67
- ?>
68
- <th id="customize-bulk-table-title" class="wdr_bulk_table_td awdr-dragable"
69
- style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
70
- echo 'display:none';
71
- }else{
72
- echo((!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '');
73
- } ?>"><span><?php _e($tbl_title_text, WDR_TEXT_DOMAIN) ?></span>
74
- </th><?php
75
- } elseif ($column == "tbl_discount") {
76
- ?>
77
- <th id="customize-bulk-table-discount" class="wdr_bulk_table_td awdr-dragable"
78
- style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
79
- echo 'display:none';
80
- }else{
81
- echo((!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '');
82
- } ?>"><span><?php _e($tbl_discount_text, WDR_TEXT_DOMAIN) ?></span>
83
- </th><?php
84
- } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ?>
86
- <th id="customize-bulk-table-range" class="wdr_bulk_table_td awdr-dragable"
87
- style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
88
- echo 'display:none';
89
- }else{
90
- echo((!$base::$config->getConfig('table_range_column', 0)) ? 'display:none' : '');
91
- }?>"><span><?php _e($tbl_range_text, WDR_TEXT_DOMAIN) ?></span></th><?php
92
- }
93
- }?>
94
- </tr>
95
- </thead>
96
- <tbody><?php
97
- foreach ($ranges as $range) :
98
- $cart_discount_text = '';
99
- $discount_type_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
100
- if (empty($discount_type_value)){
101
- continue;
102
- }
103
- ?>
104
- <tr class="wdr_bulk_table_tr bulk_table_row">
105
- <?php
106
- /**
107
- * Discount value
108
- */
109
 
110
- if (isset($range['discount_method']) && $range['discount_method'] == 'cart') {
111
- $cart_discount_text = __(' (in cart)', WDR_TEXT_DOMAIN);
112
- }
113
- $discount_type = isset($range['discount_type']) ? $range['discount_type'] : 'flat';
114
- if ($discount_type == "flat") {
115
- $discount_value = $woocommerce->formatPrice($discount_type_value);
116
- $discount_value .= __(' flat', WDR_TEXT_DOMAIN);
117
- $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
118
- } elseif ($discount_type == "percentage") {
119
- $discount_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
120
- $discount_value .= '%';
121
- $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
122
- } else {
123
- $discount_value = $woocommerce->formatPrice($discount_type_value);
124
- }
125
 
126
- if (isset($range['discount_method']) && $range['discount_method'] != 'cart') {
127
- $discounted_price_for_customizer = $woocommerce->formatPrice(isset($range['discounted_price']) ? $range['discounted_price'] : 0);
128
- }else{
129
- $discounted_price_for_customizer = $discount_value;
130
- }
131
- /**
132
- * Discount Range
133
- */
134
- if (isset($range['discount_method']) && $range['discount_method'] == 'set') {
135
- $for_text = '';
136
- } else {
137
- $for_text = ' +';
138
- }
139
- if (isset($range['from']) && !empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
140
- $discount_range = $range['from'] . ' - ' . $range['to'];
141
- } elseif (isset($range['from']) && !empty($range['from']) && isset($range['to']) && empty($range['to'])) {
142
- $discount_range = $range['from']. $for_text;
143
- } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
144
- $discount_range = '0 - ' . $range['to'];
145
- } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && empty($range['to'])) {
146
- $discount_range = '';
147
- }?><?php
148
- /**
149
- * Table Data <td>'s
150
- */
151
- $j=1;
152
- foreach ($table_sort_by_columns as $column => $order) {
153
- if ($column == "tbl_title") {?>
154
  <td class="wdr_bulk_table_td wdr_bulk_title col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
155
  style="<?php echo (!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
156
  <?php echo isset($range['rule_title']) ? $range['rule_title'] : '-' ?>
157
- </td><?php
158
 
159
- } elseif ($column == "tbl_discount") {?>
160
- <td class="wdr_bulk_table_td wdr_bulk_table_discount col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
161
- style="<?php echo (!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
162
- <span class="wdr_table_discounted_value" style="<?php echo ( !$base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discount_value; ?></span>
163
- <span class="wdr_table_discounted_price" style="<?php echo ( $base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discounted_price_for_customizer; ?></span>
164
- </td><?php
165
- } else {?>
166
- <td class="wdr_bulk_table_td wdr_bulk_range col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
167
- style="<?php echo (!$base::$config->getConfig('table_range_column', 0) || isset($range['discount_method']) && in_array($range['discount_method'], array('product', 'cart'))) ? 'display:none':'';?>"><?php echo $discount_range ?></td><?php
168
- }
169
- $j++;
170
- }?>
171
- </tr>
172
- <?php
173
- endforeach;
174
- ?>
175
- </tbody>
176
- </table><?php
 
 
177
  }
178
  }
42
  <?php
43
  }
44
  } elseif ($ranges['layout']['type'] == 'default') {
45
+ if(isset($ranges['layout']['bulk_variant_table']) && $ranges['layout']['bulk_variant_table'] == "default_variant_empty"){?>
46
+ <div class="awdr-bulk-customizable-table"> </div><?php
47
+ }else{
48
+ $tbl_title = $base::$config->getConfig('customize_bulk_table_title', 0);
49
+ $tbl_discount = $base::$config->getConfig('customize_bulk_table_discount', 2);
50
+ $tbl_range = $base::$config->getConfig('customize_bulk_table_range', 1);
51
 
52
+ $tbl_title_text = $base::$config->getConfig('table_title_column_name', 'Title');
53
+ $tbl_discount_text = $base::$config->getConfig('table_discount_column_name', 'Discount');
54
+ $tbl_range_text = $base::$config->getConfig('table_range_column_name', 'Range');
 
 
 
55
 
56
+ $table_sort_by_columns = array(
57
+ 'tbl_title' => $tbl_title,
58
+ 'tbl_discount' => $tbl_discount,
59
+ 'tbl_range' => $tbl_range,
60
+ );
61
+ asort($table_sort_by_columns); ?>
62
+ <div class="awdr-bulk-customizable-table">
63
+ <table id="sort_customizable_table" class="wdr_bulk_table_msg sar-table">
64
+ <thead class="wdr_bulk_table_thead">
65
+ <tr class="wdr_bulk_table_tr wdr_bulk_table_thead" style="<?php echo (!$base::$config->getConfig('table_column_header', 1) ? 'display:none' : '')?>">
66
+ <?php foreach ($table_sort_by_columns as $column => $order) {
67
+ if ($column == "tbl_title") {
68
+ ?>
69
+ <th id="customize-bulk-table-title" class="wdr_bulk_table_td awdr-dragable"
70
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
71
+ echo 'display:none';
72
+ }else{
73
+ echo((!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '');
74
+ } ?>"><span><?php _e($tbl_title_text, WDR_TEXT_DOMAIN) ?></span>
75
+ </th><?php
76
+ } elseif ($column == "tbl_discount") {
77
+ ?>
78
+ <th id="customize-bulk-table-discount" class="wdr_bulk_table_td awdr-dragable"
79
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
80
+ echo 'display:none';
81
+ }else{
82
+ echo((!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '');
83
+ } ?>"><span><?php _e($tbl_discount_text, WDR_TEXT_DOMAIN) ?></span>
84
+ </th><?php
85
+ } else {
86
+ ?>
87
+ <th id="customize-bulk-table-range" class="wdr_bulk_table_td awdr-dragable"
88
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
89
+ echo 'display:none';
90
+ }else{
91
+ echo((!$base::$config->getConfig('table_range_column', 0)) ? 'display:none' : '');
92
+ }?>"><span><?php _e($tbl_range_text, WDR_TEXT_DOMAIN) ?></span></th><?php
93
+ }
94
+ }?>
95
+ </tr>
96
+ </thead>
97
+ <tbody><?php
98
+ foreach ($ranges as $range) :
99
+ $cart_discount_text = '';
100
+ $discount_type_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
101
+ //echo "<pre>"; print_r($discount_type_value); echo "</pre>";
102
+ if (!isset($range['discount_value'])){
103
+ continue;
104
+ }
105
  ?>
106
+ <tr class="wdr_bulk_table_tr bulk_table_row">
107
+ <?php
108
+ /**
109
+ * Discount value
110
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
+ if (isset($range['discount_method']) && $range['discount_method'] == 'cart') {
113
+ $cart_discount_text = __(' (in cart)', WDR_TEXT_DOMAIN);
114
+ }
115
+ $discount_type = isset($range['discount_type']) ? $range['discount_type'] : 'flat';
116
+ if ($discount_type == "flat") {
117
+ $discount_value = $woocommerce->formatPrice($discount_type_value);
118
+ $discount_value .= __(' flat', WDR_TEXT_DOMAIN);
119
+ $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
120
+ } elseif ($discount_type == "percentage") {
121
+ $discount_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
122
+ $discount_value .= '%';
123
+ $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
124
+ } else {
125
+ $discount_value = $woocommerce->formatPrice($discount_type_value);
126
+ }
127
 
128
+ if (isset($range['discount_method']) && $range['discount_method'] != 'cart') {
129
+ $discounted_price_for_customizer = $woocommerce->formatPrice(isset($range['discounted_price']) ? $range['discounted_price'] : 0);
130
+ }else{
131
+ $discounted_price_for_customizer = $discount_value;
132
+ }
133
+ /**
134
+ * Discount Range
135
+ */
136
+ if (isset($range['discount_method']) && $range['discount_method'] == 'set') {
137
+ $for_text = '';
138
+ } else {
139
+ $for_text = ' +';
140
+ }
141
+ if (isset($range['from']) && !empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
142
+ $discount_range = $range['from'] . ' - ' . $range['to'];
143
+ } elseif (isset($range['from']) && !empty($range['from']) && isset($range['to']) && empty($range['to'])) {
144
+ $discount_range = $range['from']. $for_text;
145
+ } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
146
+ $discount_range = '0 - ' . $range['to'];
147
+ } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && empty($range['to'])) {
148
+ $discount_range = '';
149
+ }?><?php
150
+ /**
151
+ * Table Data <td>'s
152
+ */
153
+ $j=1;
154
+ foreach ($table_sort_by_columns as $column => $order) {
155
+ if ($column == "tbl_title") {?>
156
  <td class="wdr_bulk_table_td wdr_bulk_title col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
157
  style="<?php echo (!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
158
  <?php echo isset($range['rule_title']) ? $range['rule_title'] : '-' ?>
159
+ </td><?php
160
 
161
+ } elseif ($column == "tbl_discount") {?>
162
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
163
+ style="<?php echo (!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
164
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discount_value; ?></span>
165
+ <span class="wdr_table_discounted_price" style="<?php echo ( $base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discounted_price_for_customizer; ?></span>
166
+ </td><?php
167
+ } else {?>
168
+ <td class="wdr_bulk_table_td wdr_bulk_range col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
169
+ style="<?php echo (!$base::$config->getConfig('table_range_column', 0) || isset($range['discount_method']) && in_array($range['discount_method'], array('product', 'cart'))) ? 'display:none':'';?>"><?php echo $discount_range ?></td><?php
170
+ }
171
+ $j++;
172
+ }?>
173
+ </tr>
174
+ <?php
175
+ endforeach;
176
+ ?>
177
+ </tbody>
178
+ </table>
179
+ </div><?php
180
+ }
181
  }
182
  }
v2/Assets/Css/admin_style.css CHANGED
@@ -1424,5 +1424,8 @@ div.wdr {
1424
  background-color: #f5de9c;
1425
  padding: 10px;
1426
  }
 
 
 
1427
 
1428
 
1424
  background-color: #f5de9c;
1425
  padding: 10px;
1426
  }
1427
+ .awdr_normal_enable_check_box, .awdr_normal_exclusive_check_box{
1428
+ padding: 10px;
1429
+ }
1430
 
1431
 
v2/Assets/Js/admin_script.js CHANGED
@@ -2478,9 +2478,9 @@ jQuery(document).ready(function ($) {
2478
 
2479
  $(document).on('change', '.apply_fee_coupon_checkbox', function () {
2480
  if ($(this).prop("checked") == true) {
2481
- $(this).parents('.page__toggle').siblings('.apply_fee_coupon_label').show();
2482
  } else {
2483
- $(this).parents('.page__toggle').siblings('.apply_fee_coupon_label').hide();
2484
  }
2485
  });
2486
 
2478
 
2479
  $(document).on('change', '.apply_fee_coupon_checkbox', function () {
2480
  if ($(this).prop("checked") == true) {
2481
+ $(this).parents('.awdr_rtl_compatible').siblings('.apply_fee_coupon_label').show();
2482
  } else {
2483
+ $(this).parents('.awdr_rtl_compatible').siblings('.apply_fee_coupon_label').hide();
2484
  }
2485
  });
2486
 
v2/Assets/Js/site_main.js CHANGED
@@ -22,7 +22,7 @@
22
  $(document).ready(function ($) {
23
  function init_events() {
24
  if (awdr_params.enable_update_price_with_qty == 'show_dynamically') {
25
- $(document).on('change', '[name="quantity"]', function (){
26
  var awdr_qty_object = $(this);
27
  setTimeout(function(){
28
  var $qty = awdr_qty_object.val();
@@ -82,9 +82,10 @@
82
  });
83
  }, 0);
84
  });
85
- $( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {
 
86
  $(this).closest('form').find('input[name="quantity"]').trigger('change');
87
- });
88
  }
89
 
90
  }
@@ -96,37 +97,58 @@
96
  }
97
  init_events();
98
 
99
- /*jQuery('table.variations tr td.value select').on('change', function () {
100
- setTimeout(function(){
101
- let variation_id = jQuery('[name="variation_id"]').val();
102
- if(variation_id != '' && variation_id != '0'){
103
- console.log(variation_id);
104
- var data = {
105
- action: 'wdr_ajax',
106
- method: 'get_variable_product_bulk_table',
107
- product_id: variation_id,
108
- };
109
- jQuery.ajax({
110
- url: awdr_params.ajaxurl,
111
- data: data,
112
- type: 'POST',
113
- success: function (response) {
114
- if (response.price_html) {
115
- $price_place.html(response.price_html)
116
- } else {
117
- if(response.original_price_html != undefined){
118
- $price_place.html(response.original_price_html)
119
  }
120
  }
121
- },
122
- error: function (response) {
123
- $price_place.html("")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
- });
126
  }
127
- }, 100);
128
- });*/
129
-
 
 
 
 
 
 
 
130
  });
131
  })(jQuery);
132
 
22
  $(document).ready(function ($) {
23
  function init_events() {
24
  if (awdr_params.enable_update_price_with_qty == 'show_dynamically') {
25
+ $(document).on('change', '[name="quantity"]', function (){``
26
  var awdr_qty_object = $(this);
27
  setTimeout(function(){
28
  var $qty = awdr_qty_object.val();
82
  });
83
  }, 0);
84
  });
85
+ /*Removed as it trigger multiple time - the change event */
86
+ /*$( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {
87
  $(this).closest('form').find('input[name="quantity"]').trigger('change');
88
+ });*/
89
  }
90
 
91
  }
97
  }
98
  init_events();
99
 
100
+ if (awdr_params.awdr_dynamic_bulk_table_status == "1") {
101
+ if(awdr_params.awdr_dynamic_bulk_table_off == "on"){
102
+ function awdr_load_variation_table(variation_id){
103
+ setTimeout(function(){
104
+ if(variation_id != '' && variation_id != '0'){
105
+ var data = {
106
+ action: 'wdr_ajax',
107
+ method: 'get_variable_product_bulk_table',
108
+ product_id: variation_id,
109
+ awdr_nonce: awdr_params.nonce,
110
+ };
111
+
112
+ let awdr_opacity = 'div.awdr-bulk-customizable-table';
113
+
114
+ if(awdr_params.awdr_opacity_to_bulk_table != undefined){
115
+ if(awdr_params.awdr_opacity_to_bulk_table != ""){
116
+ awdr_opacity = awdr_params.awdr_opacity_to_bulk_table;
 
 
 
117
  }
118
  }
119
+
120
+ $.ajax({
121
+ url: awdr_params.ajaxurl,
122
+ data: data,
123
+ type: 'POST',
124
+ beforeSend: function () {
125
+ $(awdr_opacity).css('opacity','0.5');
126
+ },
127
+ complete: function () {
128
+ $(awdr_opacity).css('opacity','1');
129
+ },
130
+ success: function (response) {
131
+ if (response.bulk_table) {
132
+ $('.awdr-bulk-customizable-table').html(response.bulk_table);
133
+ }
134
+ },
135
+ error: function (response) {
136
+ $('.awdr-bulk-customizable-table').html("")
137
+ }
138
+ });
139
  }
140
+ }, 100);
141
  }
142
+ $( ".single_variation_wrap" ).on( "hide_variation", function ( event ) {
143
+ let variation_id = $(this).closest('form').find('input[name="product_id"]').val();
144
+ awdr_load_variation_table(variation_id);
145
+ });
146
+ $( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {
147
+ let variation_id = variation.variation_id;
148
+ awdr_load_variation_table(variation_id);
149
+ });
150
+ }
151
+ }
152
  });
153
  })(jQuery);
154
 
woo-discount-rules.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Simple to complex discount rules for your WooCommerce store. Core package.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
- * Version: 2.2.2
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
@@ -21,7 +21,7 @@ if (!defined('ABSPATH')) {
21
  * Current version of our app
22
  */
23
  if (!defined('WDR_VERSION')) {
24
- define('WDR_VERSION', '2.2.2');
25
  }
26
 
27
  global $awdr_load_version;
@@ -38,6 +38,7 @@ if($awdr_load_version === null || empty($awdr_load_version)){
38
  if(empty($cart_rules)) $awdr_load_version = 'v2';
39
  }
40
  }
 
41
  }
42
 
43
  /**
5
  * Description: Simple to complex discount rules for your WooCommerce store. Core package.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 2.3.0
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
21
  * Current version of our app
22
  */
23
  if (!defined('WDR_VERSION')) {
24
+ define('WDR_VERSION', '2.3.0');
25
  }
26
 
27
  global $awdr_load_version;
38
  if(empty($cart_rules)) $awdr_load_version = 'v2';
39
  }
40
  }
41
+ update_option('advanced_woo_discount_rules_load_version', $awdr_load_version);
42
  }
43
 
44
  /**