Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #593949

    i have a product with 2 varients, when i click add to cart without selecting a variation from the dropdown, i would like it to highlight the variation box in my theme main color asking for an option to first be selected to be able to add the product to cart.

    #594004

    Hey arranch!

    I have checked your web site and I can see that the product has always a Variation as first choice, if that is correct, what you need to achieve?

    Regards,
    Basilis

    #594027

    this is only set for the moment as before there was no default value and when the visitor clicked on buy now, the product didn’t add to the cart and there was no message to inform them to choose a variation to make enable the product add to cart.

    i’d like it to be set on no default, with a message to show when they try adding the product to the cart without choosing a variation from the dropdown.

    #595403

    Hi!

    You can set a default variant and have it selected automatically on page load. Edit the product then go to the Variations panel. In the “Default Form Values:” you can set the default variations.

    UPDATE: My bad. I didn’t read the thread thoroughly. Let me get back to you after a while.

    Cheers!
    Ismael

    #595413

    Hey!

    UPDATE: Please add this in the functions.php file:

    // variant products 
    add_action( 'wp_footer', 'ava_custom_script' );
    function ava_custom_script() { ?>
    	<script type="text/javascript">
    	(function($){
    		var a = function() {
    			$('.av-woo-purchase-button').on('mouseover', function() {
    				var sbutton = $('#top form.cart .button');
    				if(sbutton.attr('disabled') == "disabled") {
    					$('#top .variations select').addClass('select-variant');
    				} else {
    					$('#top .variations select').removeClass('select-variant');
    				}
    			});
    		}
    
    		a();
    	})(jQuery);
    	</script>
    	<?php
    }

    And this code in the Quick CSS field:

    .select-variant { border: 3px solid red; }
    

    Best regards,
    Ismael

    #595453

    thanks Ismael

    i added this, but when i saved the functions.php file, i was shown a page that reads the following, relating to the attached line of your coding

    #598167

    Hey!

    Looks like the characters are converted to something else. Please make sure that you copy the code directly from this forum and not from your email.

    Regards,
    Ismael

    #598385

    I have now copied it across from the post and it accepts it, but it doesn’t show when i test it on my site. I’m wondering whether it’s because I added the product purchase button with the drag/drop avia layout builder from enfold, not the default WP editor.

    #599347

    Hi!

    I checked it and the class attribute “select-variant” is being added correctly. Did you add the css code?

    Best regards,
    Ismael

    #599374

    yes i added this

    #599434

    Hey!

    Are you sure? I can’t see the css code when I checked the product page. Please post the login details here so that we can check the site.

    Regards,
    Ismael

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