gpt4 book ai didi

php - 如何将产品描述(简短)添加到 woocommerce 中的悬停框?

转载 作者:太空宇宙 更新时间:2023-11-04 02:38:51 27 4
gpt4 key购买 nike

我正在使用以下内容将产品名称和价格添加到悬停框。

在 functions.php 中

// Alter produt loop individual products 

add_action( 'woocommerce_before_shop_loop_item_title', 'new_product_defaults_wrap_open' , 20 ); //opener
add_action( 'woocommerce_after_shop_loop_item_title', 'new_product_defaults_wrap_close', 40); //closer

function new_product_defaults_wrap_open() {
echo '<div class="product-details">';
}
function new_product_defaults_wrap_close() {
echo '</div><!--/.product-details-->';
}

在 CSS 中:

/*The code below will simply setup the price-title area to be hidden and have a background. Please note that uou will have to change the background and height to match your website color scheme and product height  but first load it as and then adjust                                                                                      
*/

.products .product .product-details {
position: absolute;
background: rgba(119, 203, 109, 0.95);
top: 0;
left: 0;
right: 0;
bottom: 0;
color: #f7f7f7;
padding: 1.618em;
text-align: left;
opacity: 0;
height: 167px;
filter: alpha(opacity=@opacity * 100);
-webkit-transition: all ease 0.4s;
-moz-transition: all ease 0.4s;
-ms-transition: all ease 0.4s;
-o-transition: all ease 0.4s;
transition: all ease 0.4s;
}

/* Show the that was setup above when the user hovers*/

ul.products li.product:hover .product-details {
filter: alpha(opacity=@opacity * 100);
opacity: 1;
}

ul.products li.product a img:hover {
opacity: 0.9;
}

我从 https://support.woothemes.com/hc/en-us/articles/203103707-Products-layout-show-price-on-hover-like-Peddlar-theme-?page=1#comment_203088363 得到了这段代码.

我想将产品简短描述添加到 .product-details 类中,但我不知道该怎么做。

谢谢。

最佳答案

WooCommerce 产品描述使用 the_excerpt() 函数...像这样尝试...

function new_product_defaults_wrap_open() {
echo '<div class="product-details">';
the_excerpt();
}

关于php - 如何将产品描述(简短)添加到 woocommerce 中的悬停框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35135891/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com