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

Developer Hooks

This page documents the CartThrob extension hooks verified in the bundled CartThrob 9.0.1 source. Hook examples use ExpressionEngine extension method bodies; register each method against the matching hook name in your add-on’s setup or update file.

Most hooks either notify your extension that something happened or let you replace a value CartThrob is about to use. When CartThrob assigns the hook call to a variable, return the same type documented below. When CartThrob checks ee()->extensions->end_script, setting it to true stops the current CartThrob action after your hook runs.

Suggested Hook Layout

Use this structure when adding new hooks to this page:

  • Fires: When CartThrob calls the hook.
  • Parameters: Every value passed to the extension method.
  • Returns: Whether CartThrob uses the return value.
  • How CartThrob calls it: The relevant ee()->extensions->call() snippet.
  • Example: A small extension method showing the intended use.

Hooks

Cart Forms

cartthrob_add_to_cart_start

Fires: Before CartThrob validates and processes an add-to-cart action or {exp:cartthrob:add_to_cart} tag.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the add-to-cart action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_add_to_cart_start');

Example:

public function cartthrob_add_to_cart_start()
{
    ee()->logger->developer('CartThrob add-to-cart started');
}

cartthrob_add_to_cart_end

Fires: After CartThrob adds an item to the cart, before the action completes.

Parameters:

  • $item (Cartthrob_item|null): The item object CartThrob attempted to add.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before form completion or tag redirect.

How CartThrob calls it:

ee()->extensions->call('cartthrob_add_to_cart_end', $item);

Example:

public function cartthrob_add_to_cart_end($item)
{
    if ($item) {
        ee()->logger->developer('Added product ' . $item->product_id());
    }
}

cartthrob_delete_from_cart_start

Fires: Before CartThrob removes an item from the cart.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the delete action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_delete_from_cart_start');

Example:

public function cartthrob_delete_from_cart_start()
{
    ee()->logger->developer('Cart item delete started');
}

cartthrob_delete_from_cart_end

Fires: After CartThrob removes an item from the cart, before the action completes.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before form completion or tag redirect.

How CartThrob calls it:

ee()->extensions->call('cartthrob_delete_from_cart_end');

Example:

public function cartthrob_delete_from_cart_end()
{
    ee()->logger->developer('Cart item delete completed');
}

cartthrob_update_cart_start

Fires: Before CartThrob validates and processes an update cart form.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the update action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_update_cart_start');

Example:

public function cartthrob_update_cart_start()
{
    ee()->logger->developer('Cart update started');
}

cartthrob_update_cart_end

Fires: After CartThrob updates cart items or clears the cart, before coupon handling and inventory checks.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the update action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_update_cart_end');

Example:

public function cartthrob_update_cart_end()
{
    ee()->cartthrob->cart->set_custom_data('updated_at', ee()->localize->now);
}

cartthrob_multi_add_to_cart_start

Fires: Before CartThrob validates and processes a multi-add-to-cart form.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the multi-add action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_multi_add_to_cart_start');

Example:

public function cartthrob_multi_add_to_cart_start()
{
    ee()->logger->developer('Multi add-to-cart started');
}

cartthrob_multi_add_to_cart_end

Fires: After CartThrob loops through the submitted product IDs and adds valid items to the cart.

Parameters:

  • $entry_ids (array|string|null): The submitted entry_id input.
  • $items (array): Added Cartthrob_item objects keyed by entry ID when available.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the action before form completion.

How CartThrob calls it:

ee()->extensions->call('cartthrob_multi_add_to_cart_end', $entry_ids, $items);

Example:

public function cartthrob_multi_add_to_cart_end($entry_ids, $items)
{
    ee()->logger->developer('Added ' . count($items) . ' items with multi add');
}

cartthrob_save_customer_info_start

Fires: Before CartThrob validates a save-customer-info form.

Parameters: None.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_save_customer_info_start');

Example:

public function cartthrob_save_customer_info_start()
{
    ee()->logger->developer('Saving CartThrob customer info');
}

cartthrob_save_customer_info_end

Fires: After CartThrob successfully saves customer information.

Parameters: None.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_save_customer_info_end');

Example:

public function cartthrob_save_customer_info_end()
{
    ee()->logger->developer('CartThrob customer info saved');
}

cartthrob_checkout_action_start

