Hooks in commerce

by Michael Knabe <mk@e-netconsulting.de>

as of 01/04/2007

This document describes all the hooks in the typo3 extension commerce (version 0.8.17) as of 01/04/2007. The hooks are sorted by the classes and functions they can be found in.
Each hook has a type which is either Single or Multiple. Single hook classes are written directly to the $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$filename][$hookname] variable as there may never be more than one hook-object.
For hooks with the type "multiple" $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$filename][$hookname] is an array which can contain multiple hook objects. Each of them is called in the order they are found in the array by foreach.
Some hook-methods can return data which is used by the calling function. Others may return some values but they are ignored. For those I used the return type void as known from the C programming language


Functions: 38
Classes: 18
class tx_commerce_article
function init
function getActualPriceforScaleUid
function calculateDeliveryCosts
function getStock
function hasStock
getSpecialPrice
class tx_commerce_attribute_value
function init
class tx_commerce_attribute
function init
class tx_commerce_basket_item
function calculate_net_sum
function calculate_gross_sum
class tx_commerce_category
function init
class tx_commerce_db_article
function get_prices
class tx_commerce_db_category
function get_child_categories
function get_child_products
class tx_commerce_db_product
function get_articles
class tx_commerce_navigation
function makeArrayPostRender
class tx_commerce_pibase
function makeListView
function makeBasketInformation
function makeLineView
function addAdditionalLocallang
class tx_commerce_product
function init
class tx_commerce_pi1
function renderSingleView
function makeArticleView
class tx_commerce_pi2
function handleBasket
function generateBasket
function makeArticleView
function makeProductList
class tx_commerce_pi3
function getBillingAddress
function getDeliveryAddress
function getListing
function canMakeCheckout
function finishIt
function getBasketSum
function handleAddress
function sendUserMail
function sendAdminMail
function generateMail
class tx_commerce_pi4
function noUser
function deleteAddress
function saveAddressData
tx_commerce_pi5
tx_commerce_articlecreator
function createArticle

