Results 1 to 10 of 42

Threaded View

  1. #27
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Known Bugs (and fixes) with v1.3.8

    Problem: Looking up fields in products and products_description and looking up fields in categories and categories_description ...

    There are two function in the functions_lookups that will pull any field that you need from the products or products_description tables by just passing it the products_id ... and for pulling any field from the categories and categories_description tables just by passing the categories_id ...

    However there is an error in both of them that needs a minor fix ...

    The original code for product lookup:
    /includes/functions/functions_lookups.php
    Code:
    /*
     * Return any field from products or products_description table
     * Example: zen_products_lookup('3', 'products_date_added');
     */
      function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $product_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                  where p.products_id ='" . (int)$product_id . "'
                                  and pd.language_id = '" . (int)$language . "'");
    
        $return_field = $product_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    The original code for category lookup :
    /*
    * Return any field from categories or categories_description table
    * Example: zen_categories_lookup('10', 'parent_id');
    */
    function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
    global $db;

    if (empty($language)) $language = $_SESSION['languages_id'];

    $category_lookup = $db->Execute("select " . $what_field . " as lookup_field
    from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
    where c.categories_id ='" . (int)$categories_id . "'
    and cd.language_id = '" . (int)$language . "'");

    $return_field = $category_lookup->fields['lookup_field'];

    return $return_field;
    }
    However, there is a little bug in these that you will want to update:

    The new code for products look up:
    Code:
    /*
     * Return any field from products or products_description table
     * Example: zen_products_lookup('3', 'products_date_added');
     */
      function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $product_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                  where p.products_id ='" . (int)$product_id . "'
                                  and pd.products_id = p.products_id
                                  and pd.language_id = '" . (int)$language . "'");
    
        $return_field = $product_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    The new code for categories look up:
    Code:
    /*
     * Return any field from categories or categories_description table
     * Example: zen_categories_lookup('10', 'parent_id');
     */
      function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
        global $db;
    
        if (empty($language)) $language = $_SESSION['languages_id'];
    
        $category_lookup = $db->Execute("select " . $what_field . " as lookup_field
                                  from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                  where c.categories_id ='" . (int)$categories_id . "'
                                  and c.categories_id = cd.categories_id
                                  and cd.language_id = '" . (int)$language . "'");
    
        $return_field = $category_lookup->fields['lookup_field'];
    
        return $return_field;
      }
    Last edited by Ajeh; 10 Mar 2009 at 11:41 PM.
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v155 Known Bugs (and fixes) with v1.5.5 , a, b, c, d, e, f
    By DrByte in forum Upgrading to 1.5.x
    Replies: 17
    Last Post: 16 Aug 2017, 03:25 AM
  2. v153 Known Bugs (and fixes) with v1.5.3
    By swguy in forum Upgrading to 1.5.x
    Replies: 9
    Last Post: 18 Oct 2016, 06:17 PM
  3. v151 Known Bugs (and fixes) with v1.5.1
    By DrByte in forum Upgrading to 1.5.x
    Replies: 4
    Last Post: 18 Oct 2016, 06:17 PM
  4. v150 Known Bugs (and fixes) with v1.5.0
    By DrByte in forum Upgrading to 1.5.x
    Replies: 5
    Last Post: 18 Oct 2016, 06:17 PM
  5. Known Bugs (and fixes) with v1.3.9
    By DrByte in forum Upgrading from 1.3.x to 1.3.9
    Replies: 5
    Last Post: 31 Oct 2010, 01:11 AM

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