【发布时间】:2016-02-12 07:19:18
【问题描述】:
目前我的功能仅在执行前检查产品是否为“外部”类型,如何更改功能以检查产品是否是“分组”woocommerce 产品的一部分。然后回显包含已配置的父产品永久链接的按钮。
这就是我希望代码运行的方式(如果产品是分组产品的子产品 - 显示永久链接按钮)
我不再希望检查产品是否为外部类型。
function parent_permalink_button() {
global $post;
if( function_exists('get_product') ){
$product = get_product( $post->ID );
if( $product->is_type( 'external' ) ){
$permalink = get_permalink($post->post_parent);
echo '<a class="button" href="'.$permalink.'">Compare Deals</a>';
}
}
}
【问题讨论】:
标签: php woocommerce