在我的functions.php文件中,我有一些remove_actions和add_filters爲woocommerce運行,但問題是這些函數運行於所有woocommerce產品類型。if語句分組產品參考woocommerce
我想包裝一個簡單的if語句圍繞鉤子/過濾器我只能運行分組產品頁面問題是我不知道woocommerce如何引用這些頁面繼承我現在擁有的。
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
繼承人我想要做的,但我不知道$ groupped_product的正確引用。
if ($grouped_product) {
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
}
我有兩個和的add_filter卸下一個動作,我想在我的functions.php追加僅在分組產品頁面執行我只需要在第二個代碼塊在第一組括號正確的參考以上。
嘗試這種代碼,但它不工作..
if (is_product() and $product->is_type('grouped')) {
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
}
功能PHP文件
<?php
function theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style($parent_style, get_template_directory_uri() . '/style.css');
wp_enqueue_style('child-style',
get_stylesheet_directory_uri() . '/style.css',
array($parent_style)
);
}
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');
//Remove cart options from under short description.
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
//Filter below adds new tab and returns cart options within tab.
add_filter('woocommerce_product_tabs', 'woo_paym_product_tab');
function woo_paym_product_tab($tabs) {
// Adds the new tab
$tabs['paym-plans'] = array('title' => __('Contract Deals', 'woocommerce'), 'priority' => 10, 'callback' => 'woo_paym_product_tab_content');
return $tabs;
}
function woo_paym_product_tab_content() {
// The new tab content
woocommerce_template_single_add_to_cart();
}
//Filter below changes tab priority to display price plans first.
add_filter('woocommerce_product_tabs', 'sb_woo_move_description_tab', 98);
function sb_woo_move_description_tab($tabs) {
$tabs['paym-plans']['priority'] = 10;
$tabs['description']['priority'] = 20;
$tabs['additional_information']['priority'] = 30;
return $tabs;
}
?>
http://bryceadams.com/change-add-cart-text-woocommerce/這傢伙確實相似,但具有添加到購物車文本我怎麼能複製他的技術,但有刪除行動分組的產品只有東西? – Scott