Fires: At the beginning of checkout form processing, before checkout options are collected.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop checkout before customer info or payment processing.

How CartThrob calls it:

ee()->extensions->call('cartthrob_checkout_action_start');

Example:

public function cartthrob_checkout_action_start()
{
    if (ee()->cartthrob->cart->is_empty()) {
        ee()->extensions->end_script = true;
    }
}

cartthrob_update_live_rates_start

Fires: At the beginning of the live shipping rates action, before customer info is saved and shipping plugins are queried.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the live rates action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_update_live_rates_start');

Example:

public function cartthrob_update_live_rates_start()
{
    ee()->logger->developer('Live shipping rate refresh started');
}

Checkout

cartthrob_pre_process

Fires: During checkout before CartThrob creates or updates order data and sends data to the payment gateway.

Parameters:

  • $options (array): Checkout options such as gateway, gateway method, totals, create-user values, subscription options, and vault data.

Returns: array|null. Return an array to replace checkout options. Return null to keep the current options. Set ee()->extensions->end_script = true to stop checkout.

How CartThrob calls it:

$options = ee()->extensions->call('cartthrob_pre_process', $options) ?? $options;

Example:

public function cartthrob_pre_process($options)
{
    $options['custom_gateway_note'] = 'Checked by extension';

    return $options;
}

cartthrob_order_created

Fires: After CartThrob creates or updates an order during checkout completion.

Parameters:

  • $order (array|object|null): Order data returned by order_model->getOrder().
  • $cartmeta (array): Cart metadata at the time the order is created.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_order_created', $order, $cartmeta);

Example:

public function cartthrob_order_created($order, $cartmeta)
{
    ee()->logger->developer('CartThrob order created');
}

cartthrob_on_authorize

Fires: After a payment is authorized and CartThrob sets purchased item statuses for a completed checkout.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before cart save and completed notifications.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_authorize');

Example:

public function cartthrob_on_authorize()
{
    ee()->logger->developer('CartThrob payment authorized');
}

cartthrob_on_decline

Fires: After a payment is declined and CartThrob updates purchased item statuses.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before cart save and declined notifications.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_decline');

Example:

public function cartthrob_on_decline()
{
    ee()->logger->developer('CartThrob payment declined');
}

cartthrob_on_processing

Fires: After a payment is marked processing and CartThrob updates purchased item statuses.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before cart save and processing notifications.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_processing');

Example:

public function cartthrob_on_processing()
{
    ee()->logger->developer('CartThrob payment processing');
}

cartthrob_on_fail

Fires: After a payment fails and CartThrob updates purchased item statuses.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop CartThrob before cart save and failed notifications.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_fail');

Example:

public function cartthrob_on_fail()
{
    ee()->logger->developer('CartThrob payment failed');
}

cartthrob_on_refund_failure

Fires: When a refund cannot proceed because the active gateway is invalid or does not support refunds.

Parameters:

  • $message (string): The failure message CartThrob will use on the failed transaction state.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_refund_failure', $message);

Example:

public function cartthrob_on_refund_failure($message)
{
    ee()->logger->developer('Refund failed: ' . $message);
}

cartthrob_on_pre_refund_attempt

Fires: Immediately before CartThrob calls the payment gateway’s refund method.

Parameters:

  • $transactionId (string|null): Gateway transaction ID to refund.
  • $amount (float|string|null): Refund amount, or null when refunding the gateway default amount.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_pre_refund_attempt', $transactionId, $amount);

Example:

public function cartthrob_on_pre_refund_attempt($transactionId, $amount)
{
    ee()->logger->developer('Refund attempt for ' . $transactionId);
}

cartthrob_on_post_refund_attempt

Fires: Immediately after CartThrob calls the payment gateway’s refund method.

Parameters:

  • $result (mixed): Gateway refund response or transaction state.
  • $transactionId (string|null): Gateway transaction ID that was refunded.
  • $amount (float|string|null): Refund amount passed to the gateway.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_on_post_refund_attempt', $result, $transactionId, $amount);

Example:

public function cartthrob_on_post_refund_attempt($result, $transactionId, $amount)
{
    ee()->logger->developer('Refund response received for ' . $transactionId);
}

Email and Notifications

cartthrob_send_notification

Fires: After CartThrob preprocesses notification data and logs the notification if configured, before the notification plugin delivers it.

Parameters:

  • $notification (CartThrob\Plugins\Notification\NotificationPlugin): The notification plugin instance being sent.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to skip CartThrob’s normal delivery and return success.

How CartThrob calls it:

ee()->extensions->call('cartthrob_send_notification', $this);

Example:

public function cartthrob_send_notification($notification)
{
    ee()->logger->developer('Sending CartThrob notification: ' . $notification->getEvent());
}

cartthrob_send_email

Fires: After CartThrob parses email fields and message content, before initializing ExpressionEngine’s email library.

Parameters:

  • $from (string): Parsed sender email address.
  • $from_name (string): Parsed sender name.
  • $to (string): Parsed recipient email address.
  • $subject (string): Parsed email subject.
  • $message (string): Parsed email body.
  • $plaintext (bool): Whether the email should be sent as plain text.
  • $variables (array): Variables used to parse the email.
  • $constants (array): Constant replacements used while parsing.
  • $message_template (string|null): Optional template name used for the message.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to skip CartThrob’s normal email logging and sending.

How CartThrob calls it:

ee()->extensions->call(
    'cartthrob_send_email',
    $from,
    $from_name,
    $to,
    $subject,
    $message,
    $plaintext,
    $variables,
    $constants,
    $message_template
);

Example:

public function cartthrob_send_email($from, $from_name, $to, $subject, $message, $plaintext, $variables, $constants, $message_template)
{
    ee()->logger->developer('CartThrob email queued for ' . $to);
}

Member Data

cartthrob_create_member

Fires: During checkout member creation, after CartThrob creates the ExpressionEngine member and sends activation emails when needed.

Parameters:

  • $member_data (array): Member data used during creation, with member_id merged in.
  • $members_model (cartthrob_members_model): The CartThrob members model instance. Accept it by reference if you need to modify the object.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop before the model returns the new member ID.

How CartThrob calls it:

ee()->extensions->call('cartthrob_create_member', array_merge($data, ['member_id' => $member_id]), $this);

Example:

public function cartthrob_create_member($member_data, &$members_model)
{
    ee()->logger->developer('Created member ' . $member_data['member_id']);
}

Discounts

cartthrob_discount_filter

Fires: Before CartThrob queries entries from the configured discount channel.

Parameters:

  • $filter (array): Database filter criteria used by cartthrob_entries_model->find_entries().

Returns: array. Return the filter criteria CartThrob should use.

How CartThrob calls it:

$filter = ee()->extensions->call('cartthrob_discount_filter', $filter);

Example:

public function cartthrob_discount_filter($filter)
{
    $filter['channel_titles.status'] = 'open';

    return $filter;
}

cartthrob_get_valid_discounts_end

Fires: After CartThrob validates discount entries and builds the valid discount data array.

Parameters:

  • $discount_data (array): Valid discount data keyed by discount entry ID.

Returns: array. Return the discount data CartThrob should keep.

How CartThrob calls it:

$this->discount_data = ee()->extensions->call('cartthrob_get_valid_discounts_end', $this->discount_data);

Example:

public function cartthrob_get_valid_discounts_end($discount_data)
{
    unset($discount_data[123]);

    return $discount_data;
}

Product Data and Inventory

cartthrob_get_all_price_modifiers

Fires: At the beginning of price modifier collection for a product.

Parameters:

  • $entry_id (int|string): Product entry ID.

Returns: array|null. Return an array to seed the price modifier data. If you set ee()->extensions->end_script = true, the returned array replaces all normal price modifier processing for that call.

How CartThrob calls it:

$additional_price_modifiers = ee()->extensions->call('cartthrob_get_all_price_modifiers', $entry_id);

Example:

public function cartthrob_get_all_price_modifiers($entry_id)
{
    return [
        'size' => [
            ['option_name' => 'Large', 'option_value' => 'large', 'price' => 5, 'inventory' => 10],
        ],
    ];
}

cartthrob_get_all_price_modifiers_end

Fires: After CartThrob has collected native price modifiers for a product.

Parameters:

  • $price_modifiers (array): Final price modifier data grouped by field name.

Returns: array|null. Return an array to replace the final price modifier data.

How CartThrob calls it:

$updated_price_modifiers = ee()->extensions->call('cartthrob_get_all_price_modifiers_end', $price_modifiers);

Example:

public function cartthrob_get_all_price_modifiers_end($price_modifiers)
{
    $price_modifiers['color'][] = [
        'option_name' => 'Custom',
        'option_value' => 'custom',
        'price' => 0,
        'inventory' => '',
    ];

    return $price_modifiers;
}

cartthrob_product_reduce_inventory

Fires: After CartThrob adjusts product inventory in product_model->reduce_inventory().

Parameters:

  • $entry_id (int|string): Product entry ID.
  • $entry_data (array): Product entry data after loading the product.
  • $quantity_reduced (int|float|string): Quantity CartThrob attempted to reduce.
  • $item_options (array): Item options used to identify modifier inventory.
  • $final_resulting_inventory (int|float|false|null): Inventory value returned by the adjustment.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call(
    'cartthrob_product_reduce_inventory',
    $entry_id,
    $this->get_product($entry_id),
    $quantity,
    $item_options,
    $inventory
);

Example:

public function cartthrob_product_reduce_inventory($entry_id, $entry_data, $quantity_reduced, $item_options, $final_resulting_inventory)
{
    ee()->logger->developer('Inventory for product ' . $entry_id . ' is now ' . $final_resulting_inventory);
}

Calculations

CartThrob also has internal core hook names such as cart_total_start and cart_shipping_end. Extension developers should usually register the public cartthrob_calculate_* hooks below.

cartthrob_calculate_total

Fires: At the start of CartThrob’s cart total calculation.

Parameters: None.

Returns: float|int|string|false. Return a non-false total to replace CartThrob’s normal total calculation. Return false to allow normal calculation.

How CartThrob calls it:

$total = ee()->extensions->call('cartthrob_calculate_total');

Example:

public function cartthrob_calculate_total()
{
    return 100.00;
}

cartthrob_calculate_discount

Fires: At the start of CartThrob’s cart discount calculation.

Parameters: None.

Returns: float|int|string|false. Return a non-false discount to replace CartThrob’s normal discount calculation. Return false to allow normal calculation.

How CartThrob calls it:

$discount = ee()->extensions->call('cartthrob_calculate_discount');

Example:

public function cartthrob_calculate_discount()
{
    return 10.00;
}

cartthrob_calculate_shipping

Fires: At the end of CartThrob’s cart shipping calculation.

Parameters:

  • $shipping (float|int|string): Shipping amount CartThrob calculated.

Returns: float|int|string. Return the shipping amount CartThrob should use.

How CartThrob calls it:

return ee()->extensions->call('cartthrob_calculate_shipping', $shipping);

Example:

public function cartthrob_calculate_shipping($shipping)
{
    return $shipping + 2.50;
}

cartthrob_calculate_tax

Fires: At the end of CartThrob’s tax calculation.

Parameters:

  • $tax (float|int|string): Tax amount CartThrob calculated.

Returns: float|int|string. Return the tax amount CartThrob should use.

How CartThrob calls it:

return ee()->extensions->call('cartthrob_calculate_tax', $tax);

Example:

public function cartthrob_calculate_tax($tax)
{
    return round($tax, 2);
}

cartthrob_calculate_item_shipping

Fires: At the end of an individual item’s shipping calculation.

Parameters:

  • $shipping (float|int|string): Item shipping amount CartThrob calculated.

Returns: float|int|string. Return the item shipping amount CartThrob should use.

How CartThrob calls it:

return ee()->extensions->call('cartthrob_calculate_item_shipping', $shipping);

Example:

public function cartthrob_calculate_item_shipping($shipping)
{
    return max(0, $shipping);
}

cartthrob_calculate_inventory

Fires: When CartThrob checks inventory for a product and item option combination.

Parameters:

  • $product (Cartthrob_product): Product object being checked.
  • $item_options (array): Item options used for modifier-specific inventory.

Returns: int|float|string|false. Return the inventory value CartThrob should use.

How CartThrob calls it:

return ee()->extensions->call('cartthrob_calculate_inventory', $product, $item_options);

Example:

public function cartthrob_calculate_inventory($product, $item_options)
{
    if ($product->product_id() == 123) {
        return 999;
    }

    return false;
}

Vaults

cartthrob_create_token_start

Fires: Before CartThrob creates a payment token and vault record.

Parameters:

  • $data (array): Initial vault data submitted to token creation.

Returns: array|null. Return the data CartThrob should use. Set ee()->extensions->end_script = true to stop token creation and return null.

How CartThrob calls it:

$data = ee()->extensions->call('cartthrob_create_token_start', $data);

Example:

public function cartthrob_create_token_start($data)
{
    $data['primary'] = $data['primary'] ?? 0;

    return $data;
}

cartthrob_create_token_end

Fires: After CartThrob creates a gateway token and saves the vault model.

Parameters:

  • $data (array): Vault data saved with token, member, customer, and timestamp values.
  • $token (Cartthrob_token): Token returned by the active payment gateway.
  • $vault (CartThrob\Model\Vault): Saved vault model.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to return the token immediately.

How CartThrob calls it:

ee()->extensions->call('cartthrob_create_token_end', $data, $token, $vault);

Example:

public function cartthrob_create_token_end($data, $token, $vault)
{
    ee()->logger->developer('Created vault ' . $vault->id);
}

cartthrob_update_vault_start

Fires: Before CartThrob updates a vault model.

Parameters:

  • $vault (CartThrob\Model\Vault): Vault model being updated.

Returns: CartThrob\Model\Vault. Return the vault model CartThrob should save. Set ee()->extensions->end_script = true to skip saving and return success.

How CartThrob calls it:

$vault = ee()->extensions->call('cartthrob_update_vault_start', $vault);

Example:

public function cartthrob_update_vault_start($vault)
{
    $vault->primary = 1;

    return $vault;
}

cartthrob_update_vault_end

Fires: After CartThrob successfully saves a vault update.

Parameters:

  • $vault (CartThrob\Model\Vault): Saved vault model.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_update_vault_end', $vault);

Example:

public function cartthrob_update_vault_end($vault)
{
    ee()->logger->developer('Updated vault ' . $vault->id);
}

cartthrob_delete_vault_start

Fires: Before CartThrob deletes a vault model.

Parameters:

  • $vault (CartThrob\Model\Vault): Vault model about to be deleted.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop deletion.

How CartThrob calls it:

ee()->extensions->call('cartthrob_delete_vault_start', $vault);

Example:

public function cartthrob_delete_vault_start($vault)
{
    ee()->logger->developer('Deleting vault ' . $vault->id);
}

cartthrob_delete_vault_end

Fires: After CartThrob deletes a vault model.

Parameters:

  • $vault_id (int|string): ID of the vault that was deleted.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop any remaining delete-vault processing.

How CartThrob calls it:

ee()->extensions->call('cartthrob_delete_vault_end', $vault_id);

Example:

public function cartthrob_delete_vault_end($vault_id)
{
    ee()->logger->developer('Deleted vault ' . $vault_id);
}

cartthrob_reset_primary_vault_start

Fires: Before CartThrob clears the primary flag from a member’s vault records.

Parameters:

  • $member_id (int): Member ID whose primary vault records are being reset.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the reset.

How CartThrob calls it:

ee()->extensions->call('cartthrob_reset_primary_vault_start', $member_id);

Example:

public function cartthrob_reset_primary_vault_start($member_id)
{
    ee()->logger->developer('Resetting primary vault for member ' . $member_id);
}

cartthrob_reset_primary_vault_end

Fires: After CartThrob clears the primary flag from a member’s vault records.

Parameters: None.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_reset_primary_vault_end');

Example:

public function cartthrob_reset_primary_vault_end()
{
    ee()->logger->developer('Primary vault reset completed');
}

Downloads

cartthrob_download_start

Fires: Before CartThrob validates a download file request and resolves the file path.

Parameters: None.

Returns: Return value is ignored. Set ee()->extensions->end_script = true to stop the download action.

How CartThrob calls it:

ee()->extensions->call('cartthrob_download_start');

Example:

public function cartthrob_download_start()
{
    ee()->logger->developer('CartThrob download started');
}

cartthrob_download_end

Fires: After CartThrob validates a download request and resolves the file path, before forcing the download.

Parameters:

  • $path (string|null): Resolved file path.

Returns: string|null. Return the file path CartThrob should download. Set ee()->extensions->end_script = true to stop the download action.

How CartThrob calls it:

