hey try this code but first make sure your cash drawer connects through a USB port, serial (COM) port.
using System.IO.Ports;
// ...
private void OpenCashDrawer(string comPort)
{
try
{
SerialPort serialPort = new SerialPort(comPort, 9600); // Adjust if needed
serialPort.Open();
serialPort.Write("\x07"); // This tells the drawer to open
serialPort.Close();
}
catch (Exception ex)
{
// Handle any issues that might come up
}
}