WordPress jQuery crash [closed]

The reason you are getting the error is that you are trying to bind a JavaScript function to a WordPress PHP hook. Bind your JavaScript handler to the form’s submit event: $( “#your-form” ).submit(function( event ) { //Select checkboxes by id var $checkboxes = $(‘input[id=checkboxprice]’); //Set event $checkboxes.on(‘change’, function () { var totalPrice = 0; … Read more

How to call custom jQuery plugins into the customizer controls

First, in order to enqueue JS in the customizer controls, you need to use the customize_controls_enqueue_scripts action. This is different than the action used to enqueue scripts into the customizer preview, which is what themes normally do via customize_preview_init or wp_enqueue_scripts. So in your snippet above, replace customize_preview_init with customize_controls_enqueue_scripts. Secondly, in order to extend … Read more

Can’t delete the default jQuery in the theme

An example on how to deregister a WordPress built-in library and load your own: function load_custom_scripts() { wp_deregister_script( ‘jquery’ ); wp_register_script(‘jquery’, ‘//code.jquery.com/jquery-2.2.4.min.js’, array(), ‘2.2.4’, true); // true will place script in the footer wp_enqueue_script( ‘jquery’ ); } if(!is_admin()) { add_action(‘wp_enqueue_scripts’, ‘load_custom_scripts’, 99); }

Adding custom cart price with Ajax in wordpress

Try to change your add_custom_price_callback() as follows. Untested but should work. function add_custom_price_callback() { $custom_price = intval($_POST[‘p_m’]); $target_product_id = intval($_POST[‘s_o_v’]); foreach ( WC()->cart->get_cart() as $key=>$value ) { //Single product if ( $value[‘product_id’] == $target_product_id ) { $value[‘data’]->set_price($custom_price); } //For variation if ( $value[‘variation_id’] == $target_product_id ) { $value[‘data’]->set_price($custom_price); } } //to check if is work … Read more

fill form fields with ajax response

First, I can count on one finger the number of times A code which was developed in the hope of being “reusable” was actually reused. Write the code to the specification you can test against. “Reusable” is not a specification you can test against until you have a proper idea what will you need in … Read more

Jquery contact form to send mail to admin [closed]

Without php you can’t send an email. So as per your reference you have to use ajax and php. In wordpress ajax is little bit different as compared to normal ajax. You can check the link for how to use ajax in wordpress. https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/ https://premium.wpmudev.org/blog/using-ajax-with-wordpress/?utm_expid=3606929-101.TxEXoCfwS1KxJG1JVvj_5Q.0&utm_referrer=https%3A%2F%2Fwww.google.co.in%2F https://www.sitepoint.com/how-to-use-ajax-in-wordpress-a-real-world-example/ Once you call the action inside ajax, in that … Read more

Loading external jQuery files with $

You can do this using follow snippet // Add scripts to wp_head() function child_theme_head_script() { ?> <!– Your HTML/JavaScript goes here –> <?php } add_action( ‘wp_head’, ‘child_theme_head_script’ );

Cherry Framework theme, JQuery is using HTTP not HTTPS

If the script is enqueued using wp_enqueue_script (as it “should” be) then you can modify the tag directly with a find and replace match to fix this using the script_loader_tag filter: add_filter(‘script_loader_tag’, ‘custom_https_fix’, 10, 2); function custom_https_fix($tag, $handle) { $match=”jquery.script.js”; // replace with actual script filename if (strstr($tag, $match)) {$tag = str_replace(‘http://’, ‘https://’, $tag);} return … Read more