Tagged: variable products, woocommerce
-
AuthorPosts
-
April 27, 2018 at 4:12 pm #948014
Hello,
I would like some help from your support.
I have a variable product with colour and size attributes and variations. When i manage the stock quantity of each variation (for example: colour: red and size: large, Stock quantity: 3 products) the add to cart item counter (- & +) adds more products than three for the specific variation.
When i have a simple product with stock quantity (for example 4 products), the add to cart item counter works fine, it’s shows the correct number of products (4).
Τhis problem is only with the Variable products.
Also I have changed temporally the enfold theme with the Twenty Fifteen theme and everything works perfect so the problem happens only with the enfold theme. I don’t think that it is woocommerce issue.Please i would be very happy if you could help me with this. :)
My website works with: wordpress 4.9.5, Enfold theme 4.3 and woocommerce 3.3.5
April 30, 2018 at 9:20 am #948890Hey gkarae,
We do have an issue with the variable products at this time and our developers are working on it. Please be patient and thank you for using Enfold.
Best regards,
VictoriaMay 4, 2018 at 9:51 am #951469Thank you very much! I’m waiting for your updates! :)
May 7, 2018 at 10:32 am #952576Hi,
Thank you for understanding. Would you mind if we take a look at one of the products with the issue? We would like to inspect it.
Best regards,
IsmaelMay 10, 2018 at 1:31 pm #954539The website is under consturction so i have made for you an account for login.
When i manage the stock quantity of each variation (for example: colour: green and size: large, Stock quantity: 2 products) the add to cart item counter (- & +) adds more products than two for the specific variation.
https://www.menscode.gr/product/lekis-jeans/
When i have a simple product with stock quantity (for example 4 products), the add to cart item counter works fine, it’s shows the correct number of products (4).
May 11, 2018 at 1:26 pm #955268Hi,
Thank you for the update. The account is not an admin so we can’t get in the dashboard. Please edit the config-woocommerce > woocommerce-mod.js file, look for this code around line 48.
newNum.val(the_val).trigger("change");
Replace it with this code..
if(the_val <= max) { newNum.val(the_val).trigger("change"); }
Make sure that the line that you will modify is under the “plus” button or this line.
plus.on('click', function(){
Best regards,
IsmaelMay 11, 2018 at 2:21 pm #955302Hello and thank you very much for your reply!
I have replaced the code in line 48 but the problem stays the same ! :(Also i gave you now an admin role for your account!
May 14, 2018 at 11:33 am #956370Hi,
The max attibute is set to “29” while the actual max attribute of the input field is set to the number of available stock. Please try to disable the “swatch” and “stock” extensions temporarily.
Best regards,
IsmaelMay 14, 2018 at 10:31 pm #956711Sorry but I don’t understand what you mean with the “Please try to disable the “swatch” and “stock” extensions temporarily” :(
Do you mean the WooCommerce Variation Swatches plugin? I have disabled it but.. the problem stays the same.May 16, 2018 at 4:55 pm #957586Hi gkarae,
Yes, Ismael is referring to these two plugins:
- WooCommerce Stock Manager
- WooCommerce Variation Swatches
Best regards,
NikkoMay 16, 2018 at 8:37 pm #957678ok!
I have disabled the two plugins
WooCommerce Stock Manager
WooCommerce Variation Swatches
but same problem.. :(May 19, 2018 at 10:28 pm #959212Hi,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( do be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create a admin user and post the login credentials in the “private data” field.Best regards,
BasilisMay 20, 2018 at 11:18 am #959410Hello, i have created a temporary login with the Temporary Login Without Password plugin.
In the private content area is the login link :)May 22, 2018 at 7:43 am #960158Hi,
Thanks for the info.
We adjusted the filter and moved it inside the functions.php file.
add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 25 ); function woocommerce_total_product_price() { if(!is_admin()) { global $woocommerce, $product; // let's setup our divs echo sprintf(' <div id="product_total_price" style="font-size: 16px; font-weight: 200;">%s %s</div> ',__('Total Price (incl Tax):','woocommerce'),'<span class="price">'. get_woocommerce_currency_symbol() .' ' .$product->get_price().'</span>'); ?> <script> jQuery(function($){ $(document).ready(function() { function setMinMax() { var price = <?php echo $product->get_price(); ?>; var currency = '<?php echo get_woocommerce_currency_symbol(); ?>'; var qtycont = $('.quantity'); var qty = qtycont.find('[name=quantity]'); var max = qty.attr('max'); var min = qty.attr('min'); if(typeof max === typeof undefined && max === false) return; qty.attr('data-qty', 1); $('.variations select').on('change', function() { qty.attr('data-qty', 1); qty.attr('value', 1); qty.text(1); }); qtycont.on('click', '.plus, .minus', function(){ var qtythis = $(this).find('[name=quantity]'); var qtyNum = $(qtythis.selector).attr('data-qty'); var max = $(qtythis.selector).attr('max'); var min = $(qtythis.selector).attr('min'); var totalQty = parseInt(qtyNum); if($(this).is('.plus') && qtyNum < max) { totalQty = parseInt(qtyNum) + 1; $(qtythis.selector).attr('data-qty', totalQty); } else if($(this).is('.minus') && qtyNum > min) { totalQty = parseInt(qtyNum) - 1; $(qtythis.selector).attr('data-qty', totalQty); } $(qtythis.selector).attr('value', totalQty); if (!totalQty < 1) { var product_total = parseFloat(price * totalQty); $('#product_total_price .price').html( currency + product_total); } }); } setTimeout(function() { setMinMax(); }, 300); $(document).on('updated_cart_totals', setMinMax); }); }); </script> <?php } }
It limits the quantity based on the stock. Please remove browser cache prior to checking the page.
Best regards,
IsmaelMay 22, 2018 at 7:51 am #960162Perfect!!!! Thank you very much for your help! it works fine! :)
Is this issue will be fine in the next enfold updates?
Can I update the enfold theme now or in the future if there will be new releases?May 23, 2018 at 4:47 pm #960946Hi!
I’m not sure if this is going to be included in the theme by default because it’s quite specific to your site or case. Please keep the filter in the child theme’s functions.php file. If you haven’t created a child theme yet, please refer to the documentation.
// https://kriesi.at/documentation/enfold/how-to-install-enfold-theme/#why-child-theme
Regards,
IsmaelMay 23, 2018 at 5:05 pm #960973Thank you again for your support! :)
May 23, 2018 at 5:58 pm #961033Hi gkarae,
Glad that Ismael helped you :)
Feel free to comeback if you need further assistance.
Thanks for using Enfold and have a great day!Best regards,
Nikko -
AuthorPosts
- The topic ‘Problem with the "add to cart" item counter in woocommerce for variable products’ is closed to new replies.