Results 1 to 9 of 9
  1. #1

    Default Issue with Read Only / Radio Buttons

    Hi,

    I hope someone has found a way to do this before me...

    I need to have a simple attribute to control price. This is because one major supplier insists on prices only being displayed at the end of product_info and not on listings. I've managed to hack the display price to show a graphic when product id priced by attribute - all I need now is for pricing by attribute to behave the way I need...

    If I use a 'Read Only' option type, the display is perfect, but the price is not added in (can this be turned on anywhere? if not, why allow price details for read-only attributes?).

    If I use a single value in an option type that does work properly on price - then I get an ugly radio button when I don't want one.

    Right now, I just need the easiest hack to (a) fix the bug in read-only, or (b) hide the radio button for single options.

    Many thanks in advance,

    S

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

    Default Re: Issue with Read Only / Radio Buttons

    READ ONLY are just that READ ONLY they are not made for being added to the Product on orders they are there for information that can quickly be updated globally by making a change to the READ ONLY Option Name or Option Value ...

    Attributes are either Radio buttons or Dropdowns or Input boxes or Check boxes ...

    You would have to customize the code to manage the attributes differently where the attributes are all assumed to always be included in the price and done with hidden variables etc.

    But ... if you change anything where now there are optional choices this breaks all ...

    You could build in further customization where if there is only 1 attribute on the product ... then try to build in the hidden amount ...

    NOTE: READ ONLY is NOT a bug ... it is meant to work that way intentionally ...
    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!]
    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!

  3. #3

    Default Re: Issue with Read Only / Radio Buttons

    Thanks Linda for your speedy reply.

    I guess if a name/value/price combination is compulsory, it's not really an option, is it. As it happens I like the bullet appearing when it's a 'single dropdown'. All the attributes options work just the way I expect, except for r-o, so...

    A third option...
    If I were to add an option type 'Compulsory' which was basically read-only that *did* get counted toward price, that would be cleanest. Any "gotchas" before I dive in?

    Thanks,

    Keith

  4. #4

    Default Re: Issue with Read Only / Radio Buttons

    Actually, scrap that 'third option'.

    I'll be looking to mod my code so that read-only does get included in calculation. I'll let you know how I get on (any pointers warmly received).

    I note that there is a separate 'display-only' button which could be used to revert back to non-calculating behaviour if required. (Although, hitherto, if I use it checkout informs me I've made an invalid selection - but it's probably me missing something obvious).

    Thanks again,

    Keith

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

    Default Re: Issue with Read Only / Radio Buttons

    Read Only attributes are strictly designed to display text on products and have no other use to them and are ignored everywhere ...

    You would be better off I think finding a method to manage the single attribute on a Product than trying to change the way Read Only attributes work ...
    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!]
    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!

  6. #6

    Default Re: Issue with Read Only / Radio Buttons

    Thanks Linda, I hope you'll forgive my choosing to follow the path least trodden!

    I've managed to get values entered against Read Only fields handled how I'd like. For the benefit of any others who might stumble across this thread, I'll share how I did it.

    There were two main problems encountered.

    Firstly, the function zen_has_product_attributes in functions_lookups.php needed a bit of a tidy. The existing code was at odds with the published behaviour of PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED (although the name and published description are a bit confusing) and the test for $not_readonly=='true' was superfluous. The following tidy version meant that it behaved correctly everywhere (and still allowed the default behaviour if PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED was set to '0').

    PHP Code:
    /*

     *  Check if product has attributes

     */

      
    function zen_has_product_attributes($products_id$not_readonly 'true') {

        global 
    $db;

        

        if (
    PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED == '1') {

          
    // READONLY attributes ARE ALLOWED TO BE ADDED TO CART

          
    $attributes_query "select pa.products_attributes_id

                               from " 
    TABLE_PRODUCTS_ATTRIBUTES " pa left join " TABLE_PRODUCTS_OPTIONS " po on pa.options_id = po.products_options_id
                               where pa.products_id = '" 
    . (int)$products_id "' limit 1";
                              

        } else {

          
    // regardless of READONLY attributes no add to cart buttons

          
    $attributes_query "select pa.products_attributes_id

                               from " 
    TABLE_PRODUCTS_ATTRIBUTES " pa

                               where pa.products_id = '" 
    . (int)$products_id "' and po.products_options_type != '" PRODUCTS_OPTIONS_TYPE_READONLY "' limit 1";

        }

        
    $attributes $db->Execute($attributes_query);



        if (
    $attributes->recordCount() > && $attributes->fields['products_attributes_id'] > 0) {
            
          return 
    true;

        } else {
        
          return 
    false;

        }

      } 
    Secondly, the value of the option was not being passed into the cart (because the readonly wording was not a form input type).

    This was changed by replacing the code in attributes.php below...
    PHP Code:
     // READONLY

                      
    case ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY):

                      
    $options_name[] = $products_options_names->fields['products_options_name'];
                      
    $options_menu[] =  . $tmp_html "\n"
    to read
    PHP Code:
                     // READONLY

                      
    case ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY):

                      
    $options_name[] = $products_options_names->fields['products_options_name'];
                      
    $options_menu[] = zen_draw_hidden_field('id[' $products_options_names->fields['products_options_id'] . ']'$products_options_value_id) . ' ' $tmp_html "\n"
    And lo! It all works beautifully.

    If I knew how, I'd wrap an
    PHP Code:
    if (PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED == '1') { ... } 
    around the $options_menu change so that behaviour was consistent, predictable, optional and compliant (and good for production). But since I didn't (don't) know PHP 'til today, you'll understand why I draw the line once it works for me;-)

    Thanks again for your guidance, and I hope the attached proves useful for other novice zenners straying this way,

    Keith

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

    Default Re: Issue with Read Only / Radio Buttons

    Glad you were able to change the behavior of READ ONLY attributes to work in a totally different manner than they were intended for your site ...

    Be sure to watch of changes in upgrades that will revert them back to how they were intended to be used ...
    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!]
    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!

  8. #8

    Default Re: Issue with Read Only / Radio Buttons

    Cheers,

    Please consider firming up switching with the existing 'PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED' in the upgrade. We're 95% there; and its prior existence indicates others have looked at this issue before me. We can keep backward compatibility and allow for awkward cases like mine.

    Results are here

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

    Default Re: Issue with Read Only / Radio Buttons

    I am not sure why we would want to change the code ... it is not meant to have READ ONLY attributes work like the other attributes ...

    They are not meant to be added to the shopping_cart ... nor are they meant to be added to the order ...

    Their only purpose is to be READ ONLY so that you can have global information that can be changed based on the text that they display ...
    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!]
    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. Stuck with radio buttons
    By jabbawest in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 13 Jul 2010, 04:29 PM
  2. Login Page: Remove HTML & TEXT-Only Radio Buttons
    By MeltDown in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 23 Jun 2009, 10:27 AM
  3. Radio Buttons With No Label
    By fotofx in forum Setting Up Categories, Products, Attributes
    Replies: 4
    Last Post: 6 Jun 2008, 03:48 AM
  4. can I Remove the HTML & TEXT-Only options and Radio Buttons ?
    By jdunique in forum General Questions
    Replies: 6
    Last Post: 29 Apr 2008, 02:26 PM

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