-
1. Re: Hide content with {tag_instock, true}
BCTemple Jan 5, 2013 7:35 AM (in response to Spencer_wes)Hey Wes.
You could hide the span using CSS, then tell Javascript/jQuery to also hide the form if the span has a 0, if it has any other number leave as is? Javascript numerics is pretty handy, you can do all sorts with it.
Kind regards,
Justin -
2. Re: Hide content with {tag_instock, true}
Spencer_wes Jan 5, 2013 10:40 AM (in response to BCTemple)Hi Justin,
Thanks for the response! I did try the following script:
<div id="stock">{tag_instock, true}</div>
<div id="slave1">SOLD OUT</div>
<script>
$(document).ready(function(){
var n = $("#stock").text();
$("#slave1").css("display", (n < 1) ? "inline" : "none");
$("#slave2").css("display", (n < 1) ? "inline" : "none");
});
</script>
excuse my syntax, I'm still a novice at JavaScript. Problem was that if you change the attribute the script wouldn't react to it. In other words the script would only react to the default stock value the page loads with.
any ideas?
Wes
-
3. Re: Hide content with {tag_instock, true}
BCTemple Jan 5, 2013 7:50 PM (in response to Spencer_wes)Hi Wes,
This is untested, but you could check initially on page load as well as each time the add to cart button is clicked.
You really just need to re-run the code whenever the value changes.
Something like this perhaps: http://jsfiddle.net/M6GZb/
You can manually test it by changing the span value then pressing run. I have not tested this live in BC to make sure it works with the add to cart button. BC is known for killing DOM in eCommerce.
I've also made a couple of assumptions like your add to cart button being the standard BC image and inside the quantity UL LI. You might need to adjust a couple of things to make it work with your setup.
Replace the span in jsFiddle with {tag_instock,true} when you test it in BC.
Let me know if that works for you.
Cheers,
Justin -
4. Re: Hide content with {tag_instock, true}
Spencer_wes Jan 5, 2013 11:25 PM (in response to BCTemple)Hey Justin,
Thanks again mate for your help! I've put your script into the product details page of my site:
http://www.kiph.co.za/all-products/save-water-graphic-tee
if the product loads an initial stock value of 0 the script works perfectly, however if i change the attribute variation to eg: "small" size nothing happens.
unlike the product grouping dropdown, the new attribute dropdown doesn't refresh the page...
Regards,
Wes
-
5. Re: Hide content with {tag_instock, true}
BCTemple Jan 6, 2013 7:10 PM (in response to Spencer_wes)Hey Wes,
Of course, I forgot about the new inventory control! So you need the code to run when the <select> is clicked.
Since you're going straight to cart when you buy a product you don't really need the code running when the add to cart button is pressed so replace the last line with:
$('.catProdAttributeItem select').click(displaySlaves)
Cheers,
Justin -
6. Re: Hide content with {tag_instock, true}
Spencer_wes Jan 6, 2013 10:47 PM (in response to BCTemple)Justin you beauty! thanks champ!
-
7. Re: Hide content with {tag_instock, true}
BCTemple Jan 7, 2013 1:33 AM (in response to Spencer_wes)No worries, glad it worked!

