Author Topic: Checkout Form still performing default process even if code should disable it?  (Read 310 times)

mailblade

  • Jr. Member
  • **
  • Posts: 90
  • A beginner
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"

Code: [Select]
<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

  • Global Moderator
  • Full Member
  • *
  • Posts: 1806
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
???? 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.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)