Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hide Products Notifications Box when item viewed is in stock?


Guest

Recommended Posts

2.3.4.1 CE

At present, the infobox for Product Notifications appears on every product_info page in the website.

No one needs to add an item to their notifications list that is available for purchase. 

How do I make the box appear only when viewing items that are out of stock?  Those are the items they need on their notifications lists.

Thanks!

- Andrea

Link to comment
Share on other sites

@puggybelle

Remember when we changed the 'Buy it Now' when there was no inventory? Let's see if you can do the same thing with the Product Notification box. Here's a hint:

/catalog/includes/modules/boxes/templates/product_notifications.php

Give it a go ... and let me/us know if you get stuck ...

M

Link to comment
Share on other sites

Oh, you know I'm stuck!!!!!!

I assume it's some kind of IF statement regarding quantity < 1 or = 0, like:

if ($product_info['products_quantity'] < 1) {   

And I have no idea what the ELSE statement would be. 

I've tried a few things and all I end up with is PHP code in my Notifications Box.

- Andrea

Link to comment
Share on other sites

@puggybelle

<sigh>

Try this (untested) ...

In /catalog/includes/modules/boxes/templates/product_notifications.php ... find

<div class="panel panel-default">
  <div class="panel-heading">
    <a href="<?php echo tep_href_link('account_notifications.php', '', 'SSL'); ?>">
      <?php echo MODULE_BOXES_PRODUCT_NOTIFICATIONS_BOX_TITLE; ?>
    </a>
  </div>
  <div class="panel-body">
    <?php echo $notif_contents; ?>
  </div>
</div>

(reformatted for clarity)

and replace with this;

<?php
  if($product_info['products_quantity'] <= 0) {
?>

<div class="panel panel-default">
  <div class="panel-heading">
    <a href="<?php echo tep_href_link('account_notifications.php', '', 'SSL'); ?>">
      <?php echo MODULE_BOXES_PRODUCT_NOTIFICATIONS_BOX_TITLE; ?>
    </a>
  </div>
  <div class="panel-body">
    <?php echo $notif_contents; ?>
  </div>
</div>

<?php
  }
?>

All I did was wrap the entire thing in an IF statement ...

HTH

M

Link to comment
Share on other sites

Well, I hate to break it to you, but...

It's not working.  The box still appears on both in and out of stock items.

???

- Andrea

 

Link to comment
Share on other sites

@puggybelle

(well, I did say it was untested, didn't I :rolleyes:)

I'm sure some of the better developers will have a better idea :wacko:, but let's try this ...

1) Revert the template file back to its original state (you did back it up, didn't you?)

2) In /includes/modules/boxes/bm_product_notifications.php, find:

        ob_start();
        include('includes/modules/boxes/templates/product_notifications.php');
        $data = ob_get_clean();
        $oscTemplate->addBlock($data, $this->group);

3) Replace with this: 

       if(tep_get_products_stock((int)$_GET['products_id']) <= 0) {
          ob_start();
          include('includes/modules/boxes/templates/product_notifications.php');
          $data = ob_get_clean();
          $oscTemplate->addBlock($data, $this->group);
        }

Basically, you are wrapping the entire code that displays the 'box' in the conditional IF statement, checking to see if there is any stock on hand for the product.

Like I said, I'm sure that there is a better way to do this, and I can not say what problems may arise from this ...

M

(ducking and running)

Link to comment
Share on other sites

Note:  I put the IF statement in the actual box code instead of the template file because ...

I *ASSUMED* that you did not want the left column to show an empty column if there was stock on hand. If I put it in the template file, it would prevent the body of the message box from displaying, but it would still display the header of the box, with nothing in it.

M

Link to comment
Share on other sites

@puggybelle

One more consideration ... since this is a 'stock' module that comes with osC that you can install or un-unstall, it would be a good idea to copy the stock code, rename it, and edit the renamed copy. Uninstall the stock module, and install the renamed module. This way, if you ever update osC, the update may overwrite the stock code, but leave your modified code alone.

M

Link to comment
Share on other sites

Good advice. 

On that note, I've spent thirteen YEARS running a 2.2 site that I never upgraded. 

Sure, I had problems along the way, mostly due to webhost PHP upgrades, changes on the server and whatnot.

I'm looking forward to going live with my new site and it has not been hacked up too much....certainly nothing like my old one.

I'm learning more and more about how the newest release works.  It still is difficult for me.  The good old days of editing catalog/includes/column_left.php are over.

It's mind-blowing to see the folder/file structure in 2.3.4.1 CE.

Nothing is where I expect it to be!  And when I locate something, it's in five different files, no less!

Thank You to everyone in this forum that has helped me in the last few weeks, I appreciate it so much!

- Andrea

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...