lukefred76
Technical User
Hi,
I'm working on a sml shop basket and need some help with a bit of code.
I have a simple form which allows users to select thedocs they wish to purchase and if they wnt to purchase a subscription service...
The above is fine. However when i prepare the items for the payment processor im running into difficulties.
The script below counts and prepares which "docs" the user wants to purchase ready for the payment processor, in this instance paypal...
My question is.. How can I add the subscription service so it becomes one of the items in the paypal cart?
Many thanks if anyone can help
blx
I'm working on a sml shop basket and need some help with a bit of code.
I have a simple form which allows users to select thedocs they wish to purchase and if they wnt to purchase a subscription service...
Code:
<form method="POST" name="selectionForm" action="<?php echo $PHP_SELF; ?>" >
<table class="pandp" width="80%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td width="447"><strong>Doc</strong></td>
<td width="30"><strong>Price</strong></td>
<td width="30"> </td>
</tr>
<tr>
<td>Doc 1</td>
<td>£15</td>
<td><input type="checkbox" name="ppres[doc1]" value="15.00"
<? if (( $_POST["check"] == 'send') && ($checkboxcount > 0)){
$search_array = ($_POST['ppres']);
if (array_key_exists('doc1', $search_array)) {
echo "checked='checked' ";
}
}
?>
/></td>
</tr>
<tr>
<td>doc2</td>
<td>£15</td>
<td><input type="checkbox" name="ppres[doc2]" value="15.00"
<? if (( $_POST["check"] == 'send') && ($checkboxcount > 0)){
$search_array = ($_POST['ppres']);
if (array_key_exists('doc2', $search_array)) {
echo "checked='checked' ";
}
}
?>
/></td>
</tr>
<tr>
<td>doc3</td>
<td>£15</td>
<td><input type="checkbox" name="ppres[doc3]" value="15.00"
<? if (( $_POST["check"] == 'send') && ($checkboxcount > 0)){
$search_array = ($_POST['ppres']);
if (array_key_exists('doc3', $search_array)) {
echo "checked='checked' ";
}
}
?>
/></td>
</tr>
</table>
<h1 style="margin-bottom:0;">Subscription Service</h1>
<div>
<table width="100%" border="0" cellpadding="4" cellspacing="2" class="pandp" bgcolor="#FFFF00">
<tr>
<td colspan="2">Annual subscription for just <strong>£49.99 per year</strong>.<br /><br />
</td>
</tr>
<tr>
<td class="contact">Yes please, subscribe me to this service:</td>
<td><input type="radio" style="border:0px;" name="subscription" value="yes" <? if ( $subscription == 'yes'){ echo "CHECKED"; }?>/></td>
</tr>
<tr>
<td class="contact">No thankyou: </td>
<td><input type="radio" style="border:0px;" name="subscription" value="no" <? if ( $subscription == 'no'){ echo "CHECKED"; }?>/></td>
</tr>
</table>
</div>
<br /><br />
<input style="margin-left:10px;" type="submit" name="add" value="Proceed">
<input type="hidden" name="check" value="send" />
</form>
The above is fine. However when i prepare the items for the payment processor im running into difficulties.
The script below counts and prepares which "docs" the user wants to purchase ready for the payment processor, in this instance paypal...
Code:
<form name="pay" action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL] method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="business" value="thecode">
<input type="hidden" name="country" value="GB">
<input type="hidden" name="invoice" value="<?= $invoice ?>">
<input type="hidden" name="first_name" value="<?= $name ?>">
<input type="hidden" name="address1" value="<?= $add1 ?>">
<input type="hidden" name="address2" value="<?= $add2 ?>">
<input type="hidden" name="city" value="<?= $add3 ?>">
<input type="hidden" name="zip" value="<?= $pcode ?>">
<input type="hidden" name="night_phone_b" value="<?= $let ?>">
<input type="hidden" name="email" value="<?= $laim1 ?>">
<?
$count = 1;
foreach ($_POST['ppres'] as $k => $v) {
echo "
<input type='hidden' name='item_name_{$count}' value='$k'>
<!--<input type='hidden' name='item_number_{$count}' value='{$count}'>-->
<input type='hidden' name='quantity_{$count}' value='1'>
<input type='hidden' name='amount_{$count}' value='15.00'>";
$count++;
}
?>
<input type="hidden" name="return" value="[URL unfurl="true"]http://mysite/success.php">[/URL]
<input type="hidden" name="cancel_return" value="[URL unfurl="true"]http://mysite/failure.php">[/URL]
<input style="margin-left:10px; margin-top:10px;" type="submit" name="pay" value="Proceed to Payment Pages">
</form>
My question is.. How can I add the subscription service so it becomes one of the items in the paypal cart?
Many thanks if anyone can help
blx