Changeset 2856876
- Timestamp:
- 01/30/2023 06:48:38 AM (3 years ago)
- Location:
- woo-discount-rules/trunk
- Files:
-
- 6 edited
-
readme.txt (modified) (2 diffs)
-
v2/App/Controllers/ManageDiscount.php (modified) (6 diffs)
-
v2/App/Models/DBTable.php (modified) (1 diff)
-
v2/Assets/Js/site_main.js (modified) (2 diffs)
-
v2/Assets/Js/site_main.min.js (modified) (1 diff)
-
woo-discount-rules.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-discount-rules/trunk/readme.txt
r2848944 r2856876 5 5 Requires at least: 4.4.1 6 6 Tested up to: 6.1 7 Stable tag: 2.5. 37 Stable tag: 2.5.4 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 337 337 == Changelog == 338 338 339 = 2.5.4 - 30/01/23 = 340 * Fix: Discount data is not stored for analytics when change language using WPML [Core]. 341 * Fix: Discount value is incorrect on coupon report for fixed discount type [Core]. 342 * Fix: Dynamic strikeout not working for variable product [Core]. 343 339 344 = 2.5.3 - 16/01/23 = 340 345 * Improvement: Show used coupon report [Core] -
woo-discount-rules/trunk/v2/App/Controllers/ManageDiscount.php
r2848944 r2856876 772 772 } 773 773 if (isset($discount_coupons[$rule_id])) { 774 $discount_coupons[$rule_id]['discount_value'] += $detail['discounted_price']; 774 if ($detail['apply_type'] != 'flat_in_subtotal') { 775 $discount_coupons[$rule_id]['discount_value'] += $detail['discounted_price']; 776 } 775 777 } else { 776 778 $discount_coupons[$rule_id] = [ … … 1033 1035 } 1034 1036 if (isset($discount_coupons[$rule_id])) { 1035 $discount_coupons[$rule_id]['discount_value'] += $detail['discounted_price']; 1037 if ($detail['apply_type'] != 'flat_in_subtotal') { 1038 $discount_coupons[$rule_id]['discount_value'] += $detail['discounted_price']; 1039 } 1036 1040 } else { 1037 1041 $discount_coupons[$rule_id] = [ … … 1608 1612 $product_discount_total += isset($details['saved_amount']) ? $details['saved_amount'] : 0; 1609 1613 $product_discount_total_with_tax += isset($details['saved_amount_based_on_tax_settings']) ? $details['saved_amount_based_on_tax_settings'] : 0; 1610 foreach ($details['applied_rules'] as $rule) { 1611 $simple_discount = $bulk_discount = $set_discount = $other_discount = 0; 1612 $discount = $rule['discount']; 1613 if ($discount['applied_in'] == 'product_level') { 1614 switch ($rule['type']) { 1615 case 'simple_discount': 1616 $simple_discount = $discount['discount_price'] * $quantity; 1617 break; 1618 case 'bulk_discount': 1619 $bulk_discount = $discount['discount_price'] * $quantity; 1620 break; 1621 case 'set_discount': 1622 $set_discount = $discount['discount_price'] * $discount['discount_quantity']; 1623 break; 1624 default: 1625 $other_discount = $discount['discount_price'] * $quantity; 1626 } 1627 $discount_price = $simple_discount + $bulk_discount + $set_discount + $other_discount; 1628 DBTable::saveOrderItemDiscounts($order_id, $item_id, $product_id, $initial_price, $discounted_price, $discount_price, $quantity, $rule['id'], $simple_discount, $bulk_discount, $set_discount, 0, $other_discount, null); 1614 if (isset($details['applied_rules']) && !empty($details['applied_rules'])) { 1615 foreach ($details['applied_rules'] as $rule) { 1616 $simple_discount = $bulk_discount = $set_discount = $other_discount = 0; 1617 $discount = $rule['discount']; 1618 if ($discount['applied_in'] == 'product_level') { 1619 switch ($rule['type']) { 1620 case 'simple_discount': 1621 $simple_discount = $discount['discount_price'] * $quantity; 1622 break; 1623 case 'bulk_discount': 1624 $bulk_discount = $discount['discount_price'] * $quantity; 1625 break; 1626 case 'set_discount': 1627 $set_discount = $discount['discount_price'] * $discount['discount_quantity']; 1628 break; 1629 default: 1630 $other_discount = $discount['discount_price'] * $quantity; 1631 } 1632 $discount_price = $simple_discount + $bulk_discount + $set_discount + $other_discount; 1633 DBTable::saveOrderItemDiscounts($order_id, $item_id, $product_id, $initial_price, $discounted_price, $discount_price, $quantity, $rule['id'], $simple_discount, $bulk_discount, $set_discount, 0, $other_discount, null); 1634 } 1629 1635 } 1630 1636 } … … 2041 2047 $details['discount_type'] = 'free_product'; 2042 2048 $details['discount_price'] = $product_price; 2043 $cart_item_discounts['total_discount_details'][$cart_item _key][$rule_id] = $details;2049 $cart_item_discounts['total_discount_details'][$cart_item['key']][$rule_id] = $details; 2044 2050 } 2045 2051 } … … 2051 2057 $details['discount_type'] = 'free_product'; 2052 2058 $details['discount_price'] = $product_price; 2053 $cart_item_discounts['total_discount_details'][$cart_item _key][$rule_id] = $details;2059 $cart_item_discounts['total_discount_details'][$cart_item['key']][$rule_id] = $details; 2054 2060 } 2055 2061 } … … 2064 2070 $item_discount_info['discounted_price_based_on_tax_settings'] = round($cart_item_discounts['discounted_price_with_tax'], 4); 2065 2071 $item_discount_info['is_free_product'] = isset($cart_item_discounts['is_free_product']) && $cart_item_discounts['is_free_product']; 2066 if (isset($cart_item_discounts['total_discount_details'][$cart_item _key])) { // for product adjustment2067 foreach ($cart_item_discounts['total_discount_details'][$cart_item _key] as $rule_id => $details) {2072 if (isset($cart_item_discounts['total_discount_details'][$cart_item['key']])) { // for product adjustment 2073 foreach ($cart_item_discounts['total_discount_details'][$cart_item['key']] as $rule_id => $details) { 2068 2074 if (!isset(self::$available_rules[$rule_id])) { continue; } 2069 2075 $rule = self::$available_rules[$rule_id]; -
woo-discount-rules/trunk/v2/App/Models/DBTable.php
r2848944 r2856876 138 138 } 139 139 } 140 $back_end_ajax_actions = array( );140 $back_end_ajax_actions = array('wdr_admin_statistics'); 141 141 $back_end_ajax_actions = apply_filters('advanced_woo_discount_rules_backend_end_ajax_actions', $back_end_ajax_actions); 142 142 if(!empty($back_end_ajax_actions) && is_array($back_end_ajax_actions)){ -
woo-discount-rules/trunk/v2/Assets/Js/site_main.js
r2848944 r2856876 51 51 var $price_place = ""; 52 52 var form = awdr_qty_object.closest("form"); 53 if (form.find('button[name="add-to-cart"] , input[name="add-to-cart"]').length) {54 $product_id = form.find('button[name="add-to-cart"] , input[name="add-to-cart"]').first().val();53 if (form.find('button[name="add-to-cart"]').length) { 54 $product_id = form.find('button[name="add-to-cart"]').first().val(); 55 55 var target = 'div.product p.price'; 56 56 if(awdr_params.custom_target_simple_product != undefined){ … … 69 69 } 70 70 $price_place = getWDRDPTarget(form, target, true); 71 } else if (form.find('input[name="add-to-cart"]').length) { 72 $product_id = form.find('input[name="add-to-cart"]').first().val(); 73 var target = 'div.product p.price'; 74 if(awdr_params.custom_target_simple_product != undefined){ 75 if(awdr_params.custom_target_simple_product != ""){ 76 target = awdr_params.custom_target_simple_product; 77 } 78 } 79 $price_place = getWDRDPTarget(form, target, false); 71 80 } 72 81 if(!$product_id || $product_id == 0){ -
woo-discount-rules/trunk/v2/Assets/Js/site_main.min.js
r2848944 r2856876 1 !function(t){function i(){t("body").trigger("update_checkout")}"1"==awdr_params.refresh_order_review&&(t(document).on("change",'input[name="payment_method"],input[name="billing_city"],input[name="billing_postcode"]',function(){i()}),t(document).on("blur",'input[name="billing_email"], select#billing_state',function(){i()})),t(document).ready(function(t){function i(){if("show_dynamically"==awdr_params.enable_update_price_with_qty){function i(i,e,a){let o="";return i.find(e).length?(o=i.find(e).first(),!0===a&&(i.find(e+" .price").length||o.html("<div class='price'></div>"),o=i.find(e+" .price").first())):(o=t(e).first(),!0===a&&(t(e+" .price").length||o.html("<div class='price'></div>"),o=t(e+" .price").first())),o}t(document).on("change",'[name="quantity"]',function(){var e=t(this);setTimeout(function(){var a=e.val(),o=0,r="",c=e.closest("form");if(c.find('button[name="add-to-cart"] , input[name="add-to-cart"]').length){o=c.find('button[name="add-to-cart"], input[name="add-to-cart"]').first().val();var n="div.product p.price";void 0!=awdr_params.custom_target_simple_product&&""!=awdr_params.custom_target_simple_product&&(n=awdr_params.custom_target_simple_product),r=i(c,n,!1)}else if(c.find('input[name="variation_id"]').length){o=c.find('input[name="variation_id"]').val();var n="div.product .woocommerce-variation-price";void 0!=awdr_params.custom_target_variable_product&&""!=awdr_params.custom_target_variable_product&&(n=awdr_params.custom_target_variable_product),r=i(c,n,!0)}if(!o||0==o){if(void 0!=awdr_params.custom_simple_product_id_selector&&""!=awdr_params.custom_simple_product_id_selector){o=t(awdr_params.custom_simple_product_id_selector).val();let l="div.product p.price";void 0!=awdr_params.custom_target_simple_product&&""!=awdr_params.custom_target_simple_product&&(l=awdr_params.custom_target_simple_product),r=i(c,l,!1)}if(void 0!=awdr_params.custom_variable_product_id_selector&&""!=awdr_params.custom_variable_product_id_selector){o=t(awdr_params.custom_variable_product_id_selector).val();let d="div.product .woocommerce-variation-price";void 0!=awdr_params.custom_target_variable_product&&""!=awdr_params.custom_target_variable_product&&(d=awdr_params.custom_target_variable_product),r=i(c,d,!0)}}if(o&&r&&0!=o){var u={action:"wdr_ajax",method:"get_price_html",product_id:o,qty:a,awdr_nonce:awdr_params.nonce};t.ajax({url:awdr_params.ajaxurl,data:u,type:"POST",success:function(t){t.price_html?r.html(t.price_html):void 0!=t.original_price_html&&r.html(t.original_price_html)},error:function(t){r.html("")}})}},0)})}}if(awdr_params.js_init_trigger&&t(document).on(awdr_params.js_init_trigger,function(){i()}),i(),"1"==awdr_params.awdr_dynamic_bulk_table_status&&"on"==awdr_params.awdr_dynamic_bulk_table_off){function e(i){setTimeout(function(){if(""!=i&&"0"!=i){var e={action:"wdr_ajax",method:"get_variable_product_bulk_table",product_id:i,awdr_nonce:awdr_params.nonce};let a="div.awdr-bulk-customizable-table";void 0!=awdr_params.awdr_opacity_to_bulk_table&&""!=awdr_params.awdr_opacity_to_bulk_table&&(a=awdr_params.awdr_opacity_to_bulk_table),t.ajax({url:awdr_params.ajaxurl,data:e,type:"POST",beforeSend:function(){t(a).css("opacity","0.5")},complete:function(){t(a).css("opacity","1")},success:function(i){i.bulk_table&&t(".awdr-bulk-customizable-table").html(i.bulk_table)},error:function(i){t(".awdr-bulk-customizable-table").html("")}})}},100)}t(".single_variation_wrap").on("hide_variation",function(i){e(t(this).closest("form").find('input[name="product_id"]').val())}),t(".single_variation_wrap").on("show_variation",function(t,i,a){let o=i.variation_id;(void 0==i.is_bundled||!0!=i.is_bundled)&&e(o)})}})}(jQuery);1 !function(t){function i(){t("body").trigger("update_checkout")}"1"==awdr_params.refresh_order_review&&(t(document).on("change",'input[name="payment_method"],input[name="billing_city"],input[name="billing_postcode"]',function(){i()}),t(document).on("blur",'input[name="billing_email"], select#billing_state',function(){i()})),t(document).ready(function(t){function i(){if("show_dynamically"==awdr_params.enable_update_price_with_qty){function i(i,e,a){let o="";return i.find(e).length?(o=i.find(e).first(),!0===a&&(i.find(e+" .price").length||o.html("<div class='price'></div>"),o=i.find(e+" .price").first())):(o=t(e).first(),!0===a&&(t(e+" .price").length||o.html("<div class='price'></div>"),o=t(e+" .price").first())),o}t(document).on("change",'[name="quantity"]',function(){var e=t(this);setTimeout(function(){var a=e.val(),o=0,r="",c=e.closest("form");if(c.find('button[name="add-to-cart"]').length){o=c.find('button[name="add-to-cart"]').first().val();var n="div.product p.price";void 0!=awdr_params.custom_target_simple_product&&""!=awdr_params.custom_target_simple_product&&(n=awdr_params.custom_target_simple_product),r=i(c,n,!1)}else if(c.find('input[name="variation_id"]').length){o=c.find('input[name="variation_id"]').val();var n="div.product .woocommerce-variation-price";void 0!=awdr_params.custom_target_variable_product&&""!=awdr_params.custom_target_variable_product&&(n=awdr_params.custom_target_variable_product),r=i(c,n,!0)}else if(c.find('input[name="add-to-cart"]').length){o=c.find('input[name="add-to-cart"]').first().val();var n="div.product p.price";void 0!=awdr_params.custom_target_simple_product&&""!=awdr_params.custom_target_simple_product&&(n=awdr_params.custom_target_simple_product),r=i(c,n,!1)}if(!o||0==o){if(void 0!=awdr_params.custom_simple_product_id_selector&&""!=awdr_params.custom_simple_product_id_selector){o=t(awdr_params.custom_simple_product_id_selector).val();let l="div.product p.price";void 0!=awdr_params.custom_target_simple_product&&""!=awdr_params.custom_target_simple_product&&(l=awdr_params.custom_target_simple_product),r=i(c,l,!1)}if(void 0!=awdr_params.custom_variable_product_id_selector&&""!=awdr_params.custom_variable_product_id_selector){o=t(awdr_params.custom_variable_product_id_selector).val();let d="div.product .woocommerce-variation-price";void 0!=awdr_params.custom_target_variable_product&&""!=awdr_params.custom_target_variable_product&&(d=awdr_params.custom_target_variable_product),r=i(c,d,!0)}}if(o&&r&&0!=o){var u={action:"wdr_ajax",method:"get_price_html",product_id:o,qty:a,awdr_nonce:awdr_params.nonce};t.ajax({url:awdr_params.ajaxurl,data:u,type:"POST",success:function(t){t.price_html?r.html(t.price_html):void 0!=t.original_price_html&&r.html(t.original_price_html)},error:function(t){r.html("")}})}},0)})}}if(awdr_params.js_init_trigger&&t(document).on(awdr_params.js_init_trigger,function(){i()}),i(),"1"==awdr_params.awdr_dynamic_bulk_table_status&&"on"==awdr_params.awdr_dynamic_bulk_table_off){function e(i){setTimeout(function(){if(""!=i&&"0"!=i){var e={action:"wdr_ajax",method:"get_variable_product_bulk_table",product_id:i,awdr_nonce:awdr_params.nonce};let a="div.awdr-bulk-customizable-table";void 0!=awdr_params.awdr_opacity_to_bulk_table&&""!=awdr_params.awdr_opacity_to_bulk_table&&(a=awdr_params.awdr_opacity_to_bulk_table),t.ajax({url:awdr_params.ajaxurl,data:e,type:"POST",beforeSend:function(){t(a).css("opacity","0.5")},complete:function(){t(a).css("opacity","1")},success:function(i){i.bulk_table&&t(".awdr-bulk-customizable-table").html(i.bulk_table)},error:function(i){t(".awdr-bulk-customizable-table").html("")}})}},100)}t(".single_variation_wrap").on("hide_variation",function(i){e(t(this).closest("form").find('input[name="product_id"]').val())}),t(".single_variation_wrap").on("show_variation",function(t,i,a){let o=i.variation_id;(void 0==i.is_bundled||!0!=i.is_bundled)&&e(o)})}})}(jQuery); -
woo-discount-rules/trunk/woo-discount-rules.php
r2848944 r2856876 6 6 * Author: Flycart 7 7 * Author URI: https://www.flycart.org 8 * Version: 2.5. 38 * Version: 2.5.4 9 9 * Slug: woo-discount-rules 10 10 * Text Domain: woo-discount-rules … … 22 22 */ 23 23 if (!defined('WDR_VERSION')) { 24 define('WDR_VERSION', '2.5. 3');24 define('WDR_VERSION', '2.5.4'); 25 25 } 26 26
Note: See TracChangeset
for help on using the changeset viewer.