我已经使用了我在这里找到的 brasofilo 提供的解决方案结帐 woocommerce wordpress 中的简短描述.
但由于某种原因,每个产品的每个描述后都会添加一个冒号。
我用萤火虫试图找出它可能来自哪里。它显示在结帐页面上显示的每个产品的 dt class="variation-Productdescription" 末尾。这是我从 firebug 复制的代码:
<tbody>
<tr class="cart_item">
<td class="product-name">
<a href="http://shopurl/product/Product1/">Product1</a>
<strong class="product-quantity">× 1</strong>
<dl class="variation">
<dt class="variation-Productdescription">
<div class="post-content">
:
</dt>
<dd class="variation-Productdescription></dd>
</dl>
</td>
<td class="product-total">
</tr>
<tr class="cart_item">
</tbody>
Edit:
由于我是新人,所以我还无法在这里上传图片,所以我将问题的屏幕截图上传到https://i.stack.imgur.com/xzQHZ.jpg
产品简短描述没有冒号。
产品简短描述的屏幕截图
Edit 2:
现在对我有用的解决方案是:
add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_27900033', 10, 2 );
function wc_checkout_description_so_27900033( $other_data, $cart_item )
{
$post_data = get_post( $cart_item['product_id'] );
echo $post_data->post_excerpt;
return $other_data;
}
但正如 helgatheviking 所指出的,这不是一个好的解决方案,尽管它有效。
我将努力寻找更好的解决方案echo
.
我想在 WooCommerce v2.2 左右的某个时候$other_data
checkout 类中的变量已更改为需要的数组name
and value
对。因此,来自其他线程的代码已过时。使用它 WooCommerce 找不到name
or the value
所以这些部分是空白的,在它们应该在的位置之间只剩下冒号。尝试一下这个更新:
add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_27900033', 10, 2 );
function wc_checkout_description_so_27900033( $other_data, $cart_item )
{
$post_data = get_post( $cart_item['product_id'] );
$other_data[] = array( 'name' => 'description', 'value' => $post_data->post_excerpt );
return $other_data;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)