Stock count not working after updating to V3.9 of plugin
-
Hi,
I’ve just updated the plugin to v3.9 and the stock quantites for products with variations are not working at all at the frontend of the site – every item either has “1 available” or “sold out”.
Is this a widespread issue?
-
Can you post a website link where we can see and make a screenshot of the variations settings in the backend.
Sure, here’s the link to one of the products where the variation quantity is being displayed incorrectly: https://217.199.187.191/marierouillon.com/shop/jewellery/red-leather-ring/
Here’s my variation related code for the single product template:
<?php if (wpsc_have_variation_groups()) { ?> <div class="wpsc_product_price"> <?php if(wpsc_product_is_donation()) : ?> <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>: </label> <input type="text" id="donation_price_<?php echo wpsc_the_product_id(); ?>" name="donation_price" value="<?php echo wpsc_calculate_price(wpsc_the_product_id()); ?>" size="6" /> <?php else : ?> <?php wpsc_the_product_price_display(); ?> <?php if(wpsc_product_has_stock()) { ?> <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="stock-display in_stock"><?php echo ('(') . wpsc_check_variation_stock_availability() . ('?available)'); ?></div> <?php } else { ?> <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="stock-display out_of_stock"></div> <?php } ?> <?php endif; ?> </div> <fieldset> <div class="wpsc_variation_forms"> <table> <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?> <tr><td class="col1"><label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td> <?php /** the variation HTML and loop */?> <td class="col2"><select class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>"> <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?> <option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option> <?php endwhile; ?> </select></td></tr> <?php endwhile; ?> </table> </div> </fieldset> <?php } else { ?> <div class="wpsc_product_price"> <?php if(wpsc_product_is_donation()) : ?> <label for="donation_price_<?php echo wpsc_the_product_id(); ?>"><?php _e('Donation', 'wpsc'); ?>: </label> <input type="text" id="donation_price_<?php echo wpsc_the_product_id(); ?>" name="donation_price" value="<?php echo wpsc_calculate_price(wpsc_the_product_id()); ?>" size="6" /> <?php else : ?> <?php wpsc_the_product_price_display(); ?> <?php if(wpsc_product_has_stock()) { ?> <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="stock-display in_stock"><?php echo ('(') . wpsc_product_remaining_stock() . ('?available)'); ?></div> <?php } else { ?> <div id="stock_display_<?php echo wpsc_the_product_id(); ?>" class="stock-display out_of_stock"></div> <?php } ?> <?php endif; ?> </div> <fieldset> <div class="wpsc_variation_forms"> <table> <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?> <tr><td class="col1"><label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td> <?php /** the variation HTML and loop */?> <td class="col2"><select class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>"> <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?> <option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option> <?php endwhile; ?> </select></td></tr> <?php endwhile; ?> </table> </div> </fieldset> <?php } ?>
Any ideas?
This might be a shot in the dark, but has ‘wpsc_check_variation_stock_availability()’ been depreciated?
Thanks for your help!
Hi Jase,
This is the only instance of this issue I’ve heard of. Beautiful site, by the way!
So,
wpsc_check_variation_stock_availability
was definitely not deprecated. Would you be able to send a screenshot of the values you have for stock on those variations?That’s very kind of you to say so, thanks!
Here’s a link to a screenshot of the variations for that particular product: https://www.dropbox.com/s/utin0vtlxgywnq9/Screenshot%202014-12-04%2017.32.26.png?dl=0
And here’s a screenshot where it says there are no variations, even though they are declared: https://www.dropbox.com/s/kmnwhbwanjlqbr3/Screenshot%202014-12-04%2017.32.38.png?dl=0
Thanks for your help guys.
Hey guys,
Was any of that information helpful?Aha! I found the fix… and of course it was an obvious mistake.
In ajax.php on line 422, for some reason I had put the following code in:
“‘variation_msg’ => __(‘(’) . wpsc_check_variation_stock_availability() . (‘ available)’),”When I should have done this:
“‘variation_msg’ => __(‘(’) . $stock . (‘ available)’),”The variations are displaying correctly when selected.
Thank you for your time and effort guys!
Hi Jase,
Hmm…I’d love for you to be able to not hack the core plugin there – that’s not going to be awesome for future upgrades.
We have a jQuery custom event called “wpsc_select_variation” that you could hook into – however, we’re not currently passing the number of available stock to that. That’s sort of lame. I’m going to open a Github issue to audit some of these AJAX functions to ensure we have the proper filtering in place so that good folks like you don’t have to hack the core plugin.
Sound good?
That sounds like a plan, thanks!
- The topic ‘Stock count not working after updating to V3.9 of plugin’ is closed to new replies.