• Resolved Steve Loveridge

    (@steve-loveridge)


    Hi Jan

    Please forgive me if I’m asking some dumb questions here. I’m new to WordPress and website development, but am enjoying the learning curve!

    I’ve found your excellent plug in and would like to use it to manage bookings for a single holiday let that I own.

    I’ve managed to get it all working except:

    I cannot get the total_amount to calculate. I’ve read, and re-read your documentation, but just can’t get it to work. Could you clarify exactly what I need to enter in the Contact Form 7 booking form and email please?

    Also, when Contact Form 7 sends an email confirmation, it correctly sends the booker’s name (your-name), but in the database the name always reverts to the single room name (booking).

    The code for the Contact Form is:

    [booking]
    
    <p>Your Name (required)<br />
        [text* your-name] </p>
    
    <p>Address1 (required)<br />
        [text* your-address1] </p>
    
    <p>Address2 (optional)<br />
        [text your-address2] </p>
    
    <p>Postal Town / City (required)<br />
        [text* your-postal_town] </p>
    
    <p>County(required)<br />
        [select* your-county "Aberdeenshire"...."Worcestershire"
    ] </p>
    
    <p>Post Code / ZIP Code (required)<br />
        [text* your-postcode] </p>
    
    <p>Your Email (required)<br />
        [email* your-email] </p>
    
    <p>Your Telephone Number (optional)<br />
        [tel your-phone] </p>
    
    <p>Your Country (required)<br />
        [select* your-country  "United Kingdom" ..."Zimbabwe"]] </p>
    
    <p>Your Preferred Language<br />
        [select* your-language "ENG""FRA""ESP""DEU""ITA"] </p>
    
    <p>Check-in Date <br />
     [text* start_date id:start_date] <p>
    
    <p>Check-out Date <br />
    [text* end_date id:end_date] <p>
    
    <p>Number of Adults<br />
     [select* number_of_persons id:number_of_persons  "1" "2" "3" "4"]<p>
    
    <p>Amount Due<br />
    [your-total_amount]<p>
    
    <p>Special Requests<br />
        [textarea your-special_requirements] </p>
    
    <p>[recaptcha size:compact]<p>
    
    <p>[acceptance accept-this-1] By checking this box I confirm that I have read and accept the <a href="https://www.perrybarn.co.uk/about-us/termsconditions/" target="_blank">standard terms and conditions.</a><p>
    
    <p>[submit "Make Booking"]</p>

    As you can see, I’ve also added some extra address and special requirements fields to the form and database, but again, although the email function correctly reports these, they do not appear in the database – the new columns are blank.

    The database looks like this:

    Column	        Type	       Null	Default	Comments
    id	        bigint(20)	No
    name	        varchar(100)	No
    your-address1	varchar(255)	No
    address2	varchar(255)	No
    postal_town	varchar(255)	No
    county	        varchar(255)	No
    postcode	varchar(10)	No
    status	        int(11)	        No 	0
    start_date	date	        No 	0000-00-00
    end_date	date	        No 	0000-00-00
    email	        varchar(255)	No
    phone	        varchar(20)	No
    country	        varchar(50)	No 	United Kingdom
    language	varchar(10)	No 	ENG
    uid	        varchar(500)	No
    number_of_
    persons	        int(11)	        No 	0
    special_
    requirements	varchar(255)	No 
    
    Indexes
    
    Keyname	Type	Unique	Packed	Column	Cardinality	Collation	Null	Comment
    PRIMARY	BTREE	Yes	No	id	2	A	No

    Sorry if that’s a lot of questions – but any help would be much appreciated.

    Many thanks

    Steve

    https://www.ads-software.com/plugins/jm-avail-booking/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Jan Maat

    (@jan-maat)

    Hi Steve,

    About the total_amount calculation:

    Change:

    Number of Adults
    ?[select* number_of_persons id:number_of_persons? "1" "2" "3" "4"]

    into:

    Number of Adults
    ?[select* number_of_persons id:number_of_persons? "1" "2" "3" "4"]
    <div class="total_amount"></div>

    And remove:

    Amount Due
    [your-total_amount]

    In the emails you add :

    Amount Due
    [total_amount]

    About the new added fields;
    You need to add extra code to store these new fields. The code involved you find in file jm_avail_booking.php around line 505.
    That the name in the database always reverts to the single room name is because of the code above that stores the single room name in the field name as intended.

    Changing the code in plugins may bring you in future problems as new versions of the plugin are released. But it is up to you.

    Regards,

    Jan

    Thread Starter Steve Loveridge

    (@steve-loveridge)

    Thank you Jan.

    That’s great – I’ve now got the total_amount working on the form and the emails.

    I’ll have a go at editing jm_avail_booking.php and have found the code which does the work. It’ll be first PHP experience – so wish me luck!

    That the name in the database always reverts to the single room name is because of the code above that stores the single room name in the field name as intended.

    O have to admit to not understanding this – why would the plug in ask for the bookers’ name – only to lose it from the database and replace it with data whcih is the same as every other record? Am I missing something here? It strikes me that I need to introduce another “bespoke” database column of “booker’s name” or keep the emails.

    Please forgive me if I’m being thick!

    Thanks again for such a fast response.

    Steve

    Thread Starter Steve Loveridge

    (@steve-loveridge)

    Sorry to bother you again Jan

    I’ve modded the code as follows:

    `$wpdb->insert(
    $db_table_name_bookings, array(
    ‘name’ => $posted_data[‘booking’],
    ‘lead_name’ => $posted_data(‘lead_name’),
    ‘address1’ => $posted_data(‘address1’),
    ‘address2’ => $posted_data(‘address2’),
    ‘postal_town’ => $posted_data(‘postal_town’),
    ‘county’ => $posted_data(‘county’),
    ‘postcode’ => $posted_data(‘postcode’),
    ‘status’ => $status,
    ‘start_date’ => $start_date,
    ‘end_date’ => $end_date,
    ‘your-email’ => $posted_data[‘your-email’],
    ‘your-phone’ => $posted_data[‘your-phone’],
    ‘your-country’ => $posted_data[‘your-country’],
    ‘your-language’ => $posted_data[‘your-language’],
    ‘number_of_persons’ => $posted_data[‘number_of_persons’],
    ‘special_requirements’ => $posted_data(‘special_requirements’),
    ‘uid’ => $uid
    )
    );`

    …and the form doesn’t create any entry at all now.

    Could you point me in the right direction please?

    Sorry to be a pain

    Steve

    Plugin Contributor Jan Maat

    (@jan-maat)

    Hi Steve,

    First an answer on the previous question about bookers name. The first user of this plugin only needed a limited info on the booker. So it started all with the bare minimum to display the calendar and a reverence to the booker. The room name is required in a multi room situation. All the rooms are in the same database.
    The CTF7 form may ask for more information but they are only put in the email.

    About the second question. The names of the fields in the $wpdb→Insert must be the same as the names of the field in the database. So do not use ‘hour-email’ as the field in the database is named ’email’

    There is another request to add name fields to the plugin (Adding Name Fields and Notes Field to Database). Look there for my responds.

    Regards,

    Jan

    Thread Starter Steve Loveridge

    (@steve-loveridge)

    Thanks fr your help Jan!

    Much appreciated

    Steve

    Plugin Contributor Jan Maat

    (@jan-maat)

    Hi,

    The extra fields are added in the just released version 1.4.2

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘A few questions – total_amount, booking name and custome database fields’ is closed to new replies.