1

We like to show the website url, from the contactform in the email.

We use the shopify form template

 <div class="contactform"> 
    <input type="text" name="contact[name]" value="" size="22" tabindex="1" placeholder="Vor- und Nachname">
    <input type="email" name="contact[email]" value="" size="22" tabindex="1" required="required" placeholder="Mailadresse">
    <input type="text"  name="contact[firma]" value="" size="22" tabindex="1" placeholder="Firma">
    <input type="text"  name="contact[auflage]" value="" size="22" tabindex="1" placeholder="Auflage">  
    <textarea rows="8" cols="75"  name="contact[nachricht]" placeholder="Nachricht"></textarea>  
    <input type="submit" id="contactFormSubmit" value="Angebot anfragen" />            
    </div>
William Isted
  • 11,641
  • 4
  • 30
  • 45
Alexander H
  • 173
  • 6
  • 22
  • @john-conde Old thread, but Shopify does not allow parsing of PHP anywhere in their theme system, this question is valid as in Shopify the answer from http://stackoverflow.com/questions/6768793/get-the-full-url-in-php will not work. It will instead comment out the php tags and turn it into an inline comment. – William Isted Oct 25 '15 at 15:49

2 Answers2

2

create a hidden input

<input type="hidden" value="" id="hiddenurl" name="url"/>

and add javascript:

var a = document.getElementById('hiddenurl');
a.value = window.location.href;
baao
  • 71,625
  • 17
  • 143
  • 203
  • As of Oct 2015 this answer appears to be the most reliable. The next best option is a snippet that checks if the current template type i.e. `page`, `blog`, `collection`. But this misses out certain urls such as 404's, `homepage`, `/collections/all/` and others. https://github.com/joshuacc/Shopify-Snippets/blob/master/find-current-url.liquid – William Isted Oct 25 '15 at 15:55
0
<p><?= htmlentities( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ?></p>
Dai
  • 141,631
  • 28
  • 261
  • 374