• Hi Yith Team,

    Which part of code can i add in my function file to show the Add to Quote button only for a specific quantity for variable product ?

    I don’t need the button for all quantities.

    Help would be very appreciate, Thanks.

    • This topic was modified 5 years, 1 month ago by thimy.
    • This topic was modified 5 years, 1 month ago by thimy.
Viewing 3 replies - 1 through 3 (of 3 total)
  • katigoroshek

    (@katigoroshek)

    I’m also interested

    Plugin Author YITHEMES

    (@yithemes)

    Hello,

    You can add the following code to the functions.php file:

    if ( ! function_exists( 'yith_ywraq_show_button_based_on_qty' ) ) {
    	add_action( 'wp_footer', 'yith_ywraq_show_button_based_on_qty' );
    	function yith_ywraq_show_button_based_on_qty() {
    		?>
    		<script type="text/javascript">
                jQuery( '.product .entry-summary .quantity .qty.text' ).on( 'change', function ( e ) {
                    var qty = 5;
                    var $button = jQuery( '.product .entry-summary .yith-ywraq-add-to-quote' );
                    if ( parseInt( jQuery( this ).val() ) >= qty ) {
                        $button.css( 'display', 'block' );
                    } else {
                        $button.css( 'display', 'none' );
                    }
                } ).trigger( 'change' );
    		</script>
    		<?php
    	}
    }

    You only have to change the number 5 on this line:
    var qty = 5;
    The number you’ll set will act as the threshold for starting to show the “add to quote” button.
    For example, without modifying the previous code, the “add to quote” button is hidden until you select 5 or more.

    Thread Starter thimy

    (@thimy)

    Hi @yithemes

    Firstable thank you for your reply, i appreciate,
    but this code isn’t work for me, i don’t understand why the add_action begin by ‘wp_footer’ ?

    Is it a function in your plugin and did you test it because there is no change for me.

    Then, i search a way to deactivate the button (keeping the button visible) not by hiding it.
    If there is no other choice, i take the hide with the display none css but with a functional code if possible ??

    Thanks again.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Button for a specific quantity’ is closed to new replies.