ianhaney50 Posted July 16, 2015 Share Posted July 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 16, 2015 Share Posted July 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
ianhaney50 Posted July 16, 2015 Author Share Posted July 16, 2015 (edited) 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 July 16, 2015 by ianhaney50 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 16, 2015 Share Posted July 16, 2015 You say the current data does not allow for multiple prices for courses, yet the system requires them. The database design, therefore, is flawed and not fit for purpose. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 16, 2015 Share Posted July 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
ianhaney50 Posted July 16, 2015 Author Share Posted July 16, 2015 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 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.