Conflics with WPC Single Variations plugin
-
Hi there,
first thing first, I’m a big fan of your plugins but I think I found a conflicts when using Popup view and Single Variations one.
This is my setup (sorry I’m working localy so I can’t share you a link):
Hand made theme(but got same bug with Twenty Twenty-One):
-WPC Smart Quick View
-WPC AJAX Add to Cart
-WPC Show Single Variations (“Hide variable products on archive page.” is uncheck)
-WPC Fly CartOn my archive page, I got my main Variable Product, as I unchecked “Hide variable products on archive page.” and also my Variations Products.
1. If I click the QuickView link on my main Variable Product the popup open(everything is ok, slick, title, button…) and when I click the Add to cart button my Variation is added to the fly cart perfectly.
2. Now if I click the QuickView button on a Variation Product, my popup open (everything is in place) but when I click on the Add to cart button I’m redirect to the home page and my product was not added to the cart.
After several investigation I understand why.
When I click on the Variable Product there was 3 input type hidden in my variations_form cart.
<input type="hidden" name="add-to-cart" value="340"> (340 is my Variable product ID) <input type="hidden" name="product_id" value="340"> <input type="hidden" name="variation_id" class="variation_id" value="418">(418 is my variation ID)
If I select another variation, the value of the variation_id input change and product is added.
But when I click on a variation Product I also got my 3 input type hidden:
<input type="hidden" name="add-to-cart" value="418">(418 is my variation ID) <input type="hidden" name="product_id" value="418"> <input type="hidden" name="variation_id" class="variation_id" value="0">
But as you can see the value of the variation_id input is 0.
So when I click the Add to cart button it failed to add product to the cart and I’m redirect to the home page.I find a way to make it work, but I prefer to not add hugly code, to be sure everything will be fine when I’ll update your plugins.
This is what I’ve done:$(document).on('woosq_loaded', function() { var $product_id = $(this).find('input[name=product_id').val(); var $variation_id = $(this).find('input.variation_id'); var css_not = '.disabled, .wpc-disabled, .wooco-disabled, .woosb-disabled, .woobt-disabled, .woosg-disabled, .woofs-disabled, .woopq-disabled, .wpcbn-btn, .wpcuv-update'; var $btn = $('.single_add_to_cart_button:not('+ css_not +')'); $btn.on('click', function(e){ e.preventDefault(); if($variation_id.val() == 0 ){ $variation_id.val($product_id); } }) });
If you have a better way to make it work let me know?
Best regards
- The topic ‘Conflics with WPC Single Variations plugin’ is closed to new replies.