Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author pbosakov

    (@pbosakov)

    Hell, thank you for your interest in this plugin.

    Currency conversion is a useful feature and I will consider a direct implementation for a future release.

    In the meantime, you can use the “wpcf7calculate” jQuery event which is triggered on the form after calculation. This means that you can code your own Javascript function and place it somewhere on your site to generate links and perform further operations.

    Here is an example:

    <script type="text/javascript">
    jQuery(function($) {
          $('form').on('wpcf7calculate', function() { 
            var dollars = jQuery('input[name=total]').val();
            var euro = currencyConvert(dollars, 'USD', 'EUR');
            if (euro === false) {
                alert('Currency conversion failed');
            } else {
                alert(dollars + ' dollars = ' + euro.toFixed(2) + ' euro');
            }
            return;
        });
    });
    
    function currencyConvert(amount, from, to) {
        var result = '';
        var convertUrl = "https://free.currencyconverterapi.com/api/v3/convert?q=" + from + "_" + to + "&compact=ultra";
        var rate = false;
        jQuery.ajax({
            url: convertUrl,
            async: false,
            type: "GET",
            dataType: "json",
            success: function (data) {
                rate = data[from + "_" + to];
            }
        });
        return rate ? parseFloat(amount) * parseFloat(rate) : false;
    }
    </script>
    Plugin Author pbosakov

    (@pbosakov)

    I believe my post above answers your question and resolves your issue. If you think this plugin is a good fit for what you want to achieve, please consider trying it out on your website and leaving a review. Thanks!

    Thread Starter ramonjosegn

    (@ramonjosegn)

    Thanks for support and for the code, great

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can I send the variable Total to Google variable?’ is closed to new replies.