CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

Get Live Rates Form

get_live_rates_form is a tag pair that outputs an HTML form for live-rate quote requests.

The generated form posts to update_live_rates_action, and {shipping_fields} outputs the active shipping plugin’s custom HTML input block.

Live-rate workflows are more advanced than fixed or threshold shipping because quote accuracy depends on complete shipping data and plugin/carrier behavior.

See also:

Parameters

In addition to these tag-specific parameters, this tag also supports shared Global Form Parameters.

return

Return path used after the action completes.

return="store/shipping"

secure_return

If truthy, return redirect is forced to HTTPS.

secure_return="yes"

shipping_plugin

Optional shipping plugin class name to use for this form/request.

This value is used in two places:

  1. To load plugin HTML for {shipping_fields}.
  2. As posted form data to the action.

If omitted, the currently configured shipping plugin remains active.

shipping_plugin="Cartthrob_shipping_ups"

shipping_option

Optional posted shipping option key to request a specific live-rate option.
If omitted, action logic requests rates for all options (ALL).

shipping_option="ground"

activate_plugin

When truthy with shipping_plugin, the action can persist that plugin as the cart’s active shipping plugin config.

activate_plugin="yes"

derive_country_code

Passed through as form data for shared customer-info save flow used by the action before rate lookup.

derive_country_code="yes"

shipping_mode (legacy anchor)

Kept for docs-anchor compatibility. This parameter is not used by the current GetLiveRatesFormTag implementation.

apply_costs (legacy anchor)

Kept for docs-anchor compatibility. Current live-rate behavior is controlled by posted action inputs (for example save_shipping) and plugin response handling.

Variables

shipping_fields

Outputs the current shipping plugin’s HTML field block (plugin->html).

Use this inside the form body so plugin-required inputs are submitted.

{shipping_fields}

The tag body is also parsed with global cart/customer/form variables (globalVariables(true)), so inline form error variables from form-builder flow are available.

Behavior and Constraints

  1. This tag outputs an HTML form (it does not fetch rates during template render).
  2. Generated form posts to update_live_rates_action.
  3. Form-data keys initialized by this tag: return, secure_return, derive_country_code, shipping_plugin, shipping_option, activate_plugin.
  4. Plugin HTML in {shipping_fields} comes from the selected plugin’s html property.
  5. On submit, action flow handles validation, quote lookup, and optional cheapest-rate save.
  6. If you want the action to auto-save cheapest returned option, post save_shipping="yes" in your form body.
  7. Live-rate accuracy depends on plugin-specific required inputs and shipping configuration.

Practical Notes

Live rates are usually best for stores with a defined shipping process (weights/dimensions/origin/destination/method rules kept current).
If shipping operations are less structured, fixed/threshold shipping setups are often easier to maintain and explain to customers.

Examples

Basic live-rates form:

{exp:cartthrob:get_live_rates_form
    return="store/shipping"
    shipping_plugin="Cartthrob_shipping_ups"
}
    {shipping_fields}
    <input type="submit" value="Get Live Rates" />
{/exp:cartthrob:get_live_rates_form}

Activate selected plugin and auto-save the cheapest returned option:

{exp:cartthrob:get_live_rates_form
    return="store/shipping"
    shipping_plugin="Cartthrob_shipping_ups"
    activate_plugin="yes"
}
    {shipping_fields}
    <input type="hidden" name="save_shipping" value="yes" />
    <input type="submit" value="Apply Live Rates" />
{/exp:cartthrob:get_live_rates_form}

Use with shipping options display:

{exp:cartthrob:get_live_rates_form return="store/shipping"}
    {shipping_fields}
    <input type="submit" value="Refresh Rates" />
{/exp:cartthrob:get_live_rates_form}

{exp:cartthrob:get_shipping_options}
    <option value="{option_value}" {selected}>{option_name}: {price}</option>
{/exp:cartthrob:get_shipping_options}