How to call a function from functions.php on button click event?
-
i have the function below on function.php
/** * Set a minimum order amount for checkout */ add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); function wc_minimum_order_amount($min_amount) { // Set this variable to specify a minimum order value //$minimum = $('#amount').val(); //$minimum = 30; $minimum = $min_amount; if ( WC()->cart->total < $minimum ) { if( is_cart() ) { wc_print_notice( sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order.' , wc_price( WC()->cart->total ), wc_price( $minimum ) ), 'error' ); } else { wc_add_notice( sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order.' , wc_price( WC()->cart->total ), wc_price( $minimum ) ), 'error' ); } } }
Also, i have an input field and a button
<form> <input type="text" id="amount" name="min_amount_ID"/> <input type="button" onclick="wc_minimum_order_amount(this.form.min_amount_ID.value)" class="min_amount"/> </form>
How can i call the function wc_minimum_order_amount() from function.php file on click button?
Or how i can use the result of the script below inside wc_minimum_order_amount() function and assign it as a result to the variable $minimum ?<script type="text/javascript"> $(document).ready(function(){ $('.min_amount').on('click', function(){ var text_val = $('#amount').val(); //alert(text_val ); }); }); </script>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to call a function from functions.php on button click event?’ is closed to new replies.