Post by SirStepheno » Sun Sep 03, 2023 7:26 pm

I posted this issue on GitHub yesterday, but it was closed because it was a issue I found in the maintenance branch. So here my issue on this forum. A simple bug, do you guys experience the same?

What version of OpenCart are you reporting this for?
3.0.3.8 maintenance

Describe the bug
Just a small bug
When a error in the guest shipping occurs, only a part of the div turns red, the message shows up etc. When you correct the error, the error message disappears, but the red border (has-error class) doesn't disappear.

To Reproduce
Checkout as a guest, fill in a wrong value for one of the inputs in the shipping address section and correct it.

Expected behavior
The has-error class should disappear and the red accent around the input field should turn back to black.

Screenshots
Creating errors:
Image
Fixing errors:
Image

Additional context
I think I found the problem:

The guest shipping (guest_shipping.twig) has a extra div around the input:

Code: Select all

  <div class="form-group">
    <label class="col-sm-2 control-label" for="input-shipping-company">{{ entry_company }}</label>
    <div class="col-sm-10">
      <input type="text" name="company" value="{{ company }}" placeholder="{{ entry_company }}" id="input-shipping-company" class="form-control" />
    </div>
  </div>
While in checkout.twig the JS function turns the parent red (line 690):

// Highlight any found errors

Code: Select all

$('.text-danger').parent().addClass('has-error');
But this is only the col-sm-10 div, so it explains why the label doesn't turn red.
Later on, while not submitting the wrong information:

Code: Select all

$('.alert-dismissible, .text-danger').remove();
$('.form-group').removeClass('has-error');
So the warning text disappears, but the red color doesn't. Because the div form-group didn't have the class "has-error" but the child div has.

Simple fix

Just rewrite the JS line from above to:

Code: Select all

// Highlight any found errors
$('.text-danger').parent().parent().addClass('has-error');

Newbie

Posts

Joined
Sun Sep 03, 2023 7:17 pm

Post by ADD Creative » Mon Sep 04, 2023 4:19 pm

I can confirm I get the same issue when there is a error in the guest shipping form.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by SirStepheno » Mon Sep 04, 2023 9:44 pm

Thanks, made a pull request on GitHub, I will close this thread when it is accepted!

Newbie

Posts

Joined
Sun Sep 03, 2023 7:17 pm
Who is online

Users browsing this forum: No registered users and 5 guests