Move 产品描述 Div Woocommerce [英] Move Product Description Div Woocommerce

查看:30
本文介绍了Move 产品描述 Div Woocommerce的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法将产品描述 div 移到我的 .site-inner .wrap 下方的 #container 之外

我已经取消注册标签并使用这些功能移动了我的描述:

//移除所有标签remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);//删除标签后将产品描述添加回页面函数 woocommerce_template_product_description() {woocommerce_get_template('single-product/tabs/description.php');}add_action('woocommerce_single_product_summary', 'woocommerce_template_product_description', 32);//在产品描述周围添加divadd_action('woocommerce_single_product_summary', 'hooks_open_div', 31);函数 hooks_open_div() {echo '

';}add_action('woocommerce_single_product_summary', 'hooks_close_div', 33);函数 hooks_close_div() {回声'</div>';}

以下是 html 代码当前外观的一些屏幕截图:

这是我希望 html 代码的外观的屏幕截图:

任何帮助将不胜感激.

谢谢,威廉

解决方案

我能够稍微清理我的代码,并在此过程中得到了一些帮助来解决我的问题.

让我们首先向钩子woocommerce_after_main_content"添加描述.确保仅在单个产品上有条件地运行代码(因为该挂钩位于任何 wc 页面/存档内)并为其提供优先级 20.这将在关闭内容和容器 div 后附加说明.

清理我的代码:

事实证明,我使用钩子在描述周围添加 div 环绕的方式完全错误.我被告知将它们放在函数 woocommerce_template_product_description() 中会更容易、更干净.

这是我的新工作代码:

//移除所有标签remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);//删除标签后将产品描述添加回页面函数 woocommerce_template_product_description() {if( is_product() ){echo '<div class="product-description-container"><div class="wrap">';woocommerce_get_template('single-product/tabs/description.php');回声'</div></div>';}}add_action('woocommerce_after_main_content', 'woocommerce_template_product_description', 20);

谢谢,威廉

I am looking for a way to move the product description div outside of the #container just below my .site-inner .wrap

I have already unregistered the tabs and moved my description with these functions:

//Remove all tabs 
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
//Add product description back to page after removing tabs
function woocommerce_template_product_description() {
    woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 32 );

//Add div around product description
add_action('woocommerce_single_product_summary', 'hooks_open_div', 31);
function hooks_open_div() {
    echo '<div class="product-description-container">';
}

add_action('woocommerce_single_product_summary', 'hooks_close_div', 33);
function hooks_close_div() {
    echo '</div>';
}

Here are some screen shots of how the html code currently looks:

Here is a screen shot of how I want the html code to look:

Any help would be greatly appreciated.

Thanks, William

解决方案

I was able to clean up my code a little and in the process got some help to solve my problem.

Lets first start by adding the description to the hook 'woocommerce_after_main_content'. Make sure to conditionally run the code only if on single products (cause that hook is within any wc page/archive) and give it a priority of 20. This appended the description to after closing the content and container div.

Cleaning up my code:

Turns out the way I was using hooks to add a div wrap around the description was all wrong. I was informed it would be easyer and cleaner to place them in the function woocommerce_template_product_description().

Here is my new working code:

//Remove all tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
//Add product description back to page after removing tabs
function woocommerce_template_product_description() {
    if( is_product() ){
        echo '<div class="product-description-container"><div class="wrap">';
        woocommerce_get_template( 'single-product/tabs/description.php' );
        echo '</div></div>';
    }
}
add_action( 'woocommerce_after_main_content', 'woocommerce_template_product_description', 20 );

Thanks, William

这篇关于Move 产品描述 Div Woocommerce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