Avoid double input field

When geolocalization is active and a form uses the GET method, the script adds an hidden field for the geolocalization hash v, without checking if it already exists. But wc_query_string_form_fields adds it already, if the parameter was present in the called url.
This commit is contained in:
pierrebuet 2018-05-18 21:39:19 +02:00
parent 09891e00cf
commit 3b18ac12d1
1 changed files with 2 additions and 1 deletions

View File

@ -56,8 +56,9 @@ jQuery( function( $ ) {
$( 'form' ).each( function() {
var $this = $( this );
var method = $this.attr( 'method' );
var hasField = $this.find('input[name="v"]').length > 0;
if ( method && 'get' === method.toLowerCase() ) {
if ( method && 'get' === method.toLowerCase() && !hasField ) {
$this.append( '<input type="hidden" name="v" value="' + wc_geolocation_params.hash + '" />' );
} else {
var href = $this.attr( 'action' );