Jump to content

booking php help


ianhaney50

Recommended Posts

Hi

 

I have just had a request from a current customer who has a booking system in their website, it is for classes and people book online and pay via PayPal, what they want is if a class is on Wednesday and Thursday, they want the wednesday class to be £10.00 but the Thursday class to be £7.50

 

at the moment the class cost is set in the admin side of the booking system and does not allow multiple costs for classes on different days

 

I am wondering if that can be done in PHP at all

 

Been trying to have a go myself with the following

<?php if ($serviceID == 5) || $date == THURSDAY { $fee = getServiceSettings($serviceID,'£7.50') } else { $fee = getServiceSettings($serviceID,'£10.00')} { ?>

I know the first bit works by if it is serviceID of 5, it displays notes for the user to see when booking so thought could do something similar

 

below is the link to the booking.php file

 

http://pastebin.com/64tM5mBt

 

below is the link to the booking.process.php file

 

http://pastebin.com/2X87rezy

Link to comment
Share on other sites

I'd have thought the best place to store the price data is in the database

       +----------------+                                +---------------+                                                
       | booking        |                                | course        |                                                
       +----------------+                                +---------------+                                                
       | booking_id(PK) |                                | course_id(PK) |                                                
       | client_id      |                                | coursename    |                                                
       | course_id      |                                +---------------+                                                
       | course_date    |                                        |                                                        
       +----------------+                                        |                                                        
               |                                                 |                                                        
               |                                                 |                                                        
               |                 +--------------+                |                                                        
               |                 | course_price |                |                                                        
               |                 +--------------+                |                                                        
               +----------------<| cp_id(PK)    |>---------------+                                                        
                                 | course_id    |                                                                         
                                 | dayofweek    |                                                                         
                                 | price        |                                                                         
                                 +--------------+                              

Then join to the price table from booking table

SELECT ...
FROM booking b
INNER JOIN course_price p ON b.course_id = p.course_id AND DAYOFWEEK(.b.course_date) = p.dayofweek
Link to comment
Share on other sites

Hi Barand

 

The prices are stored within the database but the current booking system does not multiple prices for a class, it's a flat rate so if the class is £10, it is £10 for all days but need it to be £10 for just the classes on wednesday and all other days the class is £7.50

Edited by ianhaney50
Link to comment
Share on other sites

As an alternative you could have

       +-----------------+                                    +---------------+                                           
       | booking         |                                    | course        |                                           
       +-----------------+                                    +---------------+                                           
       | booking_id (PK) |                                    | course_id(PK) |                                           
       | client_id       |                                    | coursename    |                                           
       | course_id       |                                    | price         |                                           
       | coursedate      |                                    +---------------+                                           
       +-----------------+       +-----------------+                  |                                                   
                |                | price_exception |                  |                                                   
                |                +-----------------+                  |                                                   
                +---------------<| prex_id(PK)     |>-----------------+                                                   
                                 | course_id       |                                                                      
                                 | dayofweek       |                                                                      
                                 | price           |                                                                      
                                 +-----------------+               

Then if your query is like this

SELECT c.coursename
    b.coursedate
    IFNULL(px.price, c.price) as price
FROM booking b
    INNER JOIN course c USING (course_id)
    LEFT JOIN price_exception px ON b.course_id = px.course_id AND DAYOFWEEK(b.coursedate) = px.dayofweek

it will use the exception price if there is one, otherwise it will use the standard price from the course table

Link to comment
Share on other sites

For now I just done it another way

 

I created a new class specifically for the price that is different on Wednesdays to that of the other days

 

I thought would be easier to do than try and go through all the coding to work out where to do all the changes to the coding etc. as they got it from someone else who is not prepared to help really

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.