ianhaney Posted February 9, 2015 Report Share Posted February 9, 2015 Hi I need some help or pointing in the right direction please I am using a booking script that I got off Google and works perfect but the client want's users to be able to book multiple classes at a time and then pay via PayPal in one go The current booking system I am using does not do that and just seeing if anyone could help me with it please I suppose in a way it will be bit like a shopping cart system where can add multiple products to the cart and then checkout up to now I have changed the form action to a continue page so they book a class and land on the continue page that has continue to book more classes and next to that a pay via PayPal button What I am struggling with is getting the multiple classes data stored and display all the classes selected on the continue page so they can see what classes they have selected so far and then have the option to book more or checkout and pay, in a way the continue page will be bit like a shopping cart page where it shows all the products that have been added to cart Below is the coding from the php file that allows users to choose the class time and fill out their info and book <?php session_start(); ?> <?php include "includes/dbconnect.php"; include "includes/config.php"; bw_do_action("bw_load"); $name = (!empty($_REQUEST["name"]))?strip_tags(str_replace("'","`",$_REQUEST["name"])):''; $phone = (!empty($_REQUEST["phone"]))?strip_tags(str_replace("'","`",$_REQUEST["phone"])):''; $email = (!empty($_REQUEST["email"]))?strip_tags(str_replace("'","`",$_REQUEST["email"])):''; $comments = (!empty($_REQUEST["comments"]))?strip_tags(str_replace("'","`",$_REQUEST["comments"])):''; $date = (!empty($_REQUEST["date"]))?strip_tags(str_replace("'","`",$_REQUEST["date"])):''; $captcha_sum = (!empty($_POST["captcha_sum"]))?strip_tags(str_replace("'","`",$_POST["captcha_sum"])):''; $captcha = (!empty($_POST["captcha"]))?strip_tags(str_replace("'","`",$_POST["captcha"])):''; $msg2 = (!empty($_REQUEST["msg2"]))?strip_tags(str_replace("'","`",$_REQUEST["msg2"])):''; $serviceID = (!empty($_REQUEST["serviceID"]))?strip_tags(str_replace("'","`",$_REQUEST["serviceID"])): getDefaultService(); $time = (!empty($_GET["time"]))?$_GET["time"]:''; $qty = (!empty($_REQUEST["qty"]))?strip_tags(str_replace("'","`",$_REQUEST["qty"])):1; $lb1 = (!empty($_REQUEST["lb1"]))?strip_tags(str_replace("'","`",$_REQUEST["lb1"])):''; $couponCode = (!empty($_GET["couponCode"]))?strip_tags(str_replace("'","`",$_GET["couponCode"])):''; $referrer = (!empty($_REQUEST["referrer"]))?strip_tags(str_replace("'","`",$_REQUEST["referrer"])):''; //print_r($time); $availability = getAvailableBookingsTable($date,$serviceID,$time,$qty,$couponCode); $int = getInterval($serviceID); //interval in minutes. ########################################################################################################################## # GET MAXIMUM AND MINIMUM INTERVALS FOR BOOKING AND JS VALIDATION $maximumBookings = getMaxBooking($serviceID); $minimumBookings = getMinBooking($serviceID); $bookingTexts = getBookingText($serviceID); $availebleSpaces = getServiceSettings($serviceID,'spaces_available'); $fee = getServiceSettings($serviceID,'spot_price'); ########################################################################################################################## if(!empty($lb1) && $lb1=="yes"){ $msg = "<div class='error_msg'> ".CAPTCHA_ERROR."; </div>"; } header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); ?> <?php include "includes/header.php";?> <?php include "includes/javascript.validation.php";?> <?php echo $msg; ?> <div class="internal_booking_form" id="resize"> <form name="ff1" enctype="multipart/form-data" method="post" action="booking.continue.php" onsubmit="return checkForm();"> <input type="hidden" value="<?php echo $date?>" name="date"> <input type="hidden" name="interval" value="<?php echo $int;?>" /> <input type="hidden" name="serviceID" value="<?php echo $serviceID;?>" /> <input type="hidden" name="discount" value="1" /> <input type="hidden" name="referrer" value="<?php echo $referrer;?>" /> <h2><?php echo _getDate(date(getOption("date_mode"),strtotime($date)))?> <?php echo AVAIL; ?></h2> <p class="desireTime"><?php echo SEL_TIME. " ". $bookingTexts[0]?> <?php echo $bookingTexts[1]?></p> <?php echo $availability?> <?php $num1 = rand(1,9); $num2 = rand(1,9); $sum = $num1 + $num2; ?> <div class="tab"><?php echo BOOKING_FORM;?></div> <div class="book_form"> <table width="650" class="booking_form"> <tr> <td align="left"> <span><?php echo YNAME;?>*: </span> <input type="text" name="name" id="name" value="<?php echo $name?>" onchange="checkFieldBack(this)"/> <span><?php echo BOOKING_FRM_PHONE;?>*: </span> <input type="text" name="phone" id="phone" value="<?php echo $phone?>" onchange="checkFieldBack(this)" onkeyup="noAlpha(this)"/> <span><?php echo BOOKING_FRM_EMAIL;?>*: </span> <input type="text" name="email" id="email" value="<?php echo $email?>" onchange="checkFieldBack(this);"/> </td> <td align="left" style="padding-left:10px"> <span><?php echo BOOKING_FRM_COMMENTS;?>: </span> <textarea name="comments" id="comments" cols="15" rows="5" onchange="checkFieldBack(this)"><?php echo $comments?></textarea> <div class="captchaCont"> <span><?php echo $num1." + ".$num2." = "?></span> <input type="text" name="captcha" id="captcha" value="" onchange="checkFieldBack(this);"/> </div><input type="image" src="images/reserve_btn.jpg" style="margin-top: 28px;" /> <input type="hidden" name="captcha_sum" value="<?php echo md5($sum);?>" /> <input type="text" name="email1" value="" class="hi"> </td> </tr> </table> </div> </form> <script> jQuery(function(){ jQuery("#qty").spinner({min:1,max:<?php echo ($availebleSpaces)?>}); }) </script> <?php include "includes/footer.php";?> Below is the coding on the continue page where they can either choose to book more classes or checkout and pay for the classes booked - this is the page I am struggling with as each time I book a second class, the first one selected gets overwritten, think someone said its cause the date is the same name and they said to try arrays but not 100% on that to be honest <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php session_start(); require_once("includes/config.php"); //Load the configurations bw_do_action("bw_load"); ################################################################################## # 1. GET ALL VARIABLES $name = (!empty($_POST["name"])) ? strip_tags(str_replace("'", "`", $_POST["name"])) : ''; $phone = (!empty($_POST["phone"])) ? strip_tags(str_replace("'", "`", $_POST["phone"])) : ''; $email = (!empty($_POST["email"])) ? strip_tags(str_replace("'", "`", $_POST["email"])) : ''; $email1 = (!empty($_POST["email1"])) ? strip_tags(str_replace("'", "`", $_POST["email1"])) : ''; $comments = (!empty($_POST["comments"])) ? strip_tags(str_replace("'", "`", $_POST["comments"])) : ''; $date = (!empty($_POST["date"])) ? strip_tags(str_replace("'", "`", $_POST["date"])) : ''; $interval = (!empty($_POST["interval"])) ? strip_tags(str_replace("'", "`", $_POST["interval"])) : ''; $time = (!empty($_POST["time"])) ? $_POST["time"] : ''; $captcha_sum = (!empty($_POST["captcha_sum"])) ? strip_tags(str_replace("'", "`", $_POST["captcha_sum"])) : ''; $captcha = (!empty($_POST["captcha"])) ? strip_tags(str_replace("'", "`", $_POST["captcha"])) : ''; $serviceID = (!empty($_REQUEST["serviceID"])) ? strip_tags(str_replace("'", "`", $_REQUEST["serviceID"])) : getDefaultService();; $qty = (!empty($_REQUEST["qty"])) ? intval($_REQUEST["qty"]) : 1; $couponCode = (!empty($_POST["couponCode"])) ? strip_tags(str_replace("'", "`", $_POST["couponCode"])) : ''; $referrer = (!empty($_REQUEST["referrer"]))?strip_tags(str_replace("'","`",$_REQUEST["referrer"])):''; // captcha check if (empty($captcha_sum) || empty($captcha) || md5($captcha) != $captcha_sum || !empty($email1)) { $queryString = array( "date" => $date, "lb1" => "yes", "serviceID" => $serviceID, "name" => $name, "phone" => $phone, "email" => $email, "comments" => $comments, "time" => $time, "qty" => $qty, "couponCode" => $couponCode, "referrer"=>$referrer ); $timeURL = http_build_query($time); if (getOption('use_popup') && $referrer!='calendar') { header("Location: index.php?" . http_build_query($queryString)); } else { header("Location: booking.php?" . http_build_query($queryString)); } exit(); } ## Check Qty allowed $error = checkQtyForTimeBooking($serviceID, $time, $date, $interval, $qty); if (!$error) { if (!empty($name) && !empty($phone) && !empty($email)) { if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) { $msg = "<div class='error_msg'>" . BEP_10 . "</div>"; } else { if (!empty($couponCode)) { $couponData = checkCoupon($couponCode, $serviceID); if ($couponData['responce']) { $couponValue = $couponData['value']; $couponType = $couponData['type']; } else { $msg = "<div class='error_msg'>" . $couponData['message'] . "</div>"; $couponCode = ''; } } ################################################################################## # 3. PREPARE BOOKING DATE/TIME # CREATE ORDER $price_per_spot = getPricePerSpot($serviceID); $status = getServiceSettings($serviceID, 'payment_method') == 'invoice' ? 1 : 2; $orderID = mysql_insert_id(); $serviceName = getService($serviceID, 'name'); if (!empty($orderID)) { $tempVar = ""; $bookingData = array(); $spots = 0; foreach ($time as $k => $v) { $dateFrom = date("Y-m-d H:i:s", strtotime($date . " +" . $v . " minutes")); $dateTo = date("Y-m-d H:i:s", strtotime($dateFrom . " +" . $interval . " minutes")); $res = mysql_query($q) or die("error! 002"); //needed for message $tempVar .= "<tr><td>" . getDateFormat($date) . "</td><td>" . date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateFrom)) . "</td><td>" . date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateTo)) . "</td><td>" . $qty . "</td></tr>"; $bookingData[] = array( 'date' => getDateFormat($date), 'timeFrom' => date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateFrom)), 'timeTo' => date((getTimeMode()) ? "g:i a" : "H:i", strtotime($dateTo)), 'qty' => $qty, 'dateFrom'=>$dateFrom, 'dateTo'=>$dateTo ); $spots++; } $paymentBookingIngo = get_payment_info($orderID); if ($price_per_spot == 0 || $paymentBookingIngo['amount']==0) { $infoForBooking = BEP_11; $subject = BEP_161 . " (#" . $orderID . ")!"; } else { $subject = BEP_16 . " (#" . $orderID . ")!"; $infoForBooking = do_payment($orderID, getServiceSettings($serviceID, "payment_method"),null,$referrer); } } } } } ?> <?php include "includes/header.php"?> <div id="index"> <h1><?php echo BEP_20;?></h1> <?php echo $msg;?> <?php echo !$error?getOrderSummery($orderID):"";?> <?php echo $infoForBooking?> <?php echo "<div class='more-button'>"; echo "<a href=\"http://". MAIN_URL."index.php?serviceID={$serviceID}\">".BEP_21."</a>"; echo "</div>"; ?> <?php include "includes/footer.php"?> Thank you in advance, would really appreciate any help or point me in the right direction, I know most of the coding on the continue page can come off as I copied the booking processing php coding Ian Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.