Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    114
    Plugin Contributions
    0

    Idea or Suggestion admin radio field

    Hello,

    I made some radio button on my admin products page (located admin/includes/modules/product/collect_info.php) but they don't remember the choice I made when I preview then submit the product properties.

    Can someone tell me how to make them remember what I chose ?
    I think I have to store this data in a database slot but I'm kind of lost here.

    thank you

    My code :

    <?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_radio_field('stock_status', '1', ($stock_ok)) . '&nbsp;' . TEXT_PRODUCT_IN_STOCK . '&nbsp;' . zen_draw_radio_field('stock_status', '2', ($stock_3_days)) . '&nbsp;' . TEXT_PRODUCT_3_DAYS . '&nbsp;' . zen_draw_radio_field('stock_status', '3', ($stock_5_days)) . '&nbsp;' . TEXT_PRODUCT_5_DAYS . '&nbsp;' . zen_draw_radio_field('stock_status', '4', ($stock_out)) . '&nbsp;' . TEXT_PRODUCT_OUT_OF_STOCK . '&nbsp;' . zen_draw_radio_field('stock_status', '5', ($stock_none)) . '&nbsp;' . TEXT_PRODUCT_NOTHING ; ?>

  2. #2
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: admin radio field

    Yep, that's definitely going to require storing the information in the database...

    First you'll need to determine which table to store the data in (most probably the one defined by TABLE_PRODUCTS). Then you'll need to add a new attribute to store the data in - say, products_stock_status. Now you have a place to store your data.

    Next you need to add a key to the $parameters array in collect_info.php to store the data as well ... then you'll need to modify the statements where the data is stored and retrieved from the database to include products_stock_status.

    Last (for the admin, anyway), you'll need to check to see if a value for products_stock_status is set and make it the selected choice in your radio button set. You will probably also want to check to make sure that something got selected for stock_status and return an error if it got left blank...

    This is all you need to do for the admin, but if you want to change what gets displayed in the cart to the customer, you'll need to modify includes/modules/YOUR_TEMPLATE/product_listing.php and includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php.


    Alternately, if you do not want to have to modify the core code, what would be better would be to create a new product type which would include the stock_status field. See here for instructions:
    http://www.zen-cart.com/wiki/index.php/Product_Types


    ZenCart is wonderfully customizable but for making changes beyond the templating system you'll really need to know PHP and MySQL ... if you're not well versed in them I suggest reading PHP and MySQL Web Development by Welling and Thompson.


    BrandTim

  3. #3
    Join Date
    Jul 2005
    Posts
    114
    Plugin Contributions
    0

    Default Re: admin radio field

    Ok, thank you.

    My part in includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php is already done and working.

    I just need to work on a way to store and retrieve data, I'll try what you've told me and post the result here.

    Again, thank you

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

    Default Re: admin radio field

    The product_music type is an example of extra data being stored in additional database tables.

    There is also a "book" product type in the downloads section that can be used as another, different, example.
    .

    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. v150 Attributes for color radio then match radio color with swatch total of 6 colors
    By RonGin in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 17 Apr 2013, 03:19 PM
  2. Price Field in Admin
    By Nick1973 in forum General Questions
    Replies: 1
    Last Post: 22 Jan 2011, 02:34 AM
  3. Radio button requires text field
    By bigdrunk in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 2 Jul 2010, 08:17 PM
  4. Replies: 4
    Last Post: 22 Sep 2008, 09:45 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