English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Conversions  >  Before Parse Snippet

apply_filters_ref_array( 'vikappointments_before_parse_conversion_snippet', bool $status, array &$lookup, mixed $order, object $conversion )

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

$status

(bool)  True on success, false otherwise.

&$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.


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  boolean  $status      True on success, false otherwise.
 * @param  array    &$lookup     An array of placeholders.
 * @param  mixed    $order       An array/object holding the order details.
 * @param  object   $conversion  The conversion details.
 */
add_filter('vikappointments_before_parse_conversion_snippet', function($status, &$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;
    }

    return $status;
}, 10, 4);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-10-04
Helpful?

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.