Last active
May 26, 2016 12:25
-
-
Save kreamweb/cede2722b72b1b558ea592b8fbf23413 to your computer and use it in GitHub Desktop.
this code fix the problem of update the quantity automatically when the theme use a different quantity field
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
| var request; | |
| $(document).on( 'click', '.product-quantity input', function(e){ | |
| if( typeof request !== 'undefined' ){ | |
| request.abort(); | |
| } | |
| var $t = $(this), | |
| $input_quantity = $t.closest('.product-quantity').find('.input-text.qty'), | |
| name = $input_quantity.attr('name'), | |
| value = $input_quantity.val(), | |
| item_keys = name.match(/[^[\]]+(?=])/g); | |
| //this is not necessary for some theme like flatsome | |
| if( $t.hasClass('plus') ){ | |
| value ++; | |
| } | |
| if( $t.hasClass('minus') ){ | |
| value --; | |
| } | |
| //end | |
| var request_info = 'action=yith_ywraq_action&ywraq_action=update_item_quantity&quantity='+value+'&key='+item_keys[0]; | |
| request = $.ajax({ | |
| type : 'POST', | |
| url : ywraq_frontend.ajaxurl.toString().replace( '%%endpoint%%', 'yith_ywraq_action' ), | |
| dataType: 'json', | |
| data : request_info | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment