Zen Cart Logo
Forums / Addon Sideboxes / using 'if' to display a sidebox... Help pls!

using 'if' to display a sidebox... Help pls!

Locked

Views: 1,822

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
14 Jun 2007, 2:16 PM
#1
hemma avatar

hemma

New Zenner

Join Date:
Jul 2006
Posts:
37
Plugin Contributions:
0

using 'if' to display a sidebox... Help pls!

Hi guys,

I've been doing a LOT of searching, and just wanted to know, how can I make a sidebox only show itself when the product i am showing on that page has a value of products_quantity = 0
I want to use this in an if ($_GET ['products_quantity'] = 0) {$show_feature= true}
but i think i must have mucked up somewhere.

Sorry guys, but I am totally new to actually coding stuff.... and searching the entire forum didn't answer my prayers.

Any help would be greatly appreciated.

14 Jun 2007, 3:13 PM
#2
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: using 'if' to display a sidebox... Help pls!

Here's an example you can use on how you can get your products quantity globally:

$products = $_SESSION['cart']->get_products();
for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
if (isset($products[$i]['products_quantity']) && $products[$i]['products_quantity'] == 0) {
$show_feature = true;
} // End of if statement.
} // End of for statement.

In the mean time, when I think of it, are you looking for to validate specific products or your entire store's products quantity ? The above will show for the whole store for products quantity . . .

14 Jun 2007, 10:49 PM
#3
hemma avatar

hemma

New Zenner

Join Date:
Jul 2006
Posts:
37
Plugin Contributions:
0

Re: using 'if' to display a sidebox... Help pls!

Well I am looking at creating a sidebox which will only be visible when the item is out of stock.....

I will have a go at that code tonight and report on results.....

Thanks!

15 Jun 2007, 3:09 AM
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: using 'if' to display a sidebox... Help pls!

That does sound interesting. Let me know of the results. :smile:

15 Jun 2007, 11:38 AM
#5
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: using 'if' to display a sidebox... Help pls!

if ($_GET['main_page'] == 'product_info' && isset($products_quantity) && $products_quantity <= 0) $show_feature= true;
17 Jun 2007, 8:17 AM
#6
hemma avatar

hemma

New Zenner

Join Date:
Jul 2006
Posts:
37
Plugin Contributions:
0

Re: using 'if' to display a sidebox... Help pls!

Hi Folks,

Thanks for the tips on coding the sidebox, and i've been trying for a fair bit, but the coding still seems to not work. I think it has to do with what i am trying to do:

I'll try to explain a little better:

I am trying to modify the existing 'Product Notification sidebox', to only show, so that when the item is out of stock, that sidebox appears, and i can let clients know when the item will come back in stock... I've searched all over and couldn't find the answer. So hoping to make the sidebox work the way i want it to, i tried modifying the existing code of:

// test if box should show
  $show_product_notifications = false;

  if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
    if (isset($_SESSION['customer_id'])) {
      $check_query = "select count(*) as count
                      from " . TABLE_CUSTOMERS_INFO . "
                      where customers_info_id = '" . (int)$_SESSION['customer_id'] . "'
                      and global_product_notifications = '1'";

      $check = $db->Execute($check_query);

      if ($check->fields['count'] <= 0) {
        $show_product_notifications= true;
      }
    } else {
      $show_product_notifications= true;
    }
  }

to this:

$show_product_notifications = false;
 
if ($_GET['main_page'] == 'product_info' && isset($products_quantity) && $products_quantity <= 0) { $show_product_notifications = true; } 

else {
      $show_product_notifications= false;
    }

It doesn't seem to work.... Sorry to sound stupid :blush:, but its my first time trying to do any coding work....:(

Looking at it, i should have left the globals back in there, shouldn't i?

Any help would be greatly appreciated!!!

Thanks

17 Jun 2007, 9:45 AM
#7
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: using 'if' to display a sidebox... Help pls!

// test if box should show
  $show_product_notifications = false;

  if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id']) and zen_get_products_stock($_GET['products_id']) <= 0) {
    if (isset($_SESSION['customer_id'])) {
      $check_query = "select count(*) as count
                      from " . TABLE_CUSTOMERS_INFO . "
                      where customers_info_id = '" . (int)$_SESSION['customer_id'] . "'
                      and global_product_notifications = '1'";

      $check = $db->Execute($check_query);

      if ($check->fields['count'] <= 0) {
        $show_product_notifications= true;
      }
    } else {
      $show_product_notifications= true;
    }
  }
17 Jun 2007, 1:54 PM
#8
hemma avatar

hemma

New Zenner

Join Date:
Jul 2006
Posts:
37
Plugin Contributions:
0

Re: using 'if' to display a sidebox... Help pls!

Thanks! that worked beautifully!!!!