Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default zen_cfg_select_drop_down: Casting value to int?

    Why does the function, present in /YOUR_ADMIN/functions/general.php, force the $key_value to an int?
    Code:
      function zen_cfg_select_drop_down($select_array, $key_value, $key = '') {
        $string = '';
    
        $name = ((zen_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value');
        return zen_draw_pull_down_menu($name, $select_array, (int)$key_value);
      }

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: zen_cfg_select_drop_down: Casting value to int?

    ... because all the values for the dropdown <select> element are supposed to be integers.


    Are you encountering some other use-case?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,401
    Plugin Contributions
    87

    Default Re: zen_cfg_select_drop_down: Casting value to int?

    Quote Originally Posted by DrByte View Post
    Are you encountering some other use-case?
    Yes, the zen_cfg_select_option display takes up way too much room when there are a bunch of selections ... and the selections I need to "configure" require text-based values. I'll note that searching for the function's name in a vanilla Zen Cart 1.5.5e brings up only the definition in the function file.

    I've "cloned" that function for my use, dropping the (int) cast and it works like a charm!

  4. #4
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: zen_cfg_select_drop_down: Casting value to int?

    Curiously, when I first read your post I had "countries select" in my brain, not "config". So, the research I did before posting was limited to investigating country-related uses.

    I've been looking into the code further. The function was first added in v1.2.0 and has not been changed since then.
    The (int) cast appears to have been done to bridge the fact that the $key_value entries typically are drawn from database entries, where those values are stored as strings, despite primarily being numeric in content.

    I'm sure things could be safely reworked to allow that to be more flexible and still accomplish the same result.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. adding an asterisk to zen_get_products_display_price((int)
    By The_Mech in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 2 Mar 2012, 06:01 PM
  2. USPS INT Box size
    By ZL Conquistador in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 9 Feb 2011, 07:33 PM
  3. Int'l Shipping - very confused
    By devrahall in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 6 Nov 2008, 02:47 PM
  4. product_id max int 2147483647
    By bkubes in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 24 May 2008, 03:55 PM
  5. Overpriced Int'l UPS rates??
    By BEatMaKeR in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 16 May 2008, 03:44 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