by ShopSite David » Fri Jun 03, 2022 4:58 pm
We are waiting to hear back from the AvaTax folks to see if they handle it in their system. But there is a way in ShopSite Pro with some JavaScript to do it if you are using a real-time shipper like USPS, UPS, etc. where the zip code is displayed on the shopping cart screen.
In Commerce > order system > Shopping cart
in the Surcharge Pull-down add:
No Delivery Charge
Colorado Delivery Charge;+0.27
In the Text at the bottom of the Shopping Cart screen add:
<script>{let f=document.order,$=ss_jQuery;if(f.zip_code){let colorado_check=function(e){console.log('colorado check');let s=f.querySelector('[name="shipoptmenu:0"]'),v=((/^(80[0-9]{3}|81[0-6][0-9]{2})/.test(f.zip_code.value))&&s.querySelector('option:nth-child(2)')||s.querySelector('option:nth-child(1)'));$('#col-tax-label').text(v.innerText);s.value=v.value;};f.addEventListener('submit',colorado_check);f.zip_code.addEventListener('change',colorado_check);$('[name="shipoptmenu:0"]').hide().before($('<div id="col-tax-label"></div>'));colorado_check();}}</script>