Jump to content

Checkboxes to select options


hairydog

Recommended Posts

I want to add product options that are selected using a checkbox. seems a fairly normal thing to want, but it isn't available on the drop-down list of option group types.

I can choose between Dropdown list, Radiobutton list, Textbox and Textarea. Nothing else is offered.

In catalogue.class.php it says

    const OPTION_SELECT     = 0;
    const OPTION_TEXTBOX    = 1;
    const OPTION_TEXTAREA   = 2;
    const OPTION_PASSWORD = 3;
    const OPTION_RADIO  = 4;
    const OPTION_CHECKBOX = 5;
    const OPTION_DATEPICKER = 6;
    const OPTION_HIDDEN  = 7;
    const OPTION_FILE  = 8;


    private $_options_selectable = array( // fixed values
        self::OPTION_SELECT,
        self::OPTION_RADIO,
        self::OPTION_CHECKBOX,
        self::OPTION_HIDDEN,
    );
    
    private $_options_textual = array(
        self::OPTION_TEXTBOX,
        self::OPTION_TEXTAREA,
        self::OPTION_PASSWORD,
        self::OPTION_DATEPICKER,
        self::OPTION_FILE,
    );

so the other options must be being switched off somewhere else. But I can't work out where!

Link to comment
Share on other sites

CubeCart originally had single-response values for options, that is to say, "Color:Blue" or "Size:15". A checkbox implies a multiple-response value for an option, such as "Flavor Mix: Cherry, Lemon, Grape" (from a larger set). I think the ability to handle multiple-response values for an option has not yet been coded in CubeCart.

However, in the admin script /sources/products.options.inc.php, near line 270, the variable $optionTypes is set as an array with integer keys mapped to the form element type. Immediately following is a hook that can be used to add more types (use the map in the Catalogue class) - even custom types.

As mentioned, if using a checkbox form element, there is a lot more enhancement necessary to have CartCart treat the form POST as anything more than a radio button.

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the suggestion, but this is for a non-profit setup that could not afford it. So whether or not it works for them, it isn't a solution.

On 1/19/2020 at 10:43 PM, bsmither said:

CubeCart originally had single-response values for options, that is to say, "Color:Blue" or "Size:15". A checkbox implies a multiple-response value for an option, such as "Flavor Mix: Cherry, Lemon, Grape" (from a larger set). 

That's one interpretation, but it could also be "vegan" or "not vegan".

At present, the only way to do this is a pair of radiobuttons, which is logically the same, but aesthetically inferior.

If a radiobutton group of two could be replaced with a single checkbox, using the same logic, it would be useful in many cases. 

Link to comment
Share on other sites

I concur.

In a somewhat similar vein, an appliance can have a 1-year service contract, 5-year service contract, or no service contract. This is presented in a drop-down selector. (The 'no option selected' option would be understood to be an opt-out selection.)

One radio button could suffice but brings with it a certain difficulty. Initially not checked, but once checked, it will stay checked.

I will be experimenting with this shortly.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...