We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34108
    • 66 Posts
    Hi smiley I’m looking for a way to set up a product enquiry form which will dynamically pass the product details through the feedback form. I’ve had a look through the MODx Extras and the forums already but haven’t found anything unfortunately.

    Basically it would be just like a normal feedback form (using eform) but when the generated email gets to the client it would include specific product details.

    For example:

    1) Mrs Smith goes to the website and navigates to the page for the product she wants, let’s say 2L blueberry icecream.
    2) Mrs Smith fills in the enquiry form on that page.
    3) The business owner then gets an email which says something along the lines of:

    Customer name: Mrs Smith
    Product name: Icecream
    Flavor: Blueberry
    Size: 2L

    And the business owner would get a different email if Mrs Smith submitted an enquiry from the vanilla icecream product page.

    Any thoughts on the best way to go about doing this??

    Thanks heaps!
    Harmony
      • 34108
      • 66 Posts
      Thanks ganeshXL. I wasn’t able to get that method to work, for some reason any placeholders or variables I entered inside the actual feedback forms got wiped out by the time the email was sent.

      But I did find another method which is fine for simple product enquiries (detailed below). For more complex products this may work but I haven’t tried it myself yet - http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data

      1) Create a new chunk called “product-enquiry” and give it this code:

      [!eForm? &formid=`feedbackForm` &to=`[email protected] ` &tpl=`eProductEnquiryForm` &report=`eProductEnquiryReport` &thankyou=`eProductEnquiryThanks` &vericode=`1` &subject=`[*pagetitle*] - [(site_url)][*alias*]`!]


      2) This chunk should be called in a product page template, e.g.

      {{doctype}}
      {{meta}}
      {{stylesheets}}
      {{scripts}}
      </head>
      <body id="productpage" class="[*longtitle*]">
      <div id="wrapper">
      {{header}}
      {{main-nav}}
      {{search}}
      {{sub-nav}}
      <div id="content">
          <h1>[*pagetitle*]</h1>
          [*content*]
      </div>
      <img src="[*product-image*]" width="280" height="260" class="product-image" alt="" />
      {{product-enquiry}}
      </div>
      {{footer}}
      </body>
      </html>


      3) Create three new chunks:

      eProductEnquiryForm


      <h2>Enquire about this product - [*pagetitle*]</h2>
      <div class="validationmessage">
          [+validationmessage+]
      </div>
      <form method="post" action="[~[*id*]~]">
          <input type="hidden" name="formid" value="feedbackForm" />
          <p><label for="name">Your Name: *</label>
          <input type="text" name="name" maxlength="60" eform="Your Name:name:1" /></p>
          <p><label for="email">Your Email: *</label>
          <input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" /></p>
          <p><label accesskey="c" for="comments">Your Enquiry:</label>
          <textarea cols="40" rows="10" name="comments" eform="Comments:html:1"></textarea></p>
          <div class="verification">
              <p>Please enter the anti spam code below:</p>
              <img src="[+verimageurl+]" alt="verification code" />
              <div class="vericode">
                  <label accesskey="c" for="vericode">Enter code:</label>
                  <input type="text" name="vericode" size="20" />
              </div>
          </div>    
          <p class="clearfix"><input type="submit" name="submit" value="Submit my Enquiry" class="submit"></p>
      </form>


      eProductEnquiryThanks

      <div id="feedback">
      <p>Thank you for your product enquiry, we'll be in touch as soon as possible.</p>
      <p>Below is a copy of your enquiry:</p>
      <table>
      <tr><td width="120"><strong>Product Name:</strong></td><td>[*pagetitle*]</td></tr>
      <tr><td><strong>Link to Product:</strong></td><td><a href="[(site_url)][*alias*]">[(site_url)][*alias*]</a></td></tr>
      <tr><td><strong>Your Name:</strong></td><td>[+name+]</td></tr>
      <tr><td><strong>Your Email:</strong></td><td>[+email+]</td></tr>
      <tr valign="top"><td><strong>Your Enquiry:</strong></td><td>[+comments+]</td></tr>
      </table>
      </div>


      eProductEnquiryReport

      <p>This is a Product Enquiry sent by [+name+] at <a href="mailto:[+email+]?subject=RE:[+subject+]">[+email+]</a></p>
      <table>
      <tr valign="top"><td colspan="2"><hr /></td></tr>
      <tr valign="top"><td width="150"><b>Name:</b></td><td>[+name+]</td></tr>
      <tr valign="top"><td><b>Email:</b></td><td>[+email+]</td></tr>
      <tr valign="top"><td><b>Product:</b></td><td>[+subject+]</td></tr>
      <tr valign="top"><td><b>Product Enquiry:</b></td><td>[+comments+]</td></tr>
      <tr valign="top"><td colspan="2"><hr /></td></tr>
      </table>


      The email that comes through should look something like this:

      This is a Product Enquiry sent by asdfasdf at [email protected]
      ________________________________________
      Name: asdfasdf
      Email: [email protected]
      Product: Sample Product 2 - http://www.test.com/product1
      Product Enquiry: Sample enquiry text blah blah blah
      ________________________________________