Woocommerce Custom Product Text

本小妞迷上赌 提交于 2019-12-03 14:24:13

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. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!