Full shipping address and delivery address

WordPress Event Management, Calendars & Registration Forums General Question Full shipping address and delivery address

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10247

    I’ve got some questions regarding the user address management. I hope you can provide me with some ideas how this could be done.

    We need the full address of our customers to be able to provide them with a legal invoice they can use for tax purposes. The current solution using the wordpress credentials (email and a name) is insufficient. This must be a full address (and a field for the company’s name ). The second thing is that our bookees often ask if we can provide a billing address (mostly their company will pay) – one that is different from the shipping address. In fact we need both – the full shipping/home address and an optional billing address. And the best would be if this could be somehow stored with the user account data so they don’t have to type it in again when booking for the second time.

    Can this be done with Event Organizer? Please give me a hint how.

    Adrian Maleska
    #10286

    Hi Adrian,

    You can easily add an address field, however, this is saved with the booking, rather than with the user. Additionally there isn’t a way of pre-populating the fields.

    The only way around this would be to use the ‘hook’ field. By adding a hook (call it adrian_booking_form_address_fields) you can execute arbitrary code at that point:

    function adrian_address_fields(){
          //Print HTML mark-up for desired fields (e.g. address)
          //Give the fields a name attribute which you'll use to retrieve the entered values later
    
          if( is_user_logged_in() ){
              $user_id = get_current_user_id;
              //Use the user ID to pre-populate fields. Retrieving this data
              //will depend on where you store it. It's probably best to use get_user_meta()/update_user_meta()
          }
    }
    add_action( 'adrian_booking_form_address_fields', 'adrian_address_fields' );

    The added fields should now appear in the booking form at the location you place the hook element. To save the data hook into eventorganiser_pre_gateway_booking

    function adrian_save_address_fields( $booking_id ){
          //Retrieve values: look in $_POST for the names you gave the fields
          if( is_user_logged_in() ){
              $user_id = get_current_user_id;
              //Save data to the user ID
          }
    }
    add_action( 'eventorganiser_pre_gateway_booking', 'adrian_save_address_fields' );

    However, this data won’t appear along with the booking form (in the admin screen / bookings export ) as it’s effectively by-passing the booking form handling of things. Additional code could include it in the bookings export, however. Additionally the data is associated with the user, not booking.

    In 1.8 there’s a major rewrite of the way the plug-in handles booking forms, exposing a lot API which can be used to pre-populate fields, or even add additional ones. This is due for the end of this month, and I’ll include a tutorial on how to do just that. In 1.8 you could pre-populate fields and/or store the data elsewhere, and it’ll also be included along with rest of the booking form data.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.