使用woocommerce_single_product_summary
具有优先级的动作挂钩15
//test
add_action(\'woocommerce_single_product_summary\',\'ravs_credits\',15);
function ravs_credits(){
echo\'testing\';
}
以上代码打印
testing
低于产品页面上的价格。
Important Link:
woocommerce_single_product_summary 钩
WordPress hooks introduction
<人力资源>
Updated:
我假设你的信用范围表1
到100
然后指定它们。现在
在product post type中创建自定义元框。阅读How To Create Custom Post Meta Boxes读这个technique to create product rating in css现在每个产品中都有元框,给它一个介于1
到100
现在代码看起来像
//credits with rating
add_action(\'woocommerce_single_product_summary\',\'ravs_credits\',15);
function ravs_credits(){
global $post;
?>
<div class="ravs-credits">
<p>This package will grant you <?php echo get_post_meta($post->ID, $key, $single); ?> Stars</p>
<span style="width:<?php echo get_post_meta($post->ID, $key, $single); ?>%" class="rating"></span>
</div>
<?php
}
Important Link:
- get_post_meta()