Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wp_footer', function(){
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- if ( dnd_wc_uploader.update_qty_pdf && dnd_wc_uploader.show_qty ) {
- // Add minimum on upload quantity to 1.
- document.addEventListener('dndmfu_on_success', function(event){
- $('.dnd-upload-qty').attr( 'min', 1 );
- });
- // After deleting the item, reset cart quantity.
- document.addEventListener('dndmfu_after_deleted', function(event){
- $('input.qty').val(1);
- });
- // Prevent user to change cart quantity.
- $('input.qty').attr('readonly', true);
- // Update Quantity - Multiply (upload_quantity * total_pdf_pages).
- $(document).on('change', '.dnd-upload-qty', function() {
- const indexName = $(this).attr('name').match(/\[(.*?)\]/)[1]
- const pdfIndex = $('[pdf-index="'+ indexName +'"]');
- if ( $('input.qty').val() > 1 && pdfIndex.length > 0 && $(this).val() > 0 ) {
- $('input.qty').val( $(this).val() * parseInt( pdfIndex.attr('data-pages') ) );
- } else {
- $('input.qty').val( parseInt( pdfIndex.attr('data-pages') ) );
- }
- });
- }
- });
- </script>
- <?php
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement