Plugin Directory

Changeset 3751456


Ignore:
Timestamp:
10/17/2026 06:11:25 AM (4 weeks ago)
Author:
addonsorg
Message:

Release new version

Location:
cf7-cost-calculator-price-calculation
Files:
30 added
3 edited

Legend:

Unmodified
Added
Removed
  • cf7-cost-calculator-price-calculation/trunk/frontend/js/cf7_calculator.js

    r3586889 r3751456  
    6565            var field_regexp = new RegExp('(' + reg.join("|") + ')(?!\\()');
    6666            $(".ctf7-total").each(function (index) {
    67                 var eq = $(this).data('formulas');
     67                // Use attr() instead of data(): jQuery's data() coerces numeric
     68                // strings like "40" to numbers, which breaks eq.replace below.
     69                var eq = $(this).attr('data-formulas');
    6870                var value_key_vl = false;
    69                 if (eq == "") {
     71                if (eq === undefined || eq === null || String(eq).trim() === "") {
    7072                    return;
    7173                }
     74                eq = String(eq);
    7275                eq = eq.replace(/ /g, '');
    7376                // Convert function names in formulas to lowercase to make them case-insensitive
    … …  
    264267                    $(this).autoNumeric();
    265268                    $(this).autoNumeric("set", total);
     269                    // Keep the default value in sync so a native form.reset()
     270                    // (CF7 calls it on load when wpcf7.cached is set) does not
     271                    // revert the field to the initial "0".
     272                    $(this).attr("value", $(this).val());
    266273                    $(this).parent().find('.cf7-calculated-name').autoNumeric();
    267274                    $(this).parent().find('.cf7-calculated-name').autoNumeric("set", total);
    … …  
    612619            $(".cf7-hide").closest('p').css('display', 'none');
    613620        }
     621        // Re-run calculations whenever CF7 resets the form: the native reset
     622        // event fires before values are restored, so defer to the next tick;
     623        // wpcf7reset fires after CF7 finishes its refill request.
     624        $(document).on("reset", "form.wpcf7-form", function () {
     625            setTimeout(function () {
     626                $.cf7_formulas();
     627            }, 0);
     628        });
     629        $(document).on("wpcf7reset", function () {
     630            $.cf7_formulas();
     631        });
    614632    })
    615633})(jQuery);
  • cf7-cost-calculator-price-calculation/trunk/index.php

    r3586889 r3751456  
    77 * Description: Create forms with field values calculated based in other form field values for contact form 7
    88 * Author: add-ons.org
    9  * Version: 10.4
     9 * Version: 10.5
    1010 * Author URI: https://add-ons.org/
    1111 * License: GPL v2 or later
  • cf7-cost-calculator-price-calculation/trunk/readme.txt

    r3646828 r3751456  
    44Requires at least: 2.5
    55Tested up to: 7.1
    6 Stable tag: 10.4
     6Stable tag: 10.5
    77Requires PHP: 5.2
    88License: GPLv2 or later
    … …  
    117117
    118118== Changelog ==
    119 = 10.4 =
     119= 10.5 =
     120Fixed: Comatible with Contact Form 7 version 6.2
     121
    120122Added: SWITCH function
    121123Example: [calculated name1 "switch(field1,1,10,2,20,3,30,40)"]
Note: See TracChangeset for help on using the changeset viewer.