$path = ee()->extensions->call('cartthrob_download_end', $path);

Example:

public function cartthrob_download_end($path)
{
    return $path;
}

Other

cartthrob_view_converted_currency

Fires: Before CartThrob’s converted currency tag uses its built-in currency conversion request.

Parameters:

  • $number (float|int): Sanitized positive price value from the tag’s price parameter.

Returns: string|float|int. Return the value the tag should output.

How CartThrob calls it:

return ee()->extensions->call('cartthrob_view_converted_currency', $number);

Example:

public function cartthrob_view_converted_currency($number)
{
    return ee()->number->format($number * 0.9);
}

cartthrob_boot

Fires: During ExpressionEngine core_boot, after CartThrob loads its loader and paths libraries.

Parameters: None.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('cartthrob_boot');

Example:

public function cartthrob_boot()
{
    ee()->logger->developer('CartThrob booted');
}

These hooks are called from CartThrob code but do not use the cartthrob_ prefix. They are included here because they are useful when extending CartThrob forms, template parsing, or CP navigation.

form_builder_form_start

Fires: When CartThrob’s form builder starts building a template form.

Parameters:

  • $module (string): First tag part, usually cartthrob.
  • $method (string): Second tag part, such as add_to_cart_form or checkout_form.

Returns: Return value is ignored.

How CartThrob calls it:

ee()->extensions->call('form_builder_form_start', $module, $method);

Example:

public function form_builder_form_start($module, $method)
{
    if ($module === 'cartthrob' && $method === 'add_to_cart_form') {
        ee()->form_builder->set_hidden('source', 'catalog');
    }
}

cp_menu_array

Fires: When CartThrob compiles its CP sidebar data.

Parameters:

  • $menu (array): CartThrob sidebar array before final rendering.

Returns: array. Return the modified menu array. CartThrob reads ee()->extensions->last_call after this hook.

How CartThrob calls it:

ee()->extensions->call('cp_menu_array', $this->compiled_sidebar);
$this->compiled_sidebar = ee()->extensions->last_call;

Example:

public function cp_menu_array($menu)
{
    $menu['Custom']['list']['My Settings'] = 'settings/my-settings';

    return $menu;
}

template_fetch_template

Fires: When CartThrob’s template helper is about to parse a template string.

Parameters:

  • $template_data (array): Array containing template_data, the template string CartThrob will parse.

Returns: Return value is ignored by CartThrob’s template helper.

How CartThrob calls it:

ee()->extensions->call('template_fetch_template', ['template_data' => $template]);

Example:

public function template_fetch_template($template_data)
{
    ee()->logger->developer('CartThrob template helper parsing template data');
}

Removed or Legacy Hooks

The hook names below appeared in older CartThrob documentation but were not found in the bundled CartThrob 9.0.1 source during this audit. Treat them as removed or legacy rather than currently supported extension points.

cartthrob_update_subscription_details

Older documentation described this as running after subscription details were updated through an update_subscription_details form. No matching hook call or action was found in CartThrob 9.0.1. No direct replacement was identified in the audited source.

cartthrob_add_settings_nav

Older documentation described this as a way to add CartThrob settings navigation items. No matching hook call was found in CartThrob 9.0.1. For current CP navigation changes, review the related cp_menu_array hook.

cartthrob_add_settings_views

Older documentation described this as a companion to cartthrob_add_settings_nav for adding CartThrob settings views. No matching hook call was found in CartThrob 9.0.1. No direct replacement was identified in the audited source.

inventory_matching_items

Older documentation listed this as returning items similar to a product. No matching hook call was found in CartThrob 9.0.1. For current inventory overrides, review cartthrob_calculate_inventory.

cart_discount_start

This is an older internal-style hook name from CartThrob’s core calculation layer. Extension developers should use cartthrob_calculate_discount for current integrations.

cart_total_start

This is an older internal-style hook name from CartThrob’s core calculation layer. Extension developers should use cartthrob_calculate_total for current integrations.

cart_tax_end

This is an older internal-style hook name from CartThrob’s core calculation layer. Extension developers should use cartthrob_calculate_tax for current integrations.

cart_shipping_end

This is an older internal-style hook name from CartThrob’s core calculation layer. Extension developers should use cartthrob_calculate_shipping for current integrations.