Finance form does not correctly submit chosen vehicle on form submit

Issue #30 new
Anojh Thayaparan created an issue

The selected vehicle does not get submitted with the form data. In the email vehicle of interest section displays "Not Decided" even though vehicle was picked when submitting form. Issue was present on both versions of the plugin below.

Car Demons Plugin: V1.7.6 & V1.7.7 Wordpress: V4.9.1

I suspect this is due to the name attribute not being applied to the vehicle input after selecting vehicle from search (this is what I observed in dev tools in chrome):

<input type="hidden" id="purchase_stock" value="694626">

I managed to fix this issue by recreating the input tag just before form submit by appending the following to car-demon-finance-form-js.php just after the pick_voi for loop:

//=====VOI Validation
            var no_car = 0;
            var no_location = 1;
            var selected_car = "";
            var voi_radios = document.getElementsByName("pick_voi");
            var voi_type = 1;
            var msg = "";
            for (var i = 0; i < voi_radios.length; i++) {
                if (voi_radios[i].type === 'radio' && voi_radios[i].checked) {
                    var voi_type = voi_radios[i].value;
                }
            }
//Fix begins here
            var p = document.getElementById("purchase_stock").value;
            $("#purchase_stock").remove();
            $("#show_voi").append('<input id="purchase_stock" name="purchase_stock" type="hidden" value="1">');
            document.getElementById("purchase_stock").setAttribute("value", p);

This has been working so far without any issues.

Comments (3)

  1. J. Chuck Mailen

    Thanks for reporting and identifying the issue. I'll make sure this gets resolved in the next public release. There should be a commit resolving this in about a week, along with a few other commits.

  2. Anojh Thayaparan reporter

    Thank You! I am still working on adapting the finance form to work for Canadian auto dealers as we discussed. I will create a pull request when I am done!

  3. Log in to comment