Add notify email link to out of stock items

This mod will add a link to out of stock items. A customer can click that link to open an email and send a request to the store owner, asking them to notify them when the item is back in stock. (See also: Add notify email link to product descriptions)

  1. Open the products_variables.php file in the /enc/ folder.

  2. Change the code:

    // OUT OF STOCK
    if (!function_exists("var_oos"))
    {
    function var_oos($varoos, $varinv)
    {
    global $label_oos, $inventorycheck;
    $varutofstock = "";
    if ($varoos == "Yes" OR ($varinv <= 0 AND $varinv != "" AND $inventorycheck == "Yes"))
    $varoutofstock = $label_oos;
    return $varoutofstock;
    }
    }

    to:

    // OUT OF STOCK
    if (!function_exists("var_oos"))
    {
    function var_oos($varoos, $varinv)
    {
    global $label_oos, $inventorycheck, $searchrow, $urldir, $Site_Name, $Admin_Email;
    $varutofstock = "";
    if ($varoos == "Yes" OR ($varinv <= 0 AND $varinv != "" AND $inventorycheck == "Yes"))
    {
    $varitemid = $searchrow[ID];
    $varitemname = stripslashes($searchrow[Item]);
    $varemailsubject = "$Site_Name Item Notification";
    $varitemlink = doItemLink($varitemname, $varitemid, "auto");
    $varemailtitle = "Notify me when this item is in stock";
    $varemailbody = "Please contact me when the item%0D%0A%0D%0A$varitemname%0D%0A$varitemlink%0D%0A%0D%0Ais back in stock.";
    $varemail_subject = str_replace(" ", "%20", $varemailsubject);
    $varemail_body = str_replace(" ", "%20", $varemailbody);
    $varoutofstock = $label_oos ."
    $varemailtitle"; } return $varoutofstock; } }
  3. Optional! Change any of the following, if desired:

    1. Link text: To change the link text, change the line:

      $varemailtitle = "Notify me when this item is in stock";

      changing the text within the quotes to whatever you'd like.

      Alternately, you can use HTML (including images), as in:

      $varemailtitle = "Notify me when this item is in stock";

      Notice that you must add a back slash in front of each double quote within your HTML code.

    2. Subject: To change the subject of the email, change the line:

      $varemailsubject = "$Site_Name Notify Item";

      changing the text within the quotes to whatever you'd like.

      Note that you can use $Site_Name to represent the web site's name. (This will pull whatever name is set in the store admin area.)

    3. Body: To change the body of the email, change the line:

      $varemailbody = "Please contact me when the item%0D%0A%0D%0A$varitemname%0D%0A$varitemlink%0D%0A%0D%0Ais back in stock.";

      changing the text within the quotes to whatever you'd like. Use %0D%0A to represent a line break.

      Note that $varitemname represents the name of the item, and $varitemlink represents a link to the item on your site.

  4. Save and reload the file.