-
AuthorPosts
-
November 14, 2024 at 9:02 pm #1471338
Hello. I have tried several Woocommerce hooks to add text with a link to a contact page to apply for tax exemption, but it seems the Enfold theme overrides quite a few of them. Is there any way to add the text “TAX EXEMPT?” either after the word TAX in Woo cart/checkout pages, or after the dollars calculated to the right of it? Thanks.
November 15, 2024 at 7:17 am #1471364Hey Illingco,
Thank you for the inquiry.
Would you mind providing a screenshot of the area where you need this text? You can use platforms like Savvyify, Imgur, or Dropbox to upload and share the screenshot.
Best regards,
IsmaelNovember 15, 2024 at 4:19 pm #1471414Either of the areas noted in the screen shot listed. Please advise, thanks.
November 16, 2024 at 2:57 pm #1471463Hi,
I checked your previously posted staging site linked below, but the checkout is not in the same format as your screenshot.
We could add the text “TAX EXEMPT” after the word “Tax” with javascript, but we will need to see your page to examine, please link to it.Best regards,
MikeNovember 19, 2024 at 7:23 pm #1471690I’m not sure I understand. I have linked the checkout page. Please advise if this helps and what the JS might be to do this. Thanks!
November 20, 2024 at 5:30 pm #1471781November 21, 2024 at 8:58 pm #1471893Yes, where the arrow is, thank you!
November 23, 2024 at 6:58 pm #1472029Hi,
Thank you for your patience, try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function tax_exempt() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($){ $(function() { setTimeout(function(){ $('.cart_totals .tax-total th, #order_review .tax-total th').each(function() { var text = $(this).text(); $(this).text(text.replace('Tax', ' Tax Exempt ')); }); }, 2000); }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'tax_exempt', 99 );
Best regards,
MikeNovember 25, 2024 at 5:32 pm #1472169Hello Mike and thanks for this. What I was hoping for was to leave the word TAX there, and after it, text showing (TAX EXEMPT?), with the TAX EXEMPT part linked with an internal URL (and underlined) to a contact page. Is that possible? Also, can I add this to Code Snippets plugin so it does not get overwritten on theme updates? THanks!
- This reply was modified 3 weeks, 5 days ago by Illingco.
November 26, 2024 at 5:25 am #1472215Hi,
Thank you for the update.
We edited the script a bit. Please try it again and make sure to adjust the link or the href value:
function av_custom_script_tax_exempt() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($){ $(function() { setTimeout(function(){ $('.cart_totals .tax-total th, #order_review .tax-total th').each(function() { var text = $(this).text(); if (text.includes('Tax')) { $(this).html(text.replace('Tax', 'Tax (<a href="https://example.com/tax-exempt-info" target="_blank">Tax Exempt?</a>)')); } }); }, 2000); }); })(jQuery); }); </script> <?php } add_action( 'wp_footer', 'av_custom_script_tax_exempt', 99 );
Best regards,
IsmaelNovember 26, 2024 at 5:47 pm #1472296Thank you. Oddly however, it goes blank once I enter shipping details and it calculates tax. It is there for a second, and then goes away. Any idea why?
November 27, 2024 at 7:05 am #1472340Hi,
Thank you for the update.
it goes blank once I enter shipping details and it calculates tax
The script seems to be working as expected. It transforms the text from “Tax” to “Tax (Exempt?)”. How can we reproduce the issue? Please provide a screenshot using platforms like Savvyify, Imgur, or Dropbox.
Best regards,
IsmaelDecember 2, 2024 at 5:41 pm #1472731Once you fill in billing fields on checkout page, it disappears. If you try that, you should see what I mean. Thanks.
December 3, 2024 at 8:03 am #1472765Hi,
This text pops up when filling in the fields.
Suspicious activity has been detected. If you believe this to be an error, please contact (Email address hidden if logged out) .
Please disable it temporarily.
We adjusted the script a bit and added the updated_checkout event. Please try it again:
function av_custom_script_tax_exempt() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($) { $(function() { function updateTaxLabel() { $('.cart_totals .tax-total th, #order_review .tax-total th').each(function() { var text = $(this).text(); if (text.includes('Tax')) { $(this).html(text.replace('Tax', 'Tax (<a href="https://example.com/tax-exempt-info" target="_blank">Tax Exempt?</a>)')); } }); } setTimeout(updateTaxLabel, 2000); $(document.body).on('updated_checkout', function() { updateTaxLabel(); }); }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'av_custom_script_tax_exempt', 99);
Best regards,
IsmaelDecember 5, 2024 at 10:34 pm #1473045That seems to work thank you! You may close this ticket.
December 6, 2024 at 8:00 am #1473075 -
AuthorPosts
- The topic ‘Text after TAX field, or after tax calcualtion’ is closed to new replies.