説明

wpforms_square_process_get_payment_args_singleフィルターは、Squareの単一支払いリクエスト引数を送信前に変更できます。動的なデータを挿入したり、支払いメモでスマートタグを実行したり、メタデータを調整したりするために使用できます。

このフィルターを使用して、Squareのメモフィールド内でWPFormsスマートタグを実行し、Squareのトランザクション詳細にフォームの値を含めることができます。Squareのnoteフィールドは500文字に制限されているため、それに応じて出力をトリミングしてください。

パラメータータイプ説明
$argsarraySquareの単一支払い引数。一般的なキーにはamount_moneycustomer_idnoteなどがあります。
$processプロセス現在の送信のSquareプロセスインスタンス。$process->form_dataおよび$process->fieldsにアクセスできます。

ソース

wpforms\src\Integrations\Square\Process.php

// Process Smart Tags in the Square payment note and trim to 500 chars.
function wpf_dev_square_single_payment_args( $args, $process ) {
    if ( isset( $args['note'] ) ) {
        $note        = apply_filters(
            'wpforms_process_smart_tags',
            $args['note'],
            $process->form_data,
            $process->fields,
            0
        );
        $args['note'] = wp_html_excerpt( $note, 500 );
    }
    return $args;
}
add_filter( 'wpforms_square_process_get_payment_args_single', 'wpf_dev_square_single_payment_args', 10, 2 );

参考記事