lib/class.tx_commerce_article.php
class tx_commerce_article
function init
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['postinit']
Call: postinit($this)
Type: Multiple
Result: void
These hooks are called after the initialization of the Object.
function getActualPriceforScaleUid
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['getActualPriceforScaleUid']
Call: getActualPriceforScaleUid($count,$this)
Type: Single
Result: float - The price for $count times the article The hook should return the uid of the price depending on the $count parameter which contains the number of articles to be bought.
function calculateDeliveryCosts
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['calculateDeliveryCost']
Call: calculateDeliveryCostNet($this->deliveryCostNet,$this)
Type: Single
Result: void
This hooks job is to set the $deliveryCostNet variable to the net delivery cost
Call: calculateDeliveryCostGross($this->deliveryCostGross,$this)
Type: Single
Result: void
This hooks job is to set the $deliveryCostGross variable to the gross delivery cost
function getStock
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['getStock']
Call: getStock($this->stock,$this)
Type: Single
Result: void
Set the stock available for this article using this hook
function hasStock
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['hasStock']
Call: hasStock($amount,$this)
Type: Single
Result: boolean - Are there enough articles in stock
Return true iff there are enough articles in stock where $amount is the number of articles to be bought
getSpecialPrice
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['specialPrice']
Call: specialPrice($specialPrice, $this->prices_uids)
Type: Single
Result: void
Set the $specialPrice for this article. $specialPrice is an array with current price and PriceUid. $this->prices_uid is an array containing all the valid prices.
lib/class.tx_commerce_attribute_value.php
class tx_commerce_attribute_value
function init
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_attribute_value.php']['postinit']
Call: postinit($this)
Type: Multiple
Result: void
These hooks are called after the initialization of the Object.
lib/class.tx_commerce_attribute.php
class tx_commerce_attribute
function init
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_attribute.php']['postinit']
Call: postinit($this)
Type: Multiple
Result: void
These hooks are called after the initialization of the Object.
lib/class.tx_commerce_basket_item.php
class tx_commerce_basket_item
function calculate_net_sum
TODO
function calculate_gross_sum
TODO
lib/class.tx_commerce_category.php
class tx_commerce_category
function init
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_category.php']['postinit']
Call: postinit($this)
Type: Multiple Result: void
These hooks are called after the initialization of the Object.
lib/class.tx_commerce_db_article.php
class tx_commerce_db_article
function get_prices
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_article.php']['priceOrder']
Call: priceOrder($orderField) Type: Single
Result: string - The new ORDER BY clause to read the database
Change the order for the price field and return a new $orderField
lib/class.tx_commerce_db_category.php
class tx_commerce_db_category
function get_child_categories
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_category.php']['categoryOrder']
Call: categoryOrder($this->CategoryOrderField,$this)
Type: Single
Result: string - The new ORDER BY clause to read the database
This hook returns the ORDER BY field(s) that will be passed on to the t3lib_db later on.
function get_child_products
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_category.php']['productOrder']
Call: productOrder($this->orderField,$this)
Type: Single
Result: string - The new ORDER BY clause to read the database
This hook returns the ORDER BY field(s) that will be passed on to the t3lib_db later on.
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_category.php']['productQueryPreHook']
productQueryPreHook($data, $this)
Type: Single
Result: queryArray -> Modificated QueryArray to work with the database
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_category.php']['productQueryPostHook']
productQueryPostHook($data, $this)
Type: Single
Result: queryArray -> Modificated of data after the query
lib/class.tx_commerce_db_product.php
class tx_commerce_db_product
function get_articles
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['articleOrder']
Call: aditionalWhere($where)
Type: Single
Result: string - The new WHERE clause to read the database
The result of this hook is concatenated with the where clause which will be passed on to the t3lib_db later on.
lib/class.tx_commerce_navigation.php
class tx_commerce_navigation
function makeArrayPostRender
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_db_navigation.php']['sortingOrder']
Call: sortingOrder($sorting,$uid_root,$mainTable,$tableMm,$mDepth,$path,$this)
Type: Multiple
TODO: Add a description for this hook
As I did not understand what this function does I was not able to describe this hook
lib/class.tx_commerce_pibase.php
class tx_commerce_pibase
function makeListView
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['listview']
Call: additionalMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD some markers to the $markerArray and RETURN it as the result of this hook is used as the new $markerArray
function makeBasketInformation
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['makeBasketInformation']
Call: processMarkerBasketInformation($markerArray,$basketObj,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD some markers to the $markerArray and RETURN it as the result of this hook is used as the new $markerArray
function makeLineView
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['makeLineView']
Call: processMarkerLineView($markerArray,$basketItemObj,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD some markers to the $markerArray and RETURN it as the result of this hook is used as the new $markerArray
formatAttributeValue
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['formatAttributeValue']
Call: formatAttributeValue($key, $myAttributeUid, $matrix[$myAttributeUid]['valueuidlist'][$key], $return2, $this)
Type: Single
Result: string, new formating
Changes the default formating
addAdditionalLocallang
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['locallang']
Call: loadAdditionalLocallang($this)
Type: Multiple
possibility to add your own locallang-files
lib/class.tx_commerce_product.php
class tx_commerce_product
function init
GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['makeLineView']
Call: postinit($this)
Type: Multiple
Result: void
These hooks are called after the initialization of the Object.
pi1/class.tx_commerce_pi1.php
This class is for generating the product listings. (single and list view)
class tx_commerce_pi1
function renderSingleView
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['singleview']
Call: additionalMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional Markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray
function makeArticleView
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['articleview']
Call: $hookObj->additionalMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional Markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray
This Hook exists three times. It is called for every possible result of the if-switches, so it is only called once for every call of the function. It is anyway called immediately before the call to substituteMarkerArray is made
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['additionalMarkerMakeArticleView']
Call: $hookObj->additionalMarkerMakeArticleView$markerArray,$prod,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional Markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray
This Hook is called at the end of the method, for global replace
pi2/class.tx_commerce_pi2.php
This class is for showing the basket
class tx_commerce_pi2
function handleBasket
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['postartAddUid']
Call: postartAddUid($this->basket,$this)
Type: Multiple
Result: void
Hook for editing the basket after adding an article to it
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['postpayArt']
Call: postpayArt($this->basket,$this)
Type: Multiple
Result: void
Hook for editing the basket after adding a payment article to it
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['postdelArt']
Call: postdelArt($this->basket,$this)
Type: Multiple
Result: void
Hook for editing the basket after adding a delivery article to it
function generateBasket
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasketMarker']
Call: additionalMarker($basketArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray. This $markerArray is then used to substitute the template-code for the basket.
function makeArticleView
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeArticleView']
Call: additionalMarker($basketArray,$this,$art,$prod)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray. This $markerArray is then used to substitute the template-code for the article view.
function makeProductList
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeProductList']
Call: SingeDisplayPrefixId()
Type: Multiple
Result: integer - The new prefixId
Changes the prefixId used to create the links to the detail page.
pi3/class.tx_commerce_pi3.php
Handles the checkout
class tx_commerce_pi3
function getBillingAddress
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['getBillingAddress']
Call: ProcessMarker($markerArray, $this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
This $markerArray is used to substitute the template-code for the "get billing address"-page.
function getDeliveryAddress
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['getDeliveryAddress']
Call: ProcessMarker($markerArray, $this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
This $markerArray is used to substitute the template-code for the "get delivery address"-page.
function getListing
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['getListing']
Call: ProcessMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
This $markerArray is used to substitute the template-code for the "contents of basket"-page.
function canMakeCheckout
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['canMakeCheckout']
Call: canMakeCheckoutOwnTests($checks,$myCheck)
Type: Multiple
Result: void
The parameter $checks is an array with the standard checks of commerce. If you remove for example nopayment from the array
commerce does not check if there is a payment article included. With the second parameter you can add your own checks. Set $myCheck to a string and it will be used here: return $this->cObj->cObjGetSingle($this->conf['cantMakeCheckout.'][$canMakeCheckout], $this->conf['cantMakeCheckout.'][$canMakeCheckout.'.']);
function finishIt
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['finishIt']
Call: postpayment($paymentObj,$basket,$this)
Type: Multiple
Result: void
This is called when the payment is finished.
Call: generateOrderId($orderId, $basket, $this)
Type: Multiple
Result: void
This is your chance to change the orderId. Return the new $orderId
Call: preinsert($orderData,$this)
Type: Multiple
Result: void
Your last chance to change the order data. Next step is to inject the data into the database.
Call: afterMailSend($orderData,$this)
Type: Multiple
Result: void
Now it's to late. We just sent the acknowledgment to the customer and the admin. But you can change the orderData before the acknowledgment is written to the browser
Call: ProcessMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
One more chance to change the $markerArray. Now it's used to display the page confirming the ordering
function getBasketSum
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['getBasketSum']
Call: ProcessMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
This $markerArray is used to substitute the output of the BasketSum. I.e. the "'###LISTING_BASKET_'.strtoupper($type).'###'" sub part of the template.
function getBasketSum
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['handleAddress']
Call: preProcessUserData($feuData,$this)
Type: Multiple
Result: void
manipulation of fe_user Data, for example for creating a md5 password, before the user is created
Call: preProcessUserData($feuData,$this)
Type: Multiple
Result: void
manipulation of fe_user Data, for example after creating a md5 password, after the user is created $feuData will be used in the next steps (for example sending a usermail
function sendUserMail
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['sendUserMail']
Call: getUserMail($userMail,$orderUid,$orderData)
Type: Multiple
Result: string - The email address of the user
At this point you should return the email address of the user.
Call: preGenerateMail($UserMailObj,$this) Type: Multiple
Result: void
This hook is called before the mail content is created by calling $UserMailObj->generateMail($orderUid, $orderData,$userMarker) where $UserMailObj is an instance of the class tx_commerce_pi3.
Call: PostGenerateMail($UserMailObj,$this,$GLOBALS['TSFE']->fe_user->tx_commerce_basket,$mailcontent,$this)
Type: Multiple
Result: void
This hook is called immediately after creating the mailcontent. It could be used to edit $mailcontent for example.
function sendAdminMail
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['sendAdminMail']
Call: preGenerateMail($AdminMailObj,$this)
Type: Multiple
Result: void
This hook is called before the mail content is created by calling $AdminMailObj->generateMail($orderUid, $orderData) where $UserMailObj is an instance of the class tx_commerce_pi3.
Call: $hookObj->PostGenerateMail($AdminMailObj,$this,$GLOBALS['TSFE']->fe_user->tx_commerce_basket,$mailcontent,$this)
Type: Multiple
Result: void
This hook is called immediately after creating the mailcontent. It could be used to edit $mailcontent for example.
function generateMail
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi3/class.tx_commerce_pi3.php']['generateMail']
Call: ProcessMarker($markerArray,$this)
Type: Multiple
Result: array() - A new $markerArray
ADD additional markers to the $markerArray and RETURN it. The result of this hook is used as the new $markerArray.
$markerArray will be used to substitute the markers in the mail template
pi4/class.tx_commerce_pi4.php
class tx_commerce_pi4
handles everything concerning the addresses
function noUser
[TODO]
function deleteAddress
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi4/class.tx_commerce_pi4.php']['deleteAddress']
Call: deleteAddress($this->piVars['addressid'],$this)
Type: Multiple
Result: string - A system message (potentially ignored)
The result of the last called hook will replace the ###SYS_MESSAGE### marker in the address listing generated later on.
ATTENTION: If there are multiple hooks the results of the prior called ones are ignored. Of cause these hooks could be useful by changing &$this->piVars['addressid'] or &$this
function saveAddressData
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi4/class.tx_commerce_pi4.php']['saveAddress']
Call: beforeAddressSave($newData,$this)
Type: Multiple
Result: void
This hook is called before the new address is saved to the database.
$newdata is an array consisting of the following elements:
$newData['tx_commerce_fe_user_id'] - The users id in the "fe_user"-table
$newData['tx_commerce_address_type_id'] - The id of the address type
$newData['pid'] - The pid of the address
Call: afterAddressSave($newUid,$newData,$this)
Type: Multiple
Result: void
This hook is called after the new address is saved to the database.
$newUid is the uid of the address in the "tt_address"-table
For a description of $newData look at
beforeAddressSave($newData,$this)-hook in this section
Call: beforeAddressEdit($this->piVars['addressid'],$newData,$this)
Type: Multiple
Result: void
This hook is called before the address is changed
$this->piVars['addressid'] is the uid of the address in the "tt_address"-table
For a description of $newData look at beforeAddressSave($newData,$this)-hook in this section
Call: afterAddressEdit($this->piVars['addressid'],$newData,$this)
Type: Multiple
Result: void
This hook is called after the address is changed
$this->piVars['addressid'] is the uid of the address in the "tt_address"-table
For a description of $newData look at beforeAddressSave($newData,$this)-hook in this section
pi5/class.tx_commerce_pi5.php
tx_commerce_pi5
This class is going to replace the good old tx_commerce_pi3. Until then I won't document it here. Please be patient.
class.tx_commerce_articlecreator.php
tx_commerce_articlecreator
function createArticle
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_articlecreator.php']['preinsert']
Call: preinsert($articleData)
Type: Multiple
Result: void
This hook is called before a new article is added to the database.