Forked from plugin-republic/update-cart-item-ajax.js
Last active
September 8, 2022 10:03
-
-
Save shahidbahader/1a8101fa4f393a526a936e2deab5800b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$(document).ready(function(){ | |
$(document.body).on('change keyup paste', '.prefix-cart-notes', function(){ | |
$('.cart_totals').block({ | |
message: null, | |
overlayCSS: { | |
background: '#fff', | |
opacity: 0.6 | |
} | |
}); | |
var cart_id = $(this).data('cart-id'); | |
$.ajax( | |
{ | |
type: 'POST', | |
url: prefix_vars.ajaxurl, | |
data: { | |
action: 'prefix_update_cart_notes', | |
security: $('#woocommerce-cart-nonce').val(), | |
notes: $('#cart_notes_' + cart_id).val(), | |
cart_id: cart_id | |
}, | |
success: function( response ) { | |
$('.cart_totals').unblock(); | |
} | |
} | |
) | |
}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The event was not triggering after the update cart function was called, which means the custom text could not be updated if a customer has updated the cart. For that the event must be triggered on the document body. (Tested and Worked)