Home
NexoPOS

ns-orders-template-mapping

You'll use this filter to mutate or add custom template tags. If you have created custom template tags, this will be the way to provide their implementations. 

<?php
namespace Modules\YourModule\Providers;

use Illuminate\Support\ServiceProvider as CoreProvider;
use App\Classes\Hook;

class ServiceProvider extends CoreProvider
{
    public function boot()
    {
          Hook::addFilter( 'ns-orders-template-mapping', function( $tags, $order ) {
              $tags[ 'my_tag' ]   =   $order->customAttribute;
            
              return $tags;
          }, 10, 2 ); // 10: priority, 2: the function takes 2 arguments
    }
}

In this code, we're converting any template tag like {my_tag} to the value of the property "customAttribute". However, note that you adapt these to your actual needs.