before_wpcfe_shipment_form_fields

“before_wpcfe_shipment_form_fields” action hook allow to add section before the add and updates shipment form field. This action hook is mostly used in adding additional fields to the form.

Copy and paste the following code in the theme functions.php file.

// Create new section and field in the form
add_action('before_wpcfe_shipment_form_fields', function( $shipment_id ){
	?>
	<div class="col-md-12 mb-3">
		<section class="card">
			<div class="card-body">
				<section class="row">
                    <div class="col-md-6">
                        <div id="form-5" class="form-group ">
                            <label for="my_custom_field" class="active">Custom Field</label>
                            <input id="my_custom_field" type="text" class="form-control my_custom_field" name="my_custom_field" value="<?php echo get_post_meta( $shipment_id, 'my_custom_field', true ); ?>">
                        </div>
                    </div>
                </section>
			</div>
		</section>
	</div>
	<?php
});
// Save the custom fields
add_action( 'after_wpcfe_save_shipment', function( $shipment_id ){
    if( isset($_POST['my_custom_field']) ){
        update_post_meta( $shipment_id, 'my_custom_field', sanitize_text_field( $_POST['my_custom_field'] ) );
    }
} );

0
    0
    Your Cart
    Your cart is emptyReturn to Shop