Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #633351

    I’ve been trying to implement a third party plugin to allow fractional quantity in WooCommerce and having problems. It’s called WooCommerce Advanced Quantity:

    http://codecanyon.net/item/woocommerce-advanced-quantity/11861326

    In the comments for this plugin, they point to Enfold as the issue with the plugin not working properly.

    http://codecanyon.net/item/woocommerce-advanced-quantity/11861326/comments?utf8=%E2%9C%93&term=NaN&from_buyers_and_authors_only=0&from_buyers_and_authors_only=1#comment_10694888

    I get that everyone could point fingers on why this issue is occuring but I just need to be able to use fractional quantities. Is there a way to disable to +/- quantity feature Enfold implements and go back to the quantity dropdown that’s standard in WooCommerce without hacking Enfold? That is, can I do it via a hook or something?

    Thanks!

    #634266

    Hi,

    Open /enfold/config-woocommerce/woocommerce-mod.js and remove the following:

    	
    	jQuery(".quantity input[type=number]").each(function() {
    	var number = $(this),
    			max = parseFloat( number.attr( 'max' ) ),
    			min = parseFloat( number.attr( 'min' ) ),
    			step = parseInt( number.attr( 'step' ), 10 ),
    			newNum = jQuery(jQuery('
    <div />').append(number.clone(true)).html().replace('number','text')).insertAfter(number);
    			number.remove();
    
    		setTimeout(function(){
    			if(newNum.next('.plus').length == 0) {
    				var minus = jQuery('<input type="button" value="-" class="minus">').insertBefore(newNum),
    						plus    = jQuery('<input type="button" value="+" class="plus">').insertAfter(newNum);
    
    				minus.on('click', function(){
    					var the_val = parseInt( newNum.val(), 10 ) - step;
    					the_val = the_val < 0 ? 0 : the_val;
    					the_val = the_val < min ? min : the_val;
    					newNum.val(the_val);
    				});
    				plus.on('click', function(){
    					var the_val = parseInt( newNum.val(), 10 ) + step;
    					the_val = the_val > max ? max : the_val;
    					newNum.val(the_val);
    
    				});
    			}
    		},10);
    
    	});

    Regards,
    Josue

    #641842

    Just so I’m clear, there’s no way to do this without modifying a core theme file? Or at least overriding it in a child theme?

    I know this is probably best added as a feature request but is there any way to compare a child theme and its parent and identify outdated files in the child theme?

    #642133

    Hi,

    You could dequeue the parent file with a function like this:

    function wp_dequeue_avia_wc() {
       wp_dequeue_script( 'avia-woocommerce-js' );
    }
    add_action( 'wp_print_scripts', 'wp_dequeue_avia_wc', 100 );
    

    Best regards,
    Josue

    #681709

    I have an issue with this code, my problem was that I don’t have step attribute on the input so when I click on “+” or “-” the result was NaN because the step is null in my case.

    To resolve that I copy the actual javascript to my child theme and modify 2 lines off code :
    In woocommer-mod.js line 22 (I add “|| 1” to get ride of the null or undefined value):
    step = parseInt( number.attr( 'step' ), 10 ) || 1,

    And line 24 I add this :

    number.remove();
    newNum.removeAttr('pattern');

    To load this new script and unload the core one :

    function wp_dequeue_avia_wc() {
        wp_dequeue_script( 'avia-woocommerce-js' );
    }
    function wp_enqueue_avia_wc() {
        wp_enqueue_script('avia-woocommerce-js2', get_stylesheet_directory_uri() . '/config-woocommerce/woocommerce-mod.js', array('jquery'), 1, true);
    }
    
    add_action( 'wp_print_scripts', 'wp_dequeue_avia_wc', 100 );
    add_action( 'wp_enqueue_scripts', 'wp_enqueue_avia_wc' );
    • This reply was modified 7 years, 10 months ago by prometee. Reason: format
    #682726

    Hi,


    @prometee
    Glad you figured it out and thank you for sharing your solution.

    Best regards,
    Yigit

    #732609

    I’m using the “Quantities and Units for WooCommerce” plugin to enable decimal quantities and Kg as units.
    I disabled the Enfold +/- as suggested by Josue in his first answer but this is not sufficient since:
    – the quantity field is classified as a Text input field instead of a number input field (as you can see the std increase and decrease HTML buttons are not appearing also in the cart )
    – the header cart show quantities with ‘.’ instead of ‘,’
    https://drive.google.com/file/d/0B7baurTblFiQQWloLUVmeEJCN2M/view?usp=sharing
    https://drive.google.com/file/d/0B7baurTblFiQX0x0X2pwRGF1V1U/view?usp=sharing

    • This reply was modified 7 years, 6 months ago by tipinoncomuni. Reason: Question about decimal separator moved here https://kriesi.at/support/topic/decimal-point-in-woocommerce-product-quantities/
    #734222

    @tipinoncomuni
    Please contact WooCommerce about this issue. Have you got similar results when using a default WP theme?

    Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    Login credentials include:

    • The URL to the login screen.
    • A valid username (with full administration capabilities).
    • As well as a password for that username.
    • permission to deactivate plugins if necessary.

    Best regards,
    Andy

    #734406

    Theme: Twenty Seventeen
    Plugin: enabled
    the HTML +/- buttons are revealed, fractional quantities can be saved to cart

    Theme: Enfold
    Plugin: enabled
    the Enfold +/- buttons are not working, manual input with fractional quantities is not accepted by page

    Theme: Enfold child with Josua code to disable Enfold +/- buttons
    Plugin: enabled
    Enfold +/- buttons are disappeared
    The HTML +/- buttons are not revealed, manual input with fractional quantities is accepted by page
    The decimal separator in the header cart is wrong (‘.’ instead of ‘,’ as defined in woocommerce config)

    Obviously, the fractional quantities directly supported by Enfold +/- buttons … is the desired solution :-)

    Fractional quantities question moved HERE

    • This reply was modified 7 years, 6 months ago by tipinoncomuni. Reason: deleted access info
    #734426

    Hey!


    @tipinoncomuni
    Can you please start a new thread and attach these WP logins and FTP login? If you post them here, they will be visible to creator of this thread as well.

    Best regards,
    Yigit

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.