我需要重新设计产品页面的默认woocommerce模板。 我试过将avada的结构复制到child-theme。
/theme/avada/woocommerce/single-product/*
至/theme/avada-child-theme/woocommerce/single-product/
但我找不到显示整个页面的模板。只有title.php
会更改标题。但找不到页面的其余部分。
我需要删除这些部分:
- short description
- sku
- social media buttons
如何重新设计完整的产品页面对我来说是新的。 可能有人可以给我一个开始在哪里找到模板。
提前致谢。 赫尔曼
<?php
/**
* The template for displaying product content in the single-product.php template
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php
/**
* woocommerce_before_single_product hook.
*
* @hooked wc_print_notices - 10
*/
do_action( 'woocommerce_before_single_product' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
/**
* woocommerce_before_single_product_summary hook.
*
* @hooked woocommerce_show_product_sale_flash - 10
* @hooked woocommerce_show_product_images - 20
*/
do_action( 'woocommerce_before_single_product_summary' );
?>
<div class="summary entry-summary">
<?php
/**
* woocommerce_single_product_summary hook.
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
do_action( 'woocommerce_single_product_summary' );
?>
</div><!-- .summary -->
<?php
/**
* woocommerce_after_single_product_summary hook.
*
* @hooked woocommerce_output_product_data_tabs - 10
* @hooked woocommerce_upsell_display - 15
* @hooked woocommerce_output_related_products - 20
*/
do_action( 'woocommerce_after_single_product_summary' );
?>
<meta itemprop="url" content="<?php the_permalink(); ?>" />
</div><!-- #product-<?php the_ID(); ?> -->
<?php do_action( 'woocommerce_after_single_product' ); ?>
答案 0 :(得分:3)
我不了解Avada theem,但在默认的WooCommerce中,您可以在content-single-product.php
模板中看到通过 hook 添加简短描述和社交按钮。因此,要删除它们,您需要使用主题remove_action()
中的functions.php
。
如果这不能正常工作,请查看remove_action()
,因为您只需要确保参数与Avada主题的效果相符。
function so_35252579_remove_hooks(){
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
}
add_action( 'woocommerce_before_single_product', 'so_35252579_remove_hooks' );
要删除SKU,您可以禁用skus,或者如果您需要它们但不想在前端显示它们,则需要覆盖single-product/meta.php
答案 1 :(得分:0)
这是代码。您可以将其编写为插件,或者只是将粘贴复制到functions.php。请注意以下内容
add_filter(&#39; wc_get_template_part&#39;,&#39; so_29984159_custom_content_template_part&#39;,10,3);
function so_29984159_custom_content_template_part( $template, $slug, $name ){
if ( $slug == 'content' && $name == 'single-product') {
if( locate_template('content-single-product-custom.php') ) {
$template = locate_template( $file_name );
} else {
// Template not found in theme's folder, use plugin's template as a fallback
$template = dirname( __FILE__ ) . '/content-single-product-custom.php';
}
}
return $template;
}