Skip to content

Instantly share code, notes, and snippets.

@bharathjinka09
Created February 14, 2019 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bharathjinka09/ae5c676bdc0575dae052fe6ca198d575 to your computer and use it in GitHub Desktop.
Save bharathjinka09/ae5c676bdc0575dae052fe6ca198d575 to your computer and use it in GitHub Desktop.
Regarding adding a custom check box field to charitable plugin donation form in wordpress
<?php
/**
* Core functions and definitions for Reach Theme.
*
* @package Reach
*/
require_once( 'inc/class-reach-theme.php' );
/**
* Start the theme.
*/
reach_get_theme();
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; /* pixels */
}
/**
* Define whether we're in debug mode.
*
* This is set to false by default. If set to true,
* scripts and stylesheets are NOT cached or minified
* to make debugging easier.
*/
if ( ! defined( 'REACH_DEBUG' ) ) {
define( 'REACH_DEBUG', false );
}
/**
* Return the one true instance of the Reach_Theme.
*
* @return Reach_Theme
* @since 1.0.0
*/
function reach_get_theme() {
return Reach_Theme::get_instance();
}
add_action('wp_enqueue_scripts', 'load_js_assets');
function ed_charitable_register_new_checkbox_field() {
/**
* Define a new checkbox field.
*/
$field = new Charitable_Donation_Field( 'new_checkbox_field', array(
'label' => __( 'Indian', 'charitable' ),
'data_type' => 'user',
'donation_form' => array(
'type' => 'checkbox',
'show_after' => 'phone',
'required' => true,
'name'=> 'indian',
'id' => 'myCheck',
'onClick'=>'myFunction()',
),
'admin_form' => true,
'show_in_meta' => true,
'show_in_export' => true,
'email_tag' => array(
'description' => __( 'Indian or not' , 'charitable' ),
),
) );
/**
* Register the checkbox field.
*/
charitable()->donation_fields()->register_field( $field );
}
add_action( 'init', 'ed_charitable_register_new_checkbox_field' );
This is my functions.php. I have added the custom checkbox using the above code present in your github. But i am not able to display a danamojo donate button after clicking the checkbox. It should display it in donation receipt after submitting and should also save in database. For example, if a user or donor is an Indian, then he will check the checkbox and then the button will gets displayed below the checkbox. Then he will pay the donation amount. After that the donation amount and the Indian value in the checkbox should be saved and displayed in the donation receipt. The checkbox should be added after phone number text box. Thank you.
@bharathjinka09
Copy link
Author

donation-form

@bharathjinka09
Copy link
Author

This is the screenshot. I have added a checkbox called Indian and when i click that it should display a danamojo donation button and the value of checkbox "Indian" should be saved in database and should be displayed in the receipt form after submitting the donation.Please help me in solving this issue. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment