1
I’m making a query terminal using Wordpress + Woocommerce, as I will use barcode reader and will have ZERO interaction with keyboard and mouse, I need the field automatically reload a few seconds after the query.
I tried every possible possibility, but I was unsuccessful, which got closer than I needed was with <META HTTP-EQUIV="refresh" CONTENT="10;">
, the problem is that the page refreshes every X seconds and often coincides with the time of reading the barcode. I need this refresh to be X seconds after the code is entered.
Below is the code I’m using and the link of the page with the query terminal.
To div
is custom search with a widget that queries the database of Woocommerce.
I had to use onKeypress
in the input
search to disable enter, because whenever the reader reads a code it executes enter and ends up loading the product page of the e-commerce, need to continue on the same page displaying the mini product query.
Code
<div class="ysm-search-widget ysm-search-widget-3 ysm-active"><form data-id="3" role="search" method="get" class="search-form" action="https://eabeer.com.br/"> <label> <span class="screen-reader-text">Código de Barras</span> <input type="search" class="search-field" placeholder="Código de Barras" value="" name="s" autocomplete="off" autofocus onKeypress="if (event.keyCode == 13) event.returnValue = false;"><button type="submit" class="search-submit"><span class="screen-reader-text">Search</span></button> </label><div class="smart-search-results" style="max-height: 400px; width: 1120px;"><div class="smart-search-suggestions" style="position: absolute; display: none; max-height: 400px; z-index: 9999; width: 1120px;"></div></div></form></div>
You have access to the code that makes the query, Ajax?
– Sam
Sam, access I have, but like I said, I’m using a custom search widget that generates a
shortcode
, which in this case is theysm-search-widget-3
. ?– Thilindha
Yes, because you can put a code that updates the page after the query.
– Sam
After consultation, put
setTimeout(function(){ location.reload(); }, 3000);
... this will refresh the page after 3 seconds– Sam
In this case, I have to put this code in the custom Search plugin file, correct? If that is it, gets complicated, because this plugin is used for E-commerce also.
– Thilindha
VC can put inside an if that checks the page where you want it updated, then will only reload on that specific page.
– Sam
Sam, I’ll pretend I know how to not be embarrassed, rs. If I’m not going to abuse it, how do I insert this IF? I was putting the code of the plugin here, but it was very extensive and confusing.
– Thilindha
That code you passed doesn’t show the process.
– Sam
I’m not sure, but it seems to me that the function with the answer of the research is this
onSearchComplete: function (query, suggestions) {
. You would have to test with a console.log("ok"). After you send the barcode and the search result appears, see if you run the console.log– Sam
Sam, I tried N options, but none runs console.log. ( Thank you so much for being willing to help.
– Thilindha