CartThrob Global Item Options Version 3.0.2
Overview
CartThrob Global Item Options lets you define reusable option groups (with optional price modifiers) and make them available across product entries.
Core behavior in current code:
- Option groups are managed in add-on CP (
groups,create-option-group,edit-option-group,delete-option-group). - Availability can be limited to selected CartThrob product channels.
- Two fieldtypes let you override global behavior per entry:
cartthrob_item_options_select(specific option values) andcartthrob_item_groups_select(specific option groups). - Price modifiers are injected through CartThrob extension hook
cartthrob_get_all_price_modifiers. - No module template tags are exposed in
mod.cartthrob_item_options.php.
Requirements
From live docs/release metadata:
- ExpressionEngine 5+
- CartThrob 5.4.5+
- PHP 7.1+
Installation
- Upload
cartthrob_item_optionsto/system/user/addons/. - Install
CartThrob Global Item Optionsfrom EE Add-on Manager. - Confirm CartThrob product channels are configured.
- Configure add-on
Settingsand create at least one option group. - Add fieldtypes to product channels if per-entry overrides are needed.
Upgrading
- Upload new add-on files over existing
cartthrob_item_optionsfolder. - Run add-on update in EE Add-on Manager.
- Recheck channel settings and option groups.
Notes from updater:
3.0.0migration adds/normalizes settings/options schema (primary keys, typed serialized values, site scoping).- Channel-selection legacy values
all/noneare migrated to explicit channel IDs/empty list.
Start Here (10-Minute Setup)
- Open
Add-ons > CartThrob Global Item Options > Settings. - Select product channels where global item options should apply.
- Open
Option Groupsand clickNew. - Set
Label(descriptive group name) andShort Name(unique, safe key such asglobal_size). - Add at least two option rows in the options grid:
option_name,option_value, and optionalprice. - Save.
- In product templates, output options with CartThrob core
{exp:cartthrob:item_options}tag.
Common Tasks With Examples
1. Create a Global Size Group
- Group label:
Shirt Sizes - Short name:
global_shirt_sizes - Rows:
Small,small,0.00Large,large,2.00
2. Restrict Global Options to Specific Product Channels
- In
Settings, check only channels where options should apply. - Entries in unselected channels will not receive these modifiers.
3. Override by Entry With Fieldtypes
- Add
CartThrob Global Item Options Multi Selectto product channel to whitelist specific option values. - Add
CartThrob Global Item Groups Multi Selectto product channel to whitelist specific groups.
4. Customize Option Data/Grid Behavior via Hooks
- Use
cartthrob_item_options_modify_option_datato alter row data before save. - Use
cartthrob_item_options_modify_option_gridto alter CP grid rendering.
Quick Links For Existing Users
- Need channel-scope behavior: see Settings
- Need option-group schema: see Create/Edit Option Group
- Need fieldtype behavior: see Fieldtypes and Template Output
- Need runtime modifier logic: see Runtime Hooks and Behavior
Control Panel Reference
Base route: addons/settings/cartthrob_item_options
Sidebar
Items:
Option Groups(withNewbutton)Settings- external
Documentation
Settings
Route: settings
Form field:
global_item_options_channels(checkbox list)- list is limited to CartThrob
product_channels
Behavior:
- If no product channels are configured, CP shows an important alert and no settings form.
- Saved under settings key
global_item_options_channelsfor currentsite_id.
Option Groups List
Route: groups
Table columns:
IDLabelShort NameManage(toolbar)
Manage actions:
Editopensedit-option-group/{id}Removeopensdelete-option-group/{id}
Create/Edit Option Group
Routes:
create-option-groupedit-option-group/{id}
Fields:
label(required)
- descriptive name shown in CP and labels map
short_name(required)
- unique machine key used when adding modifiers to CartThrob
datagrid (required)
- columns:
- option_name (descriptive)
- option_value (value key)
- price (optional modifier)
Save behavior:
- Row data normalized into serialized array structure.
- Hook
cartthrob_item_options_modify_option_datacan mutate row data before model save. - Hook
cartthrob_item_options_modify_option_gridcan mutate displayed grid object.
Delete Option Group
Route: delete-option-group/{id}
Behavior:
- requires
confirm = yto delete - on success, redirects back to
groupswith success alert
Fieldtypes and Template Output
cartthrob_item_options_select
Name: CartThrob Global Item Options Multi Select
Purpose:
- lets entry editor choose specific option values to include for that entry
Source of choices:
- all option rows from all global option groups
- option label format in CP:
{group_label}: {option_name} - submitted value is
option_value
Storage:
- stored as EE encoded multi-value field
Template output behavior (replace_tag):
- single output: pipe-delimited string by default
- supports
limit - supports
markup="ul"|"ol" - pair output provides variables:
{item}{count}- supports
backspacein pair mode
cartthrob_item_groups_select
Name: CartThrob Global Item Groups Multi Select
Purpose:
- lets entry editor choose which global option groups apply to that entry
Source of choices:
- global option groups (
short_name=>label)
Storage/output behavior:
- same multi-value encode/decode pattern
- same
replace_tagparsing behavior and parameters as above (limit,markup,backspace, pair varsitem/count)
Runtime Hooks and Behavior
Extension Hooks Registered by Updater
cartthrob_get_all_price_modifiers->cartthrob_get_all_price_modifierscartthrob_add_settings_nav->cartthrob_add_settings_nav
Modifier Assembly Logic
On cartthrob_get_all_price_modifiers($entry_id):
- Loads entry channel + fieldtype presence.
- Reads per-entry selected option values (if fieldtype exists).
- Reads per-entry selected groups (if fieldtype exists).
- Applies global channel restriction from settings.
- Loads all option groups, stores cart meta:
- global_item_options
- item_option_labels map (short_name => group label)
6. Builds per-group option arrays and merges with existing modifier stack from prior extension calls.
Filtering behavior summary:
- If entry-level selected option values exist, options are filtered by those values.
- If entry-level selected groups exist, only those groups are included.
- If no entry overrides exist, all global groups/options apply (subject to channel restriction).
Changelog
Version 3.0.2
Release December 13, 2021
addon.setup.phpversion marker is3.0.2.
Version 3.0.1
Release March 17, 2021
Version 3.0.0
Release December 19, 2020
- Upgraded for CartThrob 5.4.5+.
- CP screens moved to EE shared form/styles.
- Fieldtypes aligned to EE option/shared select views.
- Settings/options schema updates and data migration support.
- Added
ItemOptionandSettingmodels.