首页 > 解决方案 > Woocommerce Hook 上的语法错误(T_ENCAPSED_AND_WHITESPACE)

问题描述

我在这个函数中遇到了这个错误消息,我没有看到字符有任何问题。

语法错误,意外的“cfwc_save_cus”(T_ENCAPSED_AND_WHITESPACE)

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' );

标签: woocommerce

解决方案


推荐阅读