woocommerce上的Javascript窗口位置“提交”按钮

时间:2018-11-21 12:34:07

标签: javascript html woocommerce

我需要在woocommerce的“谢谢”页面中添加一些自定义参数。通常情况下,我通常将以下代码添加到我的“提交”按钮中。

onclick="window.location.href = 'https://mywebsite.com/thank-you?companyName=' + encodeURIComponent(document.getElementById('handelsnaam').value) + '&CPLastname=' + encodeURIComponent(document.getElementById('achternaam').value) + '&EXTRAOPMERKING=' + encodeURIComponent(document.getElementById('opmerking').value)

如何在woocommerce中获得相同的结果。我想在woocommerce中将这些参数添加到我的URL中。

1 个答案:

答案 0 :(得分:0)

将以下代码添加到functions.php中可以帮助我实现所需的功能。

/// This would output 'http://blog.example.com/2009/04/16/?hello=world'
echo esc_url( add_query_arg( 'hello', 'world', 'http://blog.example.com/2009/04/16/' ) );