View Single Post
  #3  
Old 06-10-2005, 06:50 PM
 
dgstadtman dgstadtman is offline
 

Member
  
Join Date: Oct 2004
Location: Hilton Head Island, SC
Posts: 16
 

Default

Step 1: Create The Form

Here is a sample, with email, firstname, lastname, quantity desired, and 3 checkbox fields: (don't forget to change your form location!)

Code:
<form method="POST" action="http://www.yoursite.com/xcart/quoteform.php"> Fields marked &quot;<font color="#FF0000">*</font>&quot; are required <table width="330" border="0"> <tr> <td width="216">Your Email:* </td> <td width="148"><input type="text" name="EmailFrom" size="40"></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td>First Name:* </td> <td><input type="text" name="FirstName" size="40"></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td>Last Name:* </td> <td><input type="text" name="LastName" size="40"></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td>Quantity Desired:* </td> <td><input type="text" name="QuantityDesired" size="6"></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td align="left" valign="top">Colors:*</td> <td><input name="check1" type="checkbox" id="check1" value="Yes"> check1 <input name="check2" type="checkbox" id="check2" value="Yes"> check2 <input name="check3" type="checkbox" id="check3" value="Yes"> check3 </tr> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td><valign="right"><input type="submit" name="submit" value="Submit"></valign></td> </tr> </table></form>

Now Put that Form in your detailed description.

Next, we will create the php form handler...be sure to change all of te email addresses and website locations: (credits for this are in the code)

Code:
<?php // Website Contact Form Generator // http://www.tele-pro.co.uk/scripts/contact_form/ // This script is free to use as long as you // retain the credit link // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "you@email.com"; $Subject = "Quote Request"; $FirstName = Trim(stripslashes($_POST['FirstName'])); $LastName = Trim(stripslashes($_POST['LastName'])); $email = Trim(stripslashes($_POST['EmailFrom'])); $QuantityDesired = Trim(stripslashes($_POST['QuantityDesired'])); $check1= Trim(stripslashes($_POST['check1'])); $check2= Trim(stripslashes($_POST['check2'])); $check3= Trim(stripslashes($_POST['check3'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= " Online Quote Request"; $Body .= "\n"; $Body .= "\n"; $Body .= "\n"; $Body .= "First Name: "; $Body .= $FirstName; $Body .= "\n"; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $LastName; $Body .= "\n"; $Body .= "\n"; $Body .= "Email: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "\n"; $Body .= "Quantity Desired: "; $Body .= $QuantityDesired; $Body .= "\n"; $Body .= "\n"; $Body .= "CHECKBOXES: "; $Body .= "\n"; $Body .= "Check1: "; $Body .= $check1; $Body .= "\n"; $Body .= "Check2: "; $Body .= $check2; $Body .= "\n"; $Body .= "Check3: "; $Body .= $check3; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.yoursite.com/xcart/sent.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.yoursite.com/xcart/error.html\">"; } ?>

Now create your sent.html and error.html pages and upload them into the correct location.

Now we will disable the functions we don't want on the product page in customer/main/product.tpl. For example, since I don't want the entire quantity section, i would replace this-

Code:
<TABLE width="100%" cellpadding="0" cellspacing="0" border="0"> <TR><TD colspan="2"><FONT class="ProductDetailsTitle">{$lng.lbl_details}</FONT></TD></TR> <TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR> <TR><TD colspan="2"></TD></TR> {if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <TR><TD width="30%">{$lng.lbl_quantity}</TD><TD nowrap><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR> {/if} {if $product.weight ne "0.00"}<TR><TD width="30%">{$lng.lbl_weight}</TD><TD nowrap><SPAN id="product_weight">{$product.weight}</SPAN> {$config.General.weight_symbol}</TD></TR>{/if}

with this: (in line 2 I added {if $product.weight gt "0.05"} and I closed the code block with {/if})
Code:
<TABLE width="100%" cellpadding="0" cellspacing="0" border="0"> <TR><TD colspan="2">{if $product.weight gt "0.05"}<FONT class="ProductDetailsTitle">{$lng.lbl_details}</FONT></TD></TR> <TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR> <TR><TD colspan="2"></TD></TR> {if $config.Appearance.show_in_stock eq "Y" and $config.General.unlimited_products ne "Y" and $product.distribution eq ""} <TR><TD width="30%">{$lng.lbl_quantity}</TD><TD nowrap><SPAN id="product_avail_txt">{if $product.avail gt 0}{$product.avail}</SPAN>{else}{$lng.txt_no}{/if} {$lng.txt_items_available}</TD></TR> {/if} {if $product.weight ne "0.00"}<TR><TD width="30%">{$lng.lbl_weight}</TD><TD nowrap><SPAN id="product_weight">{$product.weight}</SPAN> {$config.General.weight_symbol}</TD></TR>{/if}{/if}

REMEMBER!!! Your product weight must be less than 0.05 for this to work. This way...your 'quote' product has a zero weight, taking out the things you don't want, while leaving the products with a weight of 0.05 or more to have all of the things that you take out with the 'if' statements.

Using the previous step, take out all of the other parts that you don't want to show for the 'quote' product.

Be sure to put an 'if' statement around the 'add to cart' button, or else you won't be able to use the submit button in your form.

NEXT- we are going to modify the category product listing page in customer/main/products.tpl so that we get a 'receive a quote now' message instead of 'Enter Your Price' since the price is $0. We will also make this link to the product details instead of adding it to your cart.

Open customer/main/products.tpl and change this:

Code:
{else} <FONT class="ProductPrice">{$lng.lbl_enter_your_price}</FONT> {/if}

to this:

Code:
{else} <FONT class="ProductPrice"><A href="product.php?productid={$products[product].productid}"> Get A Quote Now!</A></FONT> {/if}

I believe that that is it! I know that this will not work for everyone's application, but it works like a charm for me.

Yay...my first custom mod tutorial completed!

-Steveo
__________________
bracediscountstore.com

xgart gold 4.0.12
fancy categories 4.0.12
Reply With Quote