Site maintenance: Tuesday 17 Nov, from 10:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / General Questions / Product page, execute code on out of stock

Product page, execute code on out of stock

Started by digitalshadow on 13 Mar 2011, 10:02 AM · Views: 2,644

Results 1 to 3 of 3
13 Mar 2011, 10:02 AM
#1
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Product page, execute code on out of stock

Would it be possible to write some code so that when a visitor visits a product page, if it is out of stock the site will pop a lightbox up that will display some links?

I already use a lightbox for product images, so I presume I can use the same light box .js code?

Would anyone be able to help me and give me an idea where I should start?

Aim - If out of stock lightbox pop up displaying some links and text

13 Mar 2011, 4:02 PM
#2
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Product page, execute code on out of stock

<?php
echo '<script type="text/javascript">';
echo 'function myFunction(){ window.location = "http://www.someurl.co.uk/" };';
echo '</script>';

if ($products_quantity == 0) {
    echo '<BODY onLoad="myFunction()">';
}
?>

right, all i need now is for someone to help me write the code to go in my function :)

nothing much :hug:

13 Mar 2011, 4:30 PM
#3
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Product page, execute code on out of stock

<script language="JavaScript">
function loadalert () 

        {alert("Text here")

}
</script>

<?php if ($products_quantity == 0) {
    echo '<body onLoad="loadalert()">';
}
?>

at the moment I'm using that

URL's can't be placed in alert boxes, perhaps a high z placed div would work better