Woocommerce Custom Product Text Woocommerce Custom Product Text wordpress wordpress

Woocommerce Custom Product Text


I found the answer if anyone was wondering.

            // Get value from post data            // Don't use woocommerce_clean as it destroys sanitized characters            $value = sanitize_title( trim( stripslashes( $_REQUEST[ $taxonomy ] ) ) );

The previous is located on line 339 in woocommerce-functions.php.It needs to be changed to:

 $value = trim( stripslashes( $_REQUEST[ $taxonomy ] ) ) 

Now it's just a matter of overriding this file properly. I copied the original function from the woocommerce-functions.php and added it to my theme's functions.php. I then changed it so that it does not sanitize the user input.

This is what I added to my theme's functions.php:

add_action( 'init', 'override_add_to_cart_action' );function override_add_to_cart_action( $url = false ) { // Original function is woocommerce_add_to_cart_action()     // ... full function above and below     $value = trim( stripslashes( $_REQUEST[ $taxonomy ] ) );     // ...}

By doing it this way we do not have to change any core files allowing us to update the plugin when needed. :)