Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2006
    Posts
    40
    Plugin Contributions
    0

    Default 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.

  2. #2
    Join Date
    Aug 2004
    Posts
    1,590
    Plugin Contributions
    1

    Default 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:

    PHP Code:
    $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 . . .
    Last edited by TheOracle; 14 Jun 2007 at 04:19 PM.

  3. #3
    Join Date
    Jul 2006
    Posts
    40
    Plugin Contributions
    0

    Default 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!
    Last edited by Hemma; 14 Jun 2007 at 11:52 PM.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,590
    Plugin Contributions
    1

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

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

  5. #5
    Join Date
    Aug 2004
    Location
    Saint Petersburg, Russia
    Posts
    1,786
    Plugin Contributions
    13

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

    Code:
    if ($_GET['main_page'] == 'product_info' && isset($products_quantity) && $products_quantity <= 0) $show_feature= true;

  6. #6
    Join Date
    Jul 2006
    Posts
    40
    Plugin Contributions
    0

    Default 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:


    PHP Code:
    // 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_notificationstrue;
          }
        } else {
          
    $show_product_notificationstrue;
        }
      } 
    to this:

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

    else {
          
    $show_product_notificationsfalse;
        } 
    It doesn't seem to work.... Sorry to sound stupid , 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

  7. #7
    Join Date
    Aug 2004
    Location
    Saint Petersburg, Russia
    Posts
    1,786
    Plugin Contributions
    13

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

    PHP Code:
    // 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_notificationstrue;
          }
        } else {
          
    $show_product_notificationstrue;
        }
      } 

  8. #8
    Join Date
    Jul 2006
    Posts
    40
    Plugin Contributions
    0

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

    Thanks! that worked beautifully!!!!

 

 

Similar Threads

  1. Using Zones & UK Express (flat clone) help pls :(
    By claire31373 in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 11 Apr 2012, 10:32 PM
  2. Help!! Need to display attribute for one product using two different pricing options
    By a1000w in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 12 Aug 2009, 06:09 PM
  3. [help] display hit counter in sidebox
    By whitedevil in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Nov 2007, 03:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR