あなたがチェックアウトのいくつかの変更は、送信ボタンを作成したい場合は、あなたは2つの方法ています:woocommerce_order_button_html
フィルタに夢中にカスタム関数を使用して
1)フック、この方法:
add_filter('woocommerce_order_button_html', 'custom_order_button_html');
function custom_order_button_html($button) {
// The text of the button
$order_button_text = __('Place order', 'woocommerce');
// HERE your Javascript Event
$js_event = "fbq('track', 'AddPaymentInfo');";
// HERE you make changes (Replacing the code of the button):
$button = '<input type="submit" onClick="'.$js_event.'" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr($order_button_text) . '" data-value="' . esc_attr($order_button_text) . '" />';
return $button;
}
コードはあなたのアクティブな子テーマ(またはテーマ)のfunction.phpファイル、またはすべてのプラグインファイルに入ります。
2)テンプレートのチェックアウト/ payment.phpをオーバーライドして、ライン50)に(このコードを対象とします:
<?php echo apply_filters('woocommerce_order_button_html', '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr($order_button_text) . '" data-value="' . esc_attr($order_button_text) . '" />'); ?>
たが、これに変更:
<?php
// Set HERE your javascript event
$js_event = $js_event = "fbq('track', 'AddPaymentInfo');";
echo apply_filters('woocommerce_order_button_html', '<input type="submit" onClick="'.$js_event.'" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr($order_button_text) . '" data-value="' . esc_attr($order_button_text) . '" />'); ?>
関連資料:
すべてのコードがテストされ、機能しています。ここでは、両方のソリューションのための出力は次のようになります、
おかげ@LoicTheAztecは、私がプラグインでそれを試してみたが、チェックアウトのページに私はこのケースでは、ページ全体のために、「InitiateCheckout」イベントを一つのイベントを設定することができますユーザーが支払いデータを入力するときに、ボタンに固有の2番目のイベントを追加したいと考えています。このようにして、ユーザーが支払いを試みたが検出できなかったときを検出することができます。プラグインを使用して1ページにつき1つのイベントしか調整できない場合、システムは単にページを出たクライアントと支払いを試みた人と同じように登録し、何らかの問題に遭遇します。とにかくありがとう! – Melania