Cannot prefill hidden Ninja Forms fields

According to https://developer.ninjaforms.com/codex/changing-field-values/ you need to add .trigger( ‘change’ ) when changing Ninfa Forms field values programmatically. This should work: if(jQuery(‘#broker-list’).length) { //checks if the list exists jQuery(document).on( ‘nfFormReady’, function( e, layoutView ) { var broker_name = “”; jQuery(document).on(“click”, “.broker” , function() { broker_name = jQuery(‘.broker__name’, this).text(); console.log(broker_name); // this works perfectly if(jQuery(‘#nf-field-33’).length) { jQuery(this).val(broker_name).trigger( … Read more

Woocommerce add to cart quantity buttons with AJAX

I fixed it with some IDs add in function.php add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘quantity_inputs_for_loop_ajax_add_to_cart’, 10, 2 ); function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) { if ( $product && $product->is_type( ‘simple’ ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { // Get the necessary classes $class = implode( ‘ ‘, array_filter( array( ‘button’, ‘product_type_’ . $product->get_type(), $product->is_purchasable() && … Read more

How to update the WooCommerce cart Icon to show new products added with JavaScript

Heres a nice article describing how to do this, but a very different approach to yours : https://aceplugins.com/ajax-add-to-cart-button-on-the-product-page-woocommerce/ Since you know how many items are being added to the cart (1 based on your link) you could just fake some addition and upate the cart icon value Assuming the cart icon number has an id … Read more

How to stop focus() in custom js from scrolling to footer?

In jQuery focus by default scroll the page to the element. If we use focus({preventScroll: true}) our copy function will not work as you mension. So I have use some css hack. See the following jQuery code. function copyToClipboard(selector, event){ event.preventDefault(); var $temp = jQuery(“<div>”); jQuery(“body”).append($temp); $temp.attr(“contenteditable”, true) .html(jQuery(selector).html()).css(‘position’, ‘fixed’).select() .on(“focus”, function() { document.execCommand(‘selectAll’,false,null); }) … Read more

Replace menu links with # and add name to its li

I want the URLs of the nav-items to be replaced with # You can use the nav_menu_link_attributes hook to set the custom href value like so: add_filter( ‘nav_menu_link_attributes’, function ( $atts, $item, $args ) { if ( ‘menu-categorias’ === $args->theme_location && ‘category’ === $item->object ) { $atts[‘href’] = ‘#’ . get_term_field( ‘slug’, $item->object_id ); } … Read more

Adding JavaScript to a WordPress website

Using this link, you will find helpful notes as to how to add a script to your WordPress website. The main idea is to use inbuilt WordPress functions to load your scripts. This is done via the wp_enqueue_script function. Following examples provided in the aforementioned link, you will be able to learn how to enqueue … Read more

How to test nonce with AJAX – Plugin development

I see some issues: You ajax action can be only used by logged users. If this is correct, I recommend you add a nopriv action that returns a error message. // Inside Constructor add_action( ‘wp_ajax_nopriv_pp_html_process’, array( $this, ‘pp_html_process_not_logged’ ) ); And create this function : public function pp_html_process_not_logged () { // Status can be used … Read more

Jquery integration with my theme

I think the main problem is that you need to use a no-conflict wrapper when calling tab slideout. However, rather then simply point out the problem i’m going to cover some things you should be doing to make this script work “The WordPress Way” ..(ie. using an enqueue and hooking onto an appropriate hook to … Read more