首先要感谢那些愿意花时间帮助我的人。 这是我的问题,我买了一个叫做composit产品的woocommerce插件。当我创建产品时,所有产品都能正常工作,但是当我将产品添加到迷你购物车时,它会在代码中显示产品套件的名称。看看图片。
我在这两个php页面中找到了代码,但我认为这里出了问题,但我不知道在哪里:
这是组件文件:
<?php
/**
* Component item data template
*
* Override this template by copying it to 'yourtheme/woocommerce/component-item.php'.
*
* On occasion, this template file may need to be updated 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.
*
* @version 2.2.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?><dl class="component"><?php
$key = sanitize_text_field( $component_data[ 'key' ] );
?><dt class="component-<?php echo sanitize_html_class( $key ); ?>"><?php echo wp_kses_post( $component_data[ 'key' ] ); ?>:</dt>
<dd class="component-<?php echo sanitize_html_class( $key ); ?>"><?php echo wp_kses_post( wpautop( $component_data[ 'value' ] ) ); ?></dd>
</dl>
&#13;
以及包含迷你购物车代码的文件:
<ul class="mini-products-list" id="cart-sidebar" >
<?php foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) : ?>
<?php
$_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
$product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
if ($_product && $_product->exists() && $cart_item['quantity'] > 0
&& apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key)
) :
$product_name = apply_filters('woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key);
$thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(array(80, 160)), $cart_item, $cart_item_key);
$product_price = apply_filters('woocommerce_cart_item_price', WC()->cart->get_product_price($_product), $cart_item, $cart_item_key);
$cnt = sizeof(WC()->cart->get_cart());
$rowstatus = $cnt % 2 ? 'odd' : 'even';
?>
<li class="item<?php if ($cnt - 1 == $i) { ?>last<?php } ?>">
<div class="item-inner">
<a class="product-image"
href="<?php echo esc_url($_product->get_permalink($cart_item)); ?>" title="<?php echo esc_html($product_name); ?>"> <?php echo str_replace(array('http:', 'https:'), '', htmlspecialchars_decode($thumbnail)); ?> </a>
<div class="product-details">
<div class="access">
<a class="btn-edit" title="<?php esc_attr_e('Edit item','bolt') ;?>"
href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>"><i
class="icon-pencil"></i><span
class="hidden"><?php esc_attr_e('Edit item','bolt') ;?></span></a>
<a href="<?php echo esc_url(WC()->cart->get_remove_url($cart_item_key)); ?>"
title="<?php esc_attr_e('Remove This Item','bolt') ;?>" onClick=""
class="btn-remove1"><?php esc_attr_e('Remove','bolt') ;?></a>
</div>
<strong><?php echo esc_html($cart_item['quantity']); ?>
</strong> x <span class="price"><?php echo htmlspecialchars_decode($product_price); ?></span>
<p class="product-name"><a href="<?php echo esc_url($_product->get_permalink($cart_item)); ?>"
title="<?php echo esc_html($product_name); ?>"><?php echo esc_html($product_name); ?></a> </p>
</div>
<?php echo htmlspecialchars_decode(WC()->cart->get_item_data($cart_item)); ?>
</div>
</li>
<?php endif; ?>
<?php $i++; endforeach; ?>
</ul>
&#13;
等待您的回答,看看我需要更改代码的位置。
再次感谢您的帮助。
马特