Search

Hello,

I am trying to build a very simple ordering form where people can pick from a hand full of products and also select a corresponding amount for each product.

<form id="order" method="post" action="" enctype="multipart/form-data">

  <table id="products">  
    <xsl:for-each select="/data/products/entry">
   <tr>
         <td>
           <xsl:value-of select="name"/>
         </td>
         <td>
           <label>Amount
             <input name="fields[{name}]" type="number" min="0" value="1" />
           </label>
       <input name="send-email[body]" value="fields[{name}]" type="hidden" />
     </td>
   </tr>
 </xsl:for-each>  
   </table>

   <label>Name
     <input name="fields[name]" type="text" />
   </label>

   <label>E-mail
     <input name="fields[e-mail]" type="text" />
   </label>

   <label>Address
     <input name="fields[address]" type="text" />
   </label>

   <input name="send-email[recipient]" value="tintin" type="hidden" />
   <input name="send-email[sender-email]" value="fields[e-mail]" type="hidden" />
   <input name="send-email[sender-name]" value="fields[name]" type="hidden" />  
   <input name="send-email[reply-to-email]" value="fields[e-mail]" type="hidden" />
   <input name="send-email[reply-to-name]" value="fields[name]" type="hidden" />
   <input name="send-email[subject]" value="An order has been placed" type="hidden" />
   <input name="action[order]" type="submit" value="Place order" />

</form>

The user data submitted through the form above should be converted to and sent as an email.

This works for the most part but how can I list the products the user ordered and their corresponding amounts?

I tried to solve this through a hidden form field inside the for-each loop. However, this will only send the name and amount of the last product in the list.

Thanks for any help!

Your email body input field is inside the foreach and each itteration is overriding the previous value in the foreach. Have you thought about using the storage field to build your array of options and grab that output to send as email? Nils and Michael-e put it together I believe.

Hi moonoo, thanks for your help.

Building an array sounds reasonable to me. But what exactly is the storage field?

Storage isn't a field, it's an extension that handles sessions differently, so it's use is through events.

My bad, wrong wordage.. Storage extension is what I meant.

OK, got it. This is the extension: storage

Will try this out, thanks for your help.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details