Your cart is empty!
Before Parse Snippet
public function onBeforeParseConversionSnippet(array &$lookup, mixed $order, object $conversion) : void
Fires before parsing the snippet included within the conversion code.
Description
Trigger hook before parsing the placeholders contained within a snippet of a conversion/tracking code.
It is possible to use this hook to inject or change the attributes of the $lookup array.
Here's how to add support for a new placeholder:
$lookup['tax'] = 12.50;
And here's how to include that value within the JS snippet:
var taxAmount = {tax};
Parameters
- &$lookup
-
(array) An array of placeholders.
- $order
-
(array|object) An array/object holding the order details.
- $conversion
-
(object) The object holding the details of the conversion code.
Return Value
None.
Example
This example adds support for a new {tax}
placeholder, which will be replaced by the total tax amount of the order.
/**
* Trigger hook before parsing the placeholders contained within a snippet of
* a conversion/tracking code. It is possible to use this hook to inject or
* change the attributes of the $lookup array.
*
* @param array &$lookup An array of placeholders.
* @param mixed $order An array/object holding the order details.
* @param object $conversion The conversion details.
*/
public function onBeforeParseConversionSnippet(&$lookup, $order, $conversion)
{
// search for taxes only if we have an order wrapper
if ($order instanceof VAPOrderWrapper)
{
// register tax placeholder
$lookup['tax'] = $order->totals->tax;
}
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |
Last Update: 2021-10-06 17:05
Helpful?