public function onTranslateTakeawayOrderDetails( object $order, string $langtag ) : void

Fires while translating the details of the take-away order into a specific language.


Description

External plugins can use this event to apply the translations to additional details manually included within the order object.

Since the query used to load the details can be extended, this method offers the possibility to translate any additional data in the right way.


Parameters

$order

(object)  The object holding the details of the order.

$langtag

(string)  The language tag.

Return Value

None.


Example

The example below explains how the internal translation system works.

/**
 * External plugins can use this event to apply the translations to
 * additional details manually included within the order object.
 *
 * @param   object  $order    The order details object.
 * @param   string  $langtag  The requested language tag.
 *
 * @return  void
 */
public function onTranslateTakeawayOrderDetails($order, $langtag)
{
    // get translator
    $translator = VREFactory::getTranslator();

    // The products translation is already handled by the system, this is
    // just an explanation of how the translation system works.

    foreach ($order->items as &$item) {
        // translate product
        $tx = $translator->translate('tkentry', $item->id, $langtag);

        if ($tx) {
            // inject translation within item details
            $item->productName = $tx->name;
        }
    }
}

Changelog

Version Description
1.8.4 Introduced.
Last Update: 2023-12-29 14:15
Helpful?
See Also: