Hello,
We don’t have the option to block the site from viewing from the desktop. So, we need to check what could be the reason that your custom code does not work.
Go to Theme Option > General > mobile optimization option is enabled or disabled? Disable that in case it’s enabled.
Regards