Woocommerce 语法错误';(T_装_和_空格)在钩子上
我在此函数中遇到此错误消息,我看不出字符有任何问题 语法错误,意外的“cfwc_save_cus”(T_ENCAPSED_和_空格)Woocommerce 语法错误';(T_装_和_空格)在钩子上,woocommerce,Woocommerce,我在此函数中遇到此错误消息,我看不出字符有任何问题 语法错误,意外的“cfwc_save_cus”(T_ENCAPSED_和_空格) 请确保双引号和引号正确匹配。如果字符串中有双引号,则可以使用运算符“(引号)对其进行转义。您的意思是$\u POST['custom\u description'] function cfwc_save_custom_field( $post_id ) { $product = wc_get_product( $post_id ); $title = isse
请确保双引号和引号正确匹配。如果字符串中有双引号,则可以使用运算符“(引号)对其进行转义。您的意思是$\u POST['custom\u description']
function cfwc_save_custom_field( $post_id ) {
$product = wc_get_product( $post_id );
$title = isset( $_POST['custom_description'] ) ? $_POST['custom_description'] : '';
$product->update_meta_data( 'custom_description', sanitize_text_field( $title ) );
$product->save();
}
add_action( 'woocommerce_process_product_meta', 'cfwc_save_custom_field' );