OK, I simplified the procedure (hopefully). This is the order page and when SUBMIT is hit, the user is directed to the appropriate payment page. However I ALSO need the filled out form sent to my email address. Any ideas?
Order Form
sneedbreedley wrote OK, I simplified the procedure (hopefully). This is the order page and when SUBMIT is hit, the user is directed to the appropriate payment page. However I ALSO need the filled out form sent to my email address. Any ideas? Order Form |
The only way to do that is to use a very simple cart. You only need the form sent to you because at the moment you have no way of finding out what combination of products have been selected by the user, that is the job of paypal and paypal will send you a confirmation email detailing the product/s selected AFTER a payment has been made.
Below is the form code you need. Each product is stored in a php array - name="products[]" - see below, if selected.
<form name="products" action="product_process.php" method="post">
<input type="checkbox" value="Window Sticker" id="window_sticker" name="products[]"><label for="window_sticker">Window Sticker</label>
<br>
<input type="checkbox" value="Car Shipper" id="car_shipper" name="products[]"><label for="car_shipper">Car Shipper</label>
<br>
<input type="checkbox" value="Dealer Invoice" id="dealer_invoice" name="products[]"><label for="dealer_invoice">Dealer Invoice</label>
<br>
<input type="checkbox" value="Retail Order Form" id="retail_order_form" name="products[]"><label for="retail_order_form">Retail Order Form </label>
<br>
<input type="checkbox" value="Tank Sticker (1967-1973 Corvette Only)" id="tank_sticker" name="products[]"><label for="tank_sticker"> Tank Sticker (1967-1973 Corvette Only) </label>
<br>
<input type="submit" name="submit" value="Submit">
</form>
Below is the php code that gets the chosen products from the form checkboxes. Insert this in a file named 'product_process.php' as that is the file name the form points to. Style it visually to suit what you need.
The products chosen are appended to the $products variable. We count the number of products chosen and append that to the variable $numberOfProducts - this is used to determine what the value should be for the paypal amount field.
We then loop through the selected products and assign the values to the appropriate paypal hidden fields. You need to use your paypal business email address in place of YOUR-PAYPAL-EMAIL-ADDRESS and your countries currency code in place of YOUR-COUNTRY-CURRENCY-CODE
This negates the necessity to have 5 seperate pages with 5 different paypal buttons.
TEST THIS FUNCTIONALITY OUT BEFORE DEPOLYING IT LIVE TO MAKE SURE IT DOES WHAT YOU NEED.
<?php
$products = $_POST['products'];
$numberOfProducts = count($products);
echo "<h3>Selected Products $numberOfProducts</h3>";
echo "<ul>";
foreach($products as $selectedProducts) {
echo "<li>$selectedProducts</li>";
}
echo "</ul>";
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="YOUR-PAYPAL-EMAIL-ADDRESS">
<input type="hidden" name="currency_code" value="YOUR-COUNTRY-CURRENCY-CODE">
<?php
$ii=1;
foreach($products as $item) {
echo "
<input type='hidden' name='quantity_$ii' value='1' >
<input type='hidden' name='item_name_$ii' value='{$item}' >";
?>
<?php if($numberOfProducts === 1) {
echo "<input type='hidden' name='amount_$ii' value='95' >";
}
elseif($numberOfProducts === 2) {
echo "<input type='hidden' name='amount_$ii' value='90' >";
}
elseif($numberOfProducts === 3) {
echo "<input type='hidden' name='amount_$ii' value='75' >";
}
elseif($numberOfProducts === 4) {
echo "<input type='hidden' name='amount_$ii' value='75' >";
}
elseif($numberOfProducts === 5) {
echo "<input type='hidden' name='amount_$ii' value='75' >";
}
?>
<?php
$ii++;
}
?>
<input type="submit" id="check_out" value="CHECK OUT">
</form>