Overview
- This article outlines how to import Authority to Leave or Signature required information for WooCommerce orders.
Import delivery options
For Starshipit to import Authority to Leave or Signature required information, you need to create two Meta fields:
- authority_to_leave
values can be: 0, 1, true, false, yes, no - signature_required
values can be: 0, 1, true, false, yes, no
These two fields will be imported automatically.
Here is an example on how to display and create these fields. In Function.php add the following code:
/** Add the field signature_required to the checkout page */
add_action('woocommerce_after_order_notes', 'is_signature_required');
function is_signature_required($checkout){
echo '<div id="Signature_required"><h3>' . __('Signature Required') . '</h3>';
woocommerce_form_field('signature_required', array(
'type' => 'checkbox',
'label' => __('Signature Required'),
'required' => false,
) , $checkout->get_value('signature_required'));
echo '</div>';}
add_action('woocommerce_checkout_update_order_meta', 'is_signature_required_field_update_order_meta');
function is_signature_required_field_update_order_meta($order_id) {
if (!empty( $_POST['signature_required'])){
update_post_meta($order_id, 'signature_required', sanitize_text_field( $_POST['signature_required']));
}
}
/** Add the field authority_to_leave to the checkout page */
add_action('woocommerce_after_order_notes', 'is_atl_required');
function is_atl_required($checkout){
echo '<div id="atl"><h3>' . __('Authority To Leave') . '</h3>';
woocommerce_form_field('authority_to_leave', array(
'type' => 'checkbox',
'label' => __('Authority To Leave'),
'required' => false,
) , $checkout->get_value('authority_to_leave'));
echo '</div>';}
add_action('woocommerce_checkout_update_order_meta', 'is_atl_required_field_update_order_meta');
function is_atl_required_field_update_order_meta($order_id) {
if (!empty($_POST['authority_to_leave'])){
update_post_meta($order_id, 'authority_to_leave', sanitize_text_field( $_POST['authority_to_leave']));
}
}