---
title: How to use Chwazi custom JavaScript events
description: Chwazi comes with two custom JavaScript events that can help you perform actions based on the order type selected. Using the snippet below, you can see a console message appear based on the order type selected. Using this logic, you…
url: "https://chwazidatetime.com/docs/how-to-use-chwazi-custom-javascript-events/"
updated: "2025-04-03"
category: Custom Code Samples
---

# How to use Chwazi custom JavaScript events

Chwazi comes with two custom JavaScript events that can help you perform actions based on the order type selected. Using the snippet below, you can see a console message appear based on the order type selected.

Using this logic, you can write custom JavaScript to perform your custom logic:

```
function sl_cc_catch_chwazi_js_events(){
	echo "
	<script>
		document.addEventListener('custom:dpsCustomerSwitchedToPickup', function(){

		console.log('pickup button clicked');

		})

		document.addEventListener('custom:dpsCustomerSwitchedToDelivery', function(){

		console.log('delivery button clicked');

		})

	</script>
	";
}
add_action('wp_head', 'sl_cc_catch_chwazi_js_events');
```
