SHOW A PAYPAL FORM ONLY IF CERTAIN CRITERIA ARE MET - Jan 31st, 2023
|
This recipe, which is part of a wholesale download ordering system, forces a customer to enter at least one email address before they can order downloads (see the recipe: "MODIFYING LINKLOK PAYPAL TO SEND DOWNLOAD EMAILS TO MULTIPLE RECIPIENTS").
It requires the Website Membership plugin and can be used without Linklok, but some minor modifications in the paypal button will be required.
Linklok is an inexpensive program that I've used for quite a while to handle PayPal transaction verification and supply secure links for downloads (or web pages).
If you should decide to purchase linklok, or any other Vibralogic programs, I'd appreciate your using my affiliate link:
http://www.shareasale.com/r.cfm?B=12671&U=520135&M=3826
If at least one email address is not entered, an error message is triggered. Once there’s at least one email address, the PayPal ordering link is shown.
The script creates a variable called $custom which contains the comma separated email addresses entered and appends that to the PayPal link. PayPal uses the custom variable too pass the email addresses trough with the completed transaction. Since PayPal will only pass a maximum of 256 characters in the custom variable, there are only 5 email address fields to insure that the limit is not exceeded.
At the top of the page insert this error message code:
<?php $errorsAndAlerts = "You Must Enter At Least 1 Email Address To Continue"?>
and the login redirect:
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
Then in the body:
<?php // determine if at least 1 email has been entered in the form before submitting and display error messages ?> <?php $showForm = 1 ?> <?php $showPayPalButton = 0 ?> <?php if(@$_REQUEST['submitForm'] && (@$_REQUEST['email_1'] || @$_REQUEST['email_2']|| @$_REQUEST['email_3'] || @$_REQUEST['email_4'] || @$_REQUEST['email_5'])):?> <?php $showForm = 0 ?> <?php $showPayPalButton = 1 ?> <?php endif ?> <?php if(@$_REQUEST['submitForm'] && (@!$_REQUEST['email_1'] && @!$_REQUEST['email_2'] && @!$_REQUEST['email_3'] && @!$_REQUEST['email_4'] && @!$_REQUEST['email_5'])):?> <div align="center" ><h2 style="color:#F00;"><?php echo $errorsAndAlerts; ?></h2></div> <?php endif ?> <?php if ( $showForm == 1 ) :?> <div align="center"> <h2>Thanks for choosing a 5 pack. Enter the email addresses of the 5 clients to whom you'd like to send download links, then click the "Pay and Send Links" Button. </h2> <form method="post" action=""> <?php // NOTE: if you use action="<?php echo $_SERVER['PHP_SELF'] ?>" the custom variable will not be passed correctly ?> <table border="0" cellspacing="0" cellpadding="2"> <tr> <td>Email 1</td> <td><input type="text" name="email_1" value="<?php echo htmlencode(@$_REQUEST['email_1']); ?>" size="50" /></td> </tr> <tr> <td>Email 2</td> <td><input type="text" name="email_2" value="<?php echo htmlencode(@$_REQUEST['email_2']); ?>" size="50" /></td> </tr> <tr> <td>Email 3</td> <td><input type="text" name="email_3" value="<?php echo htmlencode(@$_REQUEST['email_3']); ?>" size="50" /></td> </tr> <tr> <td>Email 4</td> <td><input type="text" name="email_4" value="<?php echo htmlencode(@$_REQUEST['email_4']); ?>" size="50" /></td> </tr> <tr> <td>Email 5</td> <td><input type="text" name="email_5" value="<?php echo htmlencode(@$_REQUEST['email_5']); ?>" size="50" /></td> </tr> <tr> <td colspan="2" align="center"><input class="button" type="submit" name="submitForm" value="Pay and Send Links >>" /></td> </tr> </table> </form> </div> <?php endif ?>
<?php if ( @$_REQUEST['email_1']) :?> <?php $email_1 = @$_REQUEST['email_1']. ', ' ?> <?php endif ?> <?php if ( @$_REQUEST['email_2']) :?> <?php $email_2 = @$_REQUEST['email_2']. ', ' ?> <?php endif ?> <?php if ( @$_REQUEST['email_3']) :?> <?php $email_3 = @$_REQUEST['email_3']. ', ' ?> <?php endif ?> <?php if ( @$_REQUEST['email_4']) :?> <?php $email_4 = @$_REQUEST['email_4']. ', ' ?> <?php endif ?> <?php if ( @$_REQUEST['email_5']) :?> <?php $email_5 = @$_REQUEST['email_5']. ', ' ?> <?php endif ?> <?php $custom = @$email_1 .@$email_2 .@$email_3 .@$email_4 .@$email_5 ?>
<?php $custom = rtrim($custom,', '); // remove trailing comma ?> <?php $custom=urlencode($custom); // urlencode the output ?> <br /> <br /> <br /> <br /> <br /> <?php if ($showPayPalButton == 1 ) :?> <table align="center" width="40%" border="0" cellpadding="5"> <tr> <td colspan="3" align="center"><h2>Click the "Buy Now" button to pay for your 5 pack through PayPal.</h2> (PayPal Also Accepts Credit Cards) You'll have a chance to review your order before it's final. </td> </tr> <tr> <td valign="top"><div align="center"> <img src="http://www.your_site.com/images/paypal-logo.jpg" alt="" height="99" width="100" border="0" /></div></td> <td valign="top"> <div align="center"><a class="special" href="https://www.paypal.com/cgi-bin/webscr?amount=24.95 &item_number=5-pack &item_name=Five Pack &business=payments@your_site.com &no_note=1 &cpp_header_image=http://your_site.com/images/pp_header.png&currency_code=USD &lc=US&add=1&cmd=_cart &no_shipping=0&return=http://www.your_site.com/linklokipnret.php &notify_url=http://www.your_site.com/linklokipn.php &bn value=PP-ShopCartBF &custom1=<?php echo $custom?>"> <img src="http://www.your_site.com/images/buy_now_button.gif" /></a>
</div> </td> <td valign="top"><img src="http://www.your_site.com/images/paypal-logo.jpg" alt="" height="99" width="100" border="0" /> </td> </tr> </table> <?php endif ?>
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.