WP Inventory Item Reservation Form Actions

These actions allow you to expand the functionality of the reservation form, hooking into the form at various points to provide a custom user experience.

  • wpim_before_reserve_form: This action is triggered at the start of the reservation form, before the form title.
  • wpim_reserve_form_after_quantity: This action is triggered after the quantity input.
  • wpim_reserve_form: This action is triggered near the end of the form, but before the checkout button.
  • wpim_after_reserve_form: This action is triggered at the end of the entire form, after the checkout button.

Both wpim_reserve_form_after_quantity and wpim_reserve_form take the argument $args, which is an array of the status of every field in the form. Each field has three elements in the array the correspond to different information. The list below uses the name field as an example:

  • ["dispay_name"] is an integer that acts as the setting for whether the field is set to display or not. 0 means do not display, 1 means display not required, and 2 means display required.
  • ["name_label"] is a string of the input label for the field.
  • ["name"] is a string of the value of the input.

The ["form_title"], ["reserve_message"], item ["inventory_id"], ["reserve_nonce"], and any applicable ["error"] message are also part of the $args array.

The hooks wpim_before_reserve_form and wpim_after_reserve_form do not pass any arguments.

Below are several examples of how to hook into each of these actions:

add_action( 'wpim_before_reserve_form', 'custom_before_the_form' ); 
/* Echo a notice about limited quantity before the form */ 
function custom_before_the_form() { 
     echo "<span style='display: block; font-style: italic;'>*Please note that due to 
          limited inventory, we can only allow reservations of 5 items or less</span>"; 
}

 

add_action( 'wpim_reserve_form_after_quantity', 'custom_after_quantity' ); 
/* Echo a reminder notice about a sale based on quantity */ 
function custom_after_quantity( $args ) { 
     echo "<span style='display: block; color: red;'>Don't forget: take 10% off 
          if you reserve 3 or more items!</span>"; 
}

 

add_action( 'wpim_reserve_form', 'custom_thank_you' ); 
/* Echo a thank you note before the checkout button */ 
function custom_thank_you( $args ) { 
     echo "<span style='display: block; font-style: italic;'>We truly appreciate 
          your interest in our products! Don't hesitate to reach out if you have
          any questions.</span>";
}

 

add_action( 'wpim_after_reserve_form', 'custom_after_form' );
/* Echo a satisfaction guarantee notice after the form */
function custom_after_form() {
    echo "<span style='display: block; color: red;'>Satisfaction Guaranteed 
         or your money back!</span>";
}