Checkout Form still performing default process even if code should disable it?

Started by mailblade, March 25, 2018, 16:31:40 PM

Previous topic - Next topic

mailblade

VirtueMart: 3.2.4
Joomla: 3.6.4

I have made some modifications to my cart, but nothing major. Sometimes I have an issue where the user is not selecting the "SHIP TO" address. As I said I changed the layout a bit and now ONLY require the user to click a "SHIP TO" radio button to have their shipping address appear on the invoice and order details.

Unfortunately, some people forget to do so and this causes confusion.

I added this piece of code on file: "html\com_virtuemart\cart\default.php"


<script>
$(document).ready(function (){
$("#checkoutFormSubmit").click(function(e){
if (!$("input[name='shipto6']:checked").val()) {

alert("Please select the SHIP TO address by clicking on the radio button to the right of the BILL TO address");
        e.preventDefault();
return false;
}
})
});
</script>


The reason for "input[name='shipto6'", is that the shipto ID changes depending on the user logged in... So sometimes it's "shipto7" etc.

Now, when I click the Confirm button, it gives me the alert as stated, but it still performs the process of checking the item out. I tried preventDefault and "return false" but none of them worked.

Also, if I reload the cart again and check out another item, it still gives me alert even though the radio button is already checked.


Jörgen

???? I would say this should be VM default behaviour. Why are You not upgrading ? Both Joomla and VM versions are both known to have security issues.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.