View Full Version : Scripts for selling things online
I've been using NoChex to sell tickets to events like single's nights and salsa dancing in London. But very much in a manual way.
What I've found with events is people always want to waituntil the lastminute to book their place, which as an organiser is very stressful ... not knowing how many people to expect until a short time before the event is due to take place.
What I want to do is copy some of the ideas used by the discount airlines like easjet and use a sliding scale .. i.e. the earlier you book, the cheaper the price of the ticket.
Has anyone come across a script (perhaps in PHP) where for instance I want to charge people an average of £30 a ticket but could set it to start selling either the first 10 at £25, then next 10 at £28, etc or perhaps even more appealing to buy quickly ... to perhaps start tickets off at £25 and increase the price by 5 pence every hour until it reaches a maximum of say £35 a ticket.
I would then also want people emailed with a unique eticket to bring with them as proof of purchase.
Anyone ever come across anything like that? or website that use a similar method of selling because I'd like to see how they implement it.
BTW I think this will do for now .. I found this form on the forum and I'm thinking that to begin with I could try a form that starts at £28 per ticket and adds 50p per day to the price until it reaches a maximum of £35
Just trying to read up on how to get the "Amount" variable to increase by 50p per day - I assume there's like a now variable and I can use that to take the current date add the number of days difference between the day we start selling tickets and the day we cut off all sales, with a basic check to make sure the final value is £28 to £35.
I'd probabaly know how to do it in VBA, just need to read up on HTML unless someone knows it already
<html>
<head>
<title>Sample NOCHEX checkout</title>
</head>
<body bgcolor="white" color="black">
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<input type="hidden" name="email" value="you@email.com">
<input type="hidden" name="amount" value="28.00">
<input type="hidden" name="logo" value="http://your.server.name/your/logo.jpg">
<input type="hidden" name="returnurl" value="http://your.server.name/thanks.html">
<input type="hidden" name="cancelurl" value="http://your.server.name/cancel.html">
Customer Email: <input type="text" name="email_address_sender" size="20"><br>
<textarea rows="4" cols="60" name="description">Add Your Product Description:
</textarea><br>
<input type="submit" value="Pay by NOCHEX">
</form>
</body>
</html>
Someone did this PHP script for me .. certainly a really good first step in the right direction.
PHP Code:
<?php
// This is the closing date for your item, in ISO format (YYYY-MM-DD)
$end_date = "2005-01-24";
// Set this to be the final amount (highest price) you plan to sell the item for
$end_price = 35.00;
// Set this to be the daily price increment
$price_increment = 1.00;
?>
<html>
<head>
<title>Sample NOCHEX checkout</title>
</head>
<body bgcolor="white" color="black">
<?php
if (strtotime(date("Y-m-d"))>strtotime($end_date)) {
?>
<p>Sorry, this item has expired/sold out</p>
<?php
} else {
$now_price = sprintf("%01.2f", $end_price-($price_increment*ceil((strtotime($end_date)-time())/86400)));
?>
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<input type="hidden" name="email" value="you@email.com">
<input type="hidden" name="amount" value="<?php echo ($now_price); ?>">
<input type="hidden" name="logo" value="http://your.server.name/your/logo.jpg">
<input type="hidden" name="returnurl" value="http://your.server.name/thanks.html">
<input type="hidden" name="cancelurl" value="http://your.server.name/cancel.html">
Customer Email: <input type="text" name="email_address_sender" size="20"><br>
<textarea rows="4" cols="60" name="description">Add Your Product Description:
</textarea><br>
<input type="submit" value="Buy now for £<?php echo ($now_price); ?>">
</form>
<?php
}
?>
</body>
</html>
Makoto
22-01-2005, 01:17 PM
Try www.hotscripts.com tons of stuff there.
relentless
22-01-2005, 01:33 PM
I'm assuming you've got access to a MySQL database?
Shining on
22-01-2005, 02:27 PM
wow, never knew you coudl do those sorts of things with the internet.
I really must learn php!
I'm assuming you've got access to a MySQL database?
Sure do .. php and mysql go hand in hand!!
Does anyone here know PHP?
So fa I've done this .. see attachment but I'm not sure how to get the quantity thing to work
relentless
22-01-2005, 09:52 PM
I'll give you a hand if you want?
relentless
22-01-2005, 11:43 PM
Have a look at www.makesiteswork.com/test2.php (http://www.makessiteswork.com/test2.php) , just changed it around a little so you can calculate quantity. You could add a little JavaScript to validate the form and you're there (unless you want bulk order discounts).
The PHP Code is;
<html>
<head>
<title>Sample NOCHEX checkout</title>
<style type="text/css">
p, input, textarea {
font: 12px verdana;
color: #000000;
}
.button {
font: 11px verdana;
color: #993300;
background-color: #ccccc;
border: 1px solid #999999;
padding :3px
}
h1 {
font: 16px verdana bold;
color: #993300
}
.bg {
background:#993300;
}
.white{
color:white
}
</style>
</head>
<body>
<table width="60%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#666666">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<td align="center">
<?php
// check if its expired first
if (strtotime(date("Y-m-d"))>strtotime($end_date)) {
echo "<h1>Sorry! This product has expired</h1>";
}
else {
// This is the closing date for your item, in ISO format (YYYY-MM-DD)
$end_date = "2005-01-24";
// Set this to be the final amount (highest price) you plan to sell the item for
$end_price = 35.00;
// Set this to be the daily price increment
$price_increment = 1.00;
// Enter your product description
$description = "This is the product description";
// Enter your title
$title = "Product Title";
// get the now price
$now_price = sprintf("%01.2f", $end_price-($price_increment*ceil((strtotime($end_date)-time())/86400)));
// if the form has been posted calculate
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// multiply the quantity
$quantity = $_POST['quantity'];
$final_price = $quantity * $now_price
// break to form
?>
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<h1><? echo $title; ?></h1>
<p><? echo $description; ?></p>
</td>
</tr>
<tr>
<td class="bg">
<p class="white">You have ordered <strong><?php echo $quantity; ?></strong>
units/product which comes to a total of <strong>£<?php echo $final_price; ?></strong>.<br>
<strong> Please click continue to complete the purchase.</strong></p>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="email" value="you@email.com">
<input type="hidden" name="amount" value="<?php echo ($final_price); ?>">
<input type="hidden" name="email_address_sender" value="<?php echo ($_POST['email_address_sender']); ?>">
<input type="hidden" name="logo" value="http://your.server.name/your/logo.jpg">
<input type="hidden" name="returnurl" value="http://your.server.name/thanks.html">
<input type="hidden" name="cancelurl" value="http://your.server.name/cancel.html">
<input type="submit" class="button" value="Continue">
</td>
</tr>
</table>
</form>
<?
// else display original form
}
else {
?>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<table width="100%" border="0" cellspacing="1" cellpadding="6">
<tr>
<td colspan="2"> <h1><? echo $title; ?> (£<? echo $now_price; ?> per unit)</h1>
<p><? echo $description; ?></p>
</td>
</tr>
<tr class="bg">
<td width="150px"><p class="white">Customer Email: </p></td>
<td><input type="text" name="email_address_sender" size="20"></td>
</tr>
<tr class="bg">
<td><p class="white">Quantity: </p></td>
<td><input type="text" name="quantity" size="5"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" class="button" value="Click Here To Purchase"></td>
</tr>
</table>
</form>
<?php
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
I think you added an extra s onthe URL but
http://www.makesiteswork.com/test2.php
works and looks hot!!
Even the fonts look really good!! .. that's so cool!!
Did you code everything by hand or do you have some program that help make the colours and fonts?
I entered words more suitable to selling for tickets - and tried to create a variable for showing people if they don't buy their tickets today then tomorrow's price will be X amount ... but not quite sure how to do that :banghead:
Is it easy to switch from using end price to a beginning price instead? say tickets start at £28 and increase by 50p per day for however manys days until the sale end? :chin:
The only thing I can think of after that is to create a promotion code that either tells me who referred them or gives them a discount on their total.
For instance I said to people that came last time that the can have a £5 discount if they come again for this.... but wow - I'm just so impressed with what the script below does so far!!!
<html>
<head>
<title>Sample NOCHEX checkout</title>
<style type="text/css">
p, input, textarea {
font: 12px verdana;
color: #000000;
}
.button {
font: 11px verdana;
color: #993300;
background-color: #ccccc;
border: 1px solid #999999;
padding :3px
}
h1 {
font: 16px verdana bold;
color: #993300
}
.bg {
background:#993300;
}
.white{
color:white
}
</style>
</head>
<body>
<table width="60%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#666666">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<td align="center">
<?php
// check if its expired first
if (strtotime(date("Y-m-d"))>strtotime($end_date)) {
echo "<h1>Sorry! This product has expired</h1>";
}
else {
// This is the closing date for your item, in ISO format (YYYY-MM-DD)
$end_date = "2005-02-08";
// Set this to be the final amount (highest price) you plan to sell the item for
$end_price = 36.00;
// Set this to be the daily price increment
$price_increment = 0.50;
// Enter your product description
$description = "Valentines Dinner Tickets in Covent Garden";
// Enter your title
$title = "Dinner Tickets";
// get the now price
$now_price = sprintf("%01.2f", $end_price-($price_increment*ceil((strtotime($end_date)-time())/86400)));
$tomorrow_price = ($now_price+$price_increment);
// if the form has been posted calculate
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// multiply the quantity
$quantity = $_POST['quantity'];
$final_price = $quantity * $now_price
// break to form
?>
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<h1><? echo $title; ?></h1>
<p><? echo $description; ?></p>
</td>
</tr>
<tr>
<td class="bg">
<p class="white">You have ordered <strong><?php echo $quantity; ?></strong>
tickets which comes to a total of <strong>£<?php echo $final_price; ?></strong>.<br>
<strong> Please click continue to complete the purchase.</strong></p>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="email" value="email@email.com">
<input type="hidden" name="amount" value="<?php echo ($final_price); ?>">
<input type="hidden" name="email_address_sender" value="<?php echo ($_POST['email_address_sender']); ?>">
<input type="hidden" name="logo" value="http://your.server.name/your/logo.jpg">
<input type="hidden" name="returnurl" value="http://your.server.name/thanks.html">
<input type="hidden" name="cancelurl" value="http://your.server.name/cancel.html">
<input type="submit" class="button" value="Continue">
</td>
</tr>
</table>
</form>
<?
// else display original form
}
else {
?>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<table width="100%" border="0" cellspacing="1" cellpadding="6">
<tr>
<td colspan="2"> <h1><? echo $title; ?> (£<? echo $now_price; ?> per person)</h1>
<p><? echo $description; ?></p>
</td>
</tr>
<tr class="bg">
<td width="150px"><p class="white">Customer Email: </p></td>
<td><input type="text" name="email_address_sender" size="20"></td>
</tr>
<tr class="bg">
<td><p class="white">Quantity: </p></td>
<td><input type="text" name="quantity" size="5"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" class="button" value="Click Here To Purchase"></td>
</tr>
</table>
</form>
<?php
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
relentless
23-01-2005, 08:26 AM
I'll have a quick play around with it now for you. So I'll start the counter at £28 and keep incrementing till the closing date?
For keeping tabs on how many tickets sold and valid promotion codes etc you will need to use a mySQL Database, I can do add this for you if you want, won't take me a lot of time. PM me if you want to add more.
relentless
23-01-2005, 10:10 AM
Ok so now I've changed the code so that it increments the price by 50p per day, up until the end date that you specify in the script.
I've also added a promotion code variable, and a promotion discount variable to the code. So now if you type 'test' in the promotion code box you will recieve a 15% discount on the order.
Obviously the ideal way to assign promotion codes to returning customers is to generate one when they buy something the first time, store it in a database along with their details so when they come back the code they entered can be checked against the one stored and discount given if necessary. It can also be flagged that they have used their discount and are no longer eligible. This can be done quite easily.
I've added a little bit of javascript just so people dont go submitting blank forms :hyper:
Here's the code
<html>
<head>
<title>Sample NOCHEX checkout</title>
<style type="text/css">
p, input, textarea {
font: 12px verdana;
color: #000000;
}
.button {
font: 11px verdana;
color: #993300;
background-color: #ccccc;
border: 1px solid #999999;
padding :3px
}
h1 {
font: 16px verdana bold;
color: #993300
}
.bg {
background:#993300;
}
.white{
color:white
}
</style>
<script language="JavaScript" type="text/JavaScript">
function validate(f) {
if(f.email_address_sender.value=="") {
alert("Please enter a valid email address.");
return false;
}
if(f.quantity.value=="") {
alert("Please enter the quantity.");
return false;
}
return true;
}
</script>
</head>
<body>
<table width="60%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#666666">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<td align="center">
<?php
//Set the start date and end date, in ISO format (YYYY-MM-DD)
$start_date = "2005-01-20";
$end_date = "2005-01-27";
// check if its expired first
if (strtotime(date("Y-m-d"))>strtotime($end_date)) {
echo "<h1>Sorry! This product has expired</h1>";
}
else {
// Get todays date
$today_date = date("Y-m-d");
//Convert to seconds
$startDateBreak = explode("-",$start_date);
$startS = date("U", mktime('0','0','0',$startDateBreak[1], $startDateBreak[2], $startDateBreak[0]));
//convert to seconds
$endDateBreak = explode("-",$today_date);
$endS = date("U", mktime('0','0','0',$endDateBreak[1], $endDateBreak[2], $endDateBreak[0]));
//to convert seconds to days, divide seconds by 86400
$days_difference = ($endS - $startS)/86400;
// Set this to be the final amount (highest price) you plan to sell the item for
$start_price = 28.00;
// Set this to be the daily price increment
$price_increment = 0.50;
// Enter your product description
$description = "Valentines Dinner Tickets in Covent Garden";
// Enter your title
$title = "Dinner Tickets";
//Promotion code and % discount if applicable
$promotion_code = "test";
$promotion_discount = 15;
// get the now price
$now_price = sprintf("%01.2f", $start_price+($price_increment*$days_difference));
// get tommorrow price
$tomorrow_price = sprintf("%01.2f", $now_price+$price_increment);
// if the form has been posted calculate
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// grab the quantity
$quantity = $_POST['quantity'];
$customer_code = $_POST['customer_code'];
// See if there is a code, if there is add discount
if ((!empty($promotion_code)) && ($customer_code == $promotion_code)) {
$total = $quantity * $now_price;
$final_price = sprintf("%01.2f", ($total - (($total) * $promotion_discount / 100)));
}
else
{
// just the basic price
$final_price = sprintf("%01.2f", $quantity * $now_price);
}
// break to form
?>
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<h1><? echo $title; ?></h1>
<p><? echo $description; ?></p>
</td>
</tr>
<tr>
<td class="bg">
<p class="white">You have ordered <strong><?php echo $quantity; ?></strong>
units/product which comes to a total of <strong>£<?php echo $final_price; ?></strong>.<br />
<? if (!empty($total)) {?>
<em>You have made a saving of £<? echo sprintf("%01.2f", ((($total) * $promotion_discount / 100)));?>!</em><br /><br />
<? }?>
<strong> Please click continue to complete the purchase.</strong></p>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="email" value="you@email.com">
<input type="hidden" name="amount" value="<?php echo ($final_price); ?>">
<input type="hidden" name="email_address_sender" value="<?php echo ($_POST['email_address_sender']); ?>">
<input type="hidden" name="logo" value="http://your.server.name/your/logo.jpg">
<input type="hidden" name="returnurl" value="http://your.server.name/thanks.html">
<input type="hidden" name="cancelurl" value="http://your.server.name/cancel.html">
<input type="submit" class="button" value="Continue">
</td>
</tr>
</table>
</form>
<?
// else display original form
}
else {
?>
<form action="<?php echo $PHP_SELF; ?>" method="post" onsubmit="return validate(this);">
<table width="100%" border="0" cellspacing="1" cellpadding="6">
<tr>
<td colspan="2">
<h1><? echo $title; ?> (£<? echo $now_price; ?> per unit)</h1>
<p><? echo $description; ?><br />
<em>Tomorrow this product will cost £<? echo $tomorrow_price; ?></em></p>
</td>
</tr>
<tr class="bg">
<td width="150px"><p class="white">Customer Email: </p></td>
<td><input type="text" name="email_address_sender" size="20"></td>
</tr>
<tr class="bg">
<td><p class="white">Quantity: </p></td>
<td><input type="text" name="quantity" size="5"></td>
</tr>
<?
//If there has been a promotion code specified for this product
if (!empty($promotion_code)) {
?>
<tr class="bg">
<td><p class="white">Promotion Code: </p></td>
<td><input type="text" name="customer_code" size="5"></td>
</tr>
<?
}
?>
<tr>
<td colspan="2"><input type="submit" class="button" value="Click Here To Purchase"></td>
</tr>
</table>
</form>
<?php
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
wow that's way cool,
I tried it and it works really well.
I was also able to paste the code into frontpage and change the colours and add a check to make sure tickets is more then or equal to 1 and less then 6 to make sure people aren't ordering too many in one go.
NoChex does have one extra field that can be used to store additional info on the person, in the past I'd used it to store info on the names of any additional person coming if more then 1 ticket was purchased, but this is soo cool as it is for the simple task of encouraging people to book early!!
The only thing I'd want in the future may be something like on here
http://www.thesinglesolution.co.uk/events.php?id=167
where once a person books you can see a nickname for them, their age and profession - that's a pretty cool idea once you have lotsof people wanting to go but I guess maybe off putting when the list looks empty - I assume that can be just a simple text file database
But thanks for what you've done it's much appreicated :thumb:
relentless
23-01-2005, 02:34 PM
Hey it's no problem mate :)
Yeah you could do something like you've suggested real easy, but the best way would be to use MySQL (collect customer info for email marketing, news on latest events etc) rather than a flat text file. But like you said it's quite off putting if the list is empty! Best to do it once you have a regular user base.
You need anymore help let me know mate, I don't get a chance to use PHP much in work anymore, it's all ASP and .NET nowadays :(
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.