Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1433830

    Hello,
    we wouuld need to have a contact form on our product pages or pass the product url or permalink to a general contact form in a woocommerce installation. What we need is to have the product name / permalink / url in the email request.
    Example page:

    How can we do this?
    Thank you very much in advance
    Sincerely, Antonella

    #1433884

    Hi we need an urgent answer about our issue.
    Thanks
    Antonella

    #1433886

    Hi,

    There is nothing like that in the theme by default unfortunately, and implementing such a feature would be out of scope of theme support. You might be able to find a plugin or third party code which does the job for you though.

    Best regards,
    Rikard

    #1433887

    Thanks for your answer.
    Can you help us to find a way to insert a contact form in the product page like here:

    M70

    Now the botton erquest informatin open a new page (only solution we have found) but we loose the origin url of the contact.
    A solution would be to have the contact form in the product page but we did’t find a way.
    Can you give us a solution?
    Thanks in advace

    Antonella

    #1433962

    Hi,
    Try this javascript it will get url of the product page with the “more info” button when clicked and then redirect to your contact form page and add the original page url into a form field. For this example it adds the url into the message field, but you could add another field for the url so your visitors don’t write over the url.
    Try testing this javascript as is first by adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_script_to_add_product_url_into_contact_form() { ?>
      <script>
    document.addEventListener("DOMContentLoaded", function() {
        var button = document.getElementById('woocommerce-catalog_custom_button');
    
        if (!!button) {
        button.removeAttribute('href');
        button.onclick = function() {
            redirectToForm();
        };
        }
    
        function redirectToForm() {
            var currentPageUrl = window.location.href;
    
            window.location.href = 'https://www.officineditrevi.com/en/contact-us-products-info/?source=' + encodeURIComponent(currentPageUrl);
        }
    
        var urlParams = new URLSearchParams(window.location.search);
        var sourceUrl = urlParams.get('source');
    
        if (sourceUrl) {
            var formField = document.querySelector('.cf7-txt-c');
            formField.value = sourceUrl;
        }
    });
    </script>
      <?php
    }
    add_action( 'wp_footer', 'custom_script_to_add_product_url_into_contact_form', 99 );

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
    If it then works you can try adding another field to your form and adjust the code above.
    I tested this by injecting it in the browser and it worked for the test page and form that you linked above, I assume that all of the buttons on your product pages are the same.

    Best regards,
    Mike

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.