/*------------------------------------- 共通ハッシュ関数 -------------------------------------*/ if (!function_exists('to_hash')) { function to_hash($val) { if (!$val) return ''; $val = mb_strtolower(trim($val)); $val = str_replace('-', '', $val); return hash('sha256', $val); } } /*------------------------------------- external_id(user ID)取得関数 -------------------------------------*/ function get_external_id() { if (!is_user_logged_in()) return ''; return hash('sha256', get_current_user_id()); } /*------------------------------------- JS: Cookie _fbc を取得して dataLayer に入れるスニペット -------------------------------------*/ function inject_fbc_cookie_js() { echo ""; } add_action('wp_footer', 'inject_fbc_cookie_js'); /*------------------------------------- 各イベントごとのユーザーデータ出力(ViewItem, AddToCart, Checkout, Purchase) -------------------------------------*/ function push_userdata_common($event_name, $order = null) { $email = $phone = $city = $region = $country = $zip = $first_name = $last_name = ''; if ($order) { $email = $order->get_billing_email(); $phone = $order->get_billing_phone(); $city = $order->get_billing_city(); $region = $order->get_billing_state(); $country = $order->get_billing_country(); $zip = $order->get_billing_postcode(); $first_name = $order->get_billing_first_name(); $last_name = $order->get_billing_last_name(); } elseif (is_user_logged_in()) { $u = wp_get_current_user(); $m = get_user_meta($u->ID); $email = $u->user_email; $phone = isset($m['billing_phone'][0]) ? $m['billing_phone'][0] : ''; $city = isset($m['billing_city'][0]) ? $m['billing_city'][0] : ''; $region = isset($m['billing_state'][0]) ? $m['billing_state'][0] : ''; $country = isset($m['billing_country'][0]) ? $m['billing_country'][0] : ''; $zip = isset($m['billing_postcode'][0]) ? $m['billing_postcode'][0] : ''; $first_name = isset($m['billing_first_name'][0]) ? $m['billing_first_name'][0] : ''; $last_name = isset($m['billing_last_name'][0]) ? $m['billing_last_name'][0] : ''; } echo ""; } // ViewItem add_action('wp_footer', function() { if (is_product() && is_user_logged_in()) { push_userdata_common('Event – ViewItem'); } }); // AddToCart add_action('woocommerce_add_to_cart', function() { if (is_user_logged_in()) { push_userdata_common('Event – AddToCart'); } }); // BeginCheckout add_action('woocommerce_before_checkout_form', function() { if (is_user_logged_in()) { push_userdata_common('Event – BeginCheckout'); } }); // Purchase add_action('woocommerce_thankyou', function($order_id) { if ($order_id) { $order = wc_get_order($order_id); push_userdata_common('Event-Purchase', $order); } }); Rut Bryk Kaakeli SOLD OUT! – Mun stylisti

Privacy Preference Center