Set Config
set_config is a special control-flow tag pair that lets you change CartThrob config/customer values at runtime using inline set_* commands (often inside conditionals).
It is designed to apply changes, save cart state, and reload the current URL so those changes are available on the next page render.
See also:
Variables
set_price_field
Sets the product price field mapping for a channel.
Supported params:
channelorchannel_id(required)field(required, or usevalueas fallback for field name){set_price_field channel="products" field="sale_price"}
set_shipping_plugin
Sets cart shipping plugin config for this cart context.
Required param:
value(shipping plugin short name or prefixed name)
Implementation normalizes value by prefixing shipping_ and then setting:
Cartthrob_shipping_{value}.
{set_shipping_plugin value="by_weight_ups_xml"}
set_customer_info
Sets a customer info field value in cart customer info.
Required params:
fieldvalue
If field starts with customer_, that prefix is removed automatically before save.
{set_customer_info field="first_name" value="Ace"}
set_CONFIG_NAME
Generic setter pattern:
{set_CONFIG_NAME value="..."}
If there is no dedicated set_config_CONFIG_NAME method, CartThrob falls back to:
cart->set_config(CONFIG_NAME, value)
This is useful for simple cart config keys where a direct value override is enough.
{set_number_format_defaults_prefix value="£"}
Behavior and Constraints
- This is a tag pair and uses only
set_*variables inside its body. - Tag parses EE conditionals using runtime data including:
- customer info (
customer_*aliases included) - cart info values
- segment variables
- global template variables
- customer info (
- Supported variable syntax:
{set_name ...}{set_config_name ...}
- For each parsed
set_*variable:- if matching method exists (
set_config_{name}), that method runs - otherwise, if
valueexists, genericcart->set_config(name, value)is used
- if matching method exists (
- Processed
set_*variables are removed from output. - Tag saves cart and redirects to the current URL so updates apply on the next render.
- Loop-prevention behavior:
- tag stores hash of processed tagdata in cart meta (
set_config_hash) - on immediate reload, matching hash short-circuits and clears hash
- tag stores hash of processed tagdata in cart meta (
- Practical result: this tag is effectively a no-output configuration helper.
set_customer_infocan also push mapped values to member fields when:- a member is logged in
save_member_dataconfig is enabled- a matching
member_{field}_fieldmapping exists
Examples
{exp:cartthrob:set_config}
{if group_id == 7}
{set_price_field channel="products" field="product_discounted_price"}
{if:else}
{set_price_field channel="products" field="product_price"}
{/if}
{/exp:cartthrob:set_config}
Set shipping plugin dynamically:
{exp:cartthrob:set_config}
{if segment_3 == "express"}
{set_shipping_plugin value="by_weight_ups_xml"}
{/if}
{/exp:cartthrob:set_config}
Set customer info from template context:
{exp:cartthrob:set_config}
{if logged_in}
{set_customer_info field="customer_type" value="member"}
{/if}
{/exp:cartthrob:set_config}