I want to have the form on every page I list a product.
If the customer wants the product, or has questions about the product, they will ask me using the form that is located right below the product. So 100 product pages, each page with the same form below each product.
How can I know which product they are looking at?
How can I know on which page the form was filled in and sent?
Bobby's answer is good if you want the URL. If you want the page-id, then one wayI can think of is to have a field on the form that stored the page id and fill in its value with some simple jQuery when the page is rendered so it'll be saved when the form is submitted.
Something like this, assuming your field key is "xyz123".
jQuery(document).ready(function($){
var matches = document.body.className.match(/(^|\s)page-id-(\d+)(\s|$)/);
var pageid = matches[0]; // or use [2] if you want just the number
$("#field_xyz123").val(pageId);
});
Please login or Register to submit your answer
Are you manually creating products? What does the URL of a product page look like?
Yes I am manually creating prducts in wordpress.
The URL will look like https://www.swarez.co.uk/modern-art-paintings-for-sale/spectral-dynamics/
That's how he is doing it.
I want to do a similar thing.