Developer Hooks

NOTE This may not be the complete set of available hooks for CartThrob. You can search for "hook" in the CartThrob code. There are roughly 25 development hooks in the module, extension, and control panel files.

Hooks

cartthrob_delete_from_cart_start

Additional processing when a delete from cart action begins.

return void

cartthrob_delete_from_cart_end

Additional processing when a delete from cart action is about to end.

return void

cartthrob_add_to_cart_start

Additional processing when add to cart action begins. Item has not been added yet.

return void

cartthrob_add_to_cart_end

Additional processing when add to cart action ends. At this point the item data has been aggregated into an item object

$item (object)

return void

cartthrob_update_cart_start

Additional processing when update cart action begins.

return void

cartthrob_update_cart_end

Additional processing when update cart action ends.

return void

cartthrob_multi_add_to_cart_start

Additional cart processing when multi add to cart action begins

return void

cartthrob_multi_add_to_cart_end

Additional cart processing when multi add to cart action is about to end.

$entry_ids (array)

return void

cartthrob_save_customer_info_start

Additional processing when save customer info action is about to start. This may be called multiple times during other processing actions.

return void

cartthrob_save_customer_info_end

Additional processing when save customer info action is about to end. This may be called multiple times during other processing actions.

return void

cartthrob_update_subscription_details

Additional processing is run when subscription details have been updated using update_subscription_details form. This is useful for pinging third parties when a sub has been updated.

$data (array) The data/parameters that are being used to update the subscription.

return void

cartthrob_order_created

This hook is triggered when an order is created during the checkout process.

if (ee()->extensions->active_hook('cartthrob_order_created') === true) {
    $data = ee()->extensions->call('cartthrob_order_created', $order, $cartmeta);
}

return void

cartthrob_pre_process

When checkout form is submitted, but before the data is sent to the payment gateway file.

return void

cartthrob_on_authorize

Additional processing when the payment has been authorized.

return void

cartthrob_on_decline

Additional processing when the payment has been declined

return void

cartthrob_on_processing

Additional processing when the payment has been marked as "processing"

return void

cartthrob_on_fail

Additional processing when the payment has been marked as "failed"

return void

cartthrob_create_member

Called during checkout if you are attempting to create a member during checkout. If you want to modify the $this object remember to use a reference (&) on the function call.

$member_data (array)
&$this (object)

return void

cartthrob_discount_filter
$filter (array)

return $filter (array)

cart_discount_start

Adjusts the criteria used to pull relevant discount entries from the discounts channel

return $discount (float)

cart_total_start

Manipulates the cart total

return $total (float)

cart_tax_end

Manipulates the cart tax

$tax (float)

return $tax (float)

cart_shipping_end

Manipulates cart shipping costs

$shipping (float)

return $shipping (float)

inventory_matching_items

Returns items similar to product

$product_id (string)
$item_options (array)

return $items (object)

cartthrob_product_reduce_inventory

Called when inventory is being updated in the product model

$entry_id (string)
$entry_data (array)
$quantity_reduced (int)
$item_options (array)
$final_resulting_inventory (int)

returns void

cartthrob_get_all_price_modifiers

Manipulates price modifiers dynamically.

$entry_id

returns $price_modifiers (array)

cartthrob_calculate_total

Adjusts total

return $total (float)

cartthrob_calculate_discount

Adjusts discount

return $discount (float)

cartthrob_calculate_shipping

Adjusts shipping

$shipping (float)

return (float)

cartthrob_calculate_tax

Adjusts tax

$tax (float)

return $tax (float)

cartthrob_calculate_item_shipping

Adjusts shipping per item

$shipping (float)

return $shipping (float)

cartthrob_calculate_inventory

Adjusts product inventory

$product (Cartthrob_product)
$itemOptions (array)

return $inventory (int)

cartthrob_on_refund_failure

Called if refund fails.

$message (string)
cartthrob_on_pre_refund_attempt

Runs prior to the payment gateway refund call.

$transactionId (string)
$amount (float)
cartthrob_on_post_refund_attempt

Called after a refund call is made on the associated payment gateway. Response will be determined on what the payment gateway sends back.

$result (mixed, response from the payment gateway)
$transactionId (string)
$amount (float)
cartthrob_add_settings_nav

Adds navigation items to the CT settings. Should be used with cartthrob_add_settings_views

$nav (array)

return $nav (array)

cartthrob_add_settings_views

Adds settings items to the CT settings. Should be used with cartthrob_add_settings_nav

$settings_views (array)

return $settings_views (array)

cartthrob_download_start

Additional processing when add to download action begins. Download has not started, and path has not been identified.

return void

cartthrob_download_end

Allows additional manipulation of the download file path

$path (string)

return $path (string)

cartthrob_view_converted_currency

Allows additional processing for currency conversion

$number (float)

return $number (float)

cartthrob_boot

Notification of CartThrob's initial booting

return void