Title: Additional Unique Amount
Last modified: April 26, 2017

---

# Additional Unique Amount

 *  [zkenstein](https://wordpress.org/support/users/zkenstein/)
 * (@zkenstein)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/additional-unique-amount/)
 * Hi Team,
 * On this plugin, is it possible to create auto amount number? For example: donation
   amount is $100,000 the system create a unique additional will be $100,091 amount
   need to pay by users.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Matt Cromwell](https://wordpress.org/support/users/webdevmattcrom/)
 * (@webdevmattcrom)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/additional-unique-amount/#post-9070724)
 * We have a sample plugin that will do that for you automatically.
    [https://github.com/WordImpress/Give-Snippet-Library/blob/master/form-customizations/basic-fees.php](https://github.com/WordImpress/Give-Snippet-Library/blob/master/form-customizations/basic-fees.php)
 * But we are working on a more official one that will give donors options and more
   features as well. Watch our blog and newsletter for news on that.
 * Thanks!
 *  Thread Starter [zkenstein](https://wordpress.org/support/users/zkenstein/)
 * (@zkenstein)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/additional-unique-amount/#post-9103568)
 * Nice!
 *  Thread Starter [zkenstein](https://wordpress.org/support/users/zkenstein/)
 * (@zkenstein)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/additional-unique-amount/#post-9116901)
 * Hi Matt,
 * Nice sample scripts, I tried to modified it for using the random number mt_rand.
   The unique number appeared on form, but when I pressed donate now the unique 
   number not storing on to the DB. Can you please guide me? This is the part of
   code modified:
 *     ```
       function give_basic_fees_js() {
           ?>
           <script>
               <?php //Generate
   
       $digits_needed=3;
   
       global $random_number;
   
       $random_number =''; // set up a blank string
   
       $count=0;
   
       while ( $count < $digits_needed ) {
           $random_digit = mt_rand(0, 9);
   
           $random_number .= $random_digit;
           $count++;
       }?>
               var give_global_vars;
               //JS for Basic Fee calculation on the fly.
               jQuery(function ($) {
                   /**
                    * Event Triggers
                    */
                   //When document runs.
                   $(document).ready(give_basic_update_percentage());
                   //If donation amount update is triggered.
                   $(document).on('give_donation_value_updated', function () {
                       give_basic_update_percentage();
                   });
                   //If the donation.
                   $(document).on('blur', '.give-donation-amount .give-text-input', function (e) {
                       give_basic_update_percentage();
                   });
                   /**
                    * JS update logic - Basic update percentage JS.
                    */
                   function give_basic_update_percentage() {
                       //Set vars
                       var percentage = <?php echo $random_number; ?>;
                       var current_total = $('input[name="give-amount"]').val();
                       //Unformat current total so fee calculation is correct for larger donations.
                       current_total = Math.abs(parseFloat(accounting.unformat(current_total, give_global_vars.decimal_separator)));
                       var fee = percentage;
                       var new_total = current_total + fee;
                       //Set the custom amount input value format properly
                       var format_args = {
                           symbol: give_global_vars.currency_sign,
                           decimal: give_global_vars.decimal_separator,
                           thousand: give_global_vars.thousands_separator,
                           precision: give_global_vars.number_decimals
                       };
                       fee = accounting.formatMoney(fee, format_args);
                       new_total = accounting.formatMoney(new_total, format_args);
                       //Update fee information text.
                       $('span.give-basic-fee-amount').text(fee);
                       //Update final total text.
                       $('.give-final-total-amount').text(new_total);
                   }
               });
           </script>
       <?php }
       add_action( 'wp_print_footer_scripts', 'give_basic_fees_js' );
       /**
        * Adds the fee to the DB upon submit.
        *
        * @param $sanitized_amount
        *
        * @return string
        */
       function give_basic_fees_add_fee( $sanitized_amount ) {
           //$fee_percentage = (int) give_get_option( 399 );
           $fee            = $sanitized_amount;
           $new_total      = $fee + percentage;
           return $new_total;
       }
       add_filter( 'give_donation_total', 'give_basic_fees_add_fee', 1, 1 );
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Additional Unique Amount’ is closed to new replies.

 * ![](https://ps.w.org/give/assets/icon-256x256.jpg?rev=2873287)
 * [GiveWP - Donation Plugin and Fundraising Platform](https://wordpress.org/plugins/give/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/give/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/give/)
 * [Active Topics](https://wordpress.org/support/plugin/give/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/give/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/give/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [zkenstein](https://wordpress.org/support/users/zkenstein/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/additional-unique-amount/#post-9116901)
 * Status: not resolved