• Resolved Adil556

    (@flaxtrade)


    Hi,

    I have followed this guide https://givewp.com/documentation/developers/how-to-create-custom-form-fields/ and added a custom field to the form however the value is not showing in the Donations back end nor emails.

    Oddly it shows on the receipt after the payment just not the backend

    This is the code I have used:

    // Add checkbox to donation form before credit card field
    add_action( 'give_fields_donation_form_before_cc_form', function( $group ) {
        $group->append(
            give_field( 'checkbox', 'ukTax' )
    		->showInReceipt()
    		->storeAsDonorMeta()
    		->label( __( 'Yes, I am a UK Tax Payer and I would like the York Vikings Rotary Club to reclaim the tax on all qualifying donations I have made, as well as any future donations, until I notify them otherwise.' ))
        );
    });
    // Add the ukTax checkbox to donations in the backend
    function render_givewp_field_api_fields( $payment_id ) {
    	$field_name = give_get_meta( $payment_id, 'ukTax');
    
    	if ( $field_name ) : ?>
    		<div id="ukTax" class="postbox">
    			<h3 class="handle"><?php echo 'UK Tax'; ?></h3>
    			<div class="inside" style="padding-bottom:10px">
    				<?php echo $field_name; ?>
    			</div>
    		</div>
    	<?php endif;
    }
    
    add_action( 'give_view_donation_details_billing_after', 'render_givewp_field_api_fields', 10, 1 );

    Is there anything I’m missing here?

    Thanks

    • This topic was modified 1 year, 6 months ago by Adil556.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom field not showing in Donation back end’ is closed to new replies.