So far, I have created a Character Counter on the Product Page, using the following code:
JavaScript/jQuery:
<script type="text/javascript">
jQuery(document).on('keyup', '.product-custom-text', updateCount);
jQuery(document).on('keydown', '.product-custom-text', updateCount);
function updateCount() {
var cs = jQuery(this).val().length;
jQuery('#character_count').text(cs);
}
</script>
I am then using the below code, in the functions.php
file, in order to Output the Character Count:
function custom_character_counter(){
echo 'Character Count: <span id="character_count"></span>';
}
add_action('woocommerce_single_product_summary', 'custom_character_counter');
My thoughts being that now that I have the Character Count Outputted to the page, I just need to figure out how to create a function which performs the following equation:
Original Product Price + (Characters Entered x £1)
which then dynamically alters the starting Product Price in real time.
Is anyone aware of how this can be achieved?
Thanks in advance.
]]>