我正在使用 woocommerce,并且创建了一个自定义帖子类型,该类型必须被视为产品,并且用户可以添加到购物车。我按照本教程 \n http://reigelgallarde.me/programming/how-to-add-custom-post-type-to-woocommerce/ \n 并确保我的价格字段元键是 \xe2\x80\x9c_price\xe2 \x80\x9d\n但是没用。
\n\n当我尝试将此代码添加到functions.php时
\n\nfunction reigel_woocommerce_get_price($price = null,$post = null){\nif ($post->post->post_type === \'aytam\'){\n $price = get_post_meta($post->id, "_price", true);\n }\n\nreturn $price;\n}\nadd_filter(\'woocommerce_get_price\',\'reigel_woocommerce_get_price\',20,1);\nadd_action( \'init\', \'reigel_woocommerce_get_price\' );\nRun Code Online (Sandbox Code Playgroud)\n\n也没用
\n