Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
is there something like this available using couch? I've set it up for a fruit distributor with checkboxes on the form and the customers information. but the items available change monthly. No only checkout or cart needed just like a pre order system.


Thanks
Hi Tom,

Perhaps you'll find the following post useful
viewtopic.php?p=13629#p13629

It discusses creating a web form dynamically.
I think you can adapt it to suit your needs.

Does it help? Do let us know.

Thanks
KK wrote: Hi Tom,

Perhaps you'll find the following post useful
viewtopic.php?p=13629#p13629

It discusses creating a web form dynamically.
I think you can adapt it to suit your needs.

Does it help? Do let us know.

Thanks


i did see that, but I didn't find it clear how to set this up to an email to send to as well as a separate php file itself? Is there any tutorials or maybe a plugin or even an alternative method that would be applicable for me? thanks for the reply
Can you please let us know in detail what the use-case is like?

I mean, you are creating the checkboxes from the 'items' -
so what are these items? Are they already stored in the system as cloned-pages?
How will they change monthly?
Your client would be making changes to the form by herself so how should she ideally be doing this?
Finally, what should the email send out look like (what will it contain besides the selected items).

Please let us know.
Thanks.
the site that is being redone is online now, you can view the order page http://www.convenientcrops.com.au/order.html it will be of the same nature but at that stage there is an email php page that needs to be edited as well as the visible html page. so that the client gets the email saying which products have been selected. I basically need to make both the front end and back end(email the client receive when an order is made) to be edited by the client.

Hope that clears it up.
KK wrote: Can you please let us know in detail what the use-case is like?

I mean, you are creating the checkboxes from the 'items' -
so what are these items? Are they already stored in the system as cloned-pages?
How will they change monthly?
Your client would be making changes to the form by herself so how should she ideally be doing this?
Finally, what should the email send out look like (what will it contain besides the selected items).

Please let us know.
Thanks.

did this help you understand?
thanks for your time.
tom.
Hi Tom,

Yes, I got it. Thanks.

There are two distinct sections in your form -
a. A list of checkboxes showing available items for sale
b. The regular inputs of contact forms e.g. name. email etc.

The second part mentioned above is straightforward.
The first part, however, will require some thinking as we want the checkboxes to be dynamically populated from a repeatable region.

I'll explain one way of doing it (I'll post the full sample code at the end).
Please create a Couch template (say named 'orders.php') and define a repeatable region with a single textbox like this
Code: Select all
<cms:repeatable name="items" label="Autumn crops">
   <cms:editable name="desc" label="Description" type="text"/>
</cms:repeatable>

Register the template and fill out the repeatable regions with some sample data -
Untitled-1.png
Untitled-1.png (26.01 KiB) Viewed 3477 times


Now on the template, we'll create checkboxes for each of the items in the repeatable region.

If you had a look at our docs, you'll remember that the cms:input type='checkbox' tag accepts a parameter named 'opt_values' that makes it create multiple checkboxes e.g. the following code
<cms:input name='test' type='checkbox' opt_values='one || two || three' />
will create three checkboxes (the '||' places each checkbox on a separate line).

So, if we can create the '||' separated string where each part is a product that we have, we can easily create the checkboxes.

The following code does just that
Code: Select all
<cms:show_repeatable 'items' >
    <cms:set my_opt_values="<cms:concat my_opt_values '||' desc />"  scope='global'/>
</cms:show_repeatable>
The code above loops through our repeatable region and concats all the values in a variable named 'my_opt_values'.

Next we use the string we created above to create the checkboxes
Code: Select all
<cms:input type="checkbox" name="crops" label="Selected crops" opt_values=my_opt_values />


You should now see all products listed out as checkboxed items.

I am attaching the full sample code below.
Test it out as it to get a feel of how it works.
You'll need to use your own CSS to make it look good.
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Orders'>

    <cms:repeatable name="items" label="Autumn crops">
        <cms:editable name="desc" label="Description" type="text"/>
    </cms:repeatable>
   
</cms:template>


<cms:form anchor='0' method="post">

    <cms:if k_success>
        <cms:show k_success />
    </cms:if>
   
    <cms:if k_error>
        <cms:show k_error />
    </cms:if>
   
    <h1>Autumn Crops: </h1>
    <cms:show_repeatable 'items' >
        <cms:set my_opt_values="<cms:concat my_opt_values '||' desc />"  scope='global'/>
    </cms:show_repeatable>
   
    <cms:input type="checkbox" name="crops" label="Selected crops" opt_values=my_opt_values /><br/>
   
   
    <h1>Order:</h1>
    Full Name: <br />
    <cms:input name='name' label='Name' type="text" /> <br />
   
    Email: <br />
    <cms:input name='email' label='Email' type="text" validator='email' required='1' /> <br />
   
    Message: <br />
    <cms:input type="text" name='message' label='Message' class="name-email" placeholder="Extra Quantities" /> <br />
   
   
    <input type="submit" value="Submit"/>
   
</cms:form>

<?php COUCH::invoke(); ?>

When the form gets submitted, all the selected values are made available to us.
We can then take action using the submitted value e.g. email them etc.

In the sample form above, we are simply displaying the submitted values.
To email them, you can use the cms:send_mail tag e.g.
Code: Select all
<cms:if k_success >   
    <p>Thank you. We'll get back to you as soon as possible.</p>
   
    <cms:send_mail from=k_email_from to=k_email_to subject='Order form submission'>
        The following is an email sent by a visitor to your site:
        <cms:show k_success />
    </cms:send_mail>
</cms:if>


If you are not sure how forms work in Couch, i suggest you please see the following pages from our docs:
http://www.couchcms.com/docs/concepts/forms.html
http://www.couchcms.com/docs/tutorials/ ... -form.html
http://www.couchcms.com/docs/tags-refer ... _mail.html

Hope this helps.
7 posts Page 1 of 1
cron