最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to clear woocommerce checkout form after pageload

programmeradmin6浏览0评论

I am offering customers a repurchase on the order confirmed page. If they click the link they are sended directly to the checkout page. However, the form is then prefilled with the previous data. I would like to clear it, because the idea is one product(ticket) per person.

So far i have the following (and in the page source i can see the script is loaded):

function print_script() {

if (isset($_GET['extrapersoon']) && is_page(21560)){

    echo '<script>
window.addEventListener("load", function(){myFunction()};

function myFunction() {
  document.getElementsByClassName("woocommerce-checkout").reset(); 
}
</script>';
        }
  }
add_action('wp_print_scripts', 'print_script');

I tried other triggers too, such as window.load but no result yet.

Anyone?

发布评论

评论列表(0)

  1. 暂无评论