// 1. Cookie zetten bij binnenkomst via chatbot add_action('init', function() { if (isset($_GET['source']) && $_GET['source'] === 'agent') { setcookie('agent_source', 'agent', time() + 3600, '/'); } }); // 2. Tijdens checkout: alleen als er een order wordt gemaakt add_action('woocommerce_checkout_create_order', function($order, $data) { if (isset($_COOKIE['agent_source']) && $_COOKIE['agent_source'] === 'agent') { $order->update_meta_data('_source', 'agent'); } }, 10, 2);