I’ve looked for the solution to this but nothing seems to be working.
I have an SKU within a span with a class of “sku”. Some of the SKUs have periods before the SKU to allow for adding more than one product with the same SKU.
I’d like to hide the periods when the SKU is displayed though.
This is my code:
<span class="sku">..THESKU</span>
And this is the jQuery I am using:
<script>
$('span.sku').html($('span.sku').html().replace('.',''));
</script>
Is the right, or am I missing something? Thanks.
2
Answers
I just wanted to give an update with this. I still couldn't get the periods to hide, but I found a way to have duplicate SKUs so there was no longer a need for this. Thanks for all your help.
If anyone has a similar issue, the code I used is below which I added to the themes functions file.
add_filter( 'wc_product_has_unique_sku', '__return_false', PHP_INT_MAX );
Your code will only replace one
dot '.'
. You can use regex to remove all the dots instead:Hope this helps!
EDIT: Updated as suggested by @Taplar