【问题标题】:Unable to make changes in woocommerce/templates/single-product/product-attributes.php无法在 woocommerce/templates/single-product/product-attributes.php 中进行更改
【发布时间】:2020-03-09 19:44:03
【问题描述】:

无法在 Woocoommerce 插件中启用产品自定义属性的属性值之前添加空格,因为我面临的问题是属性值与表格折叠,我想让它正确enter image description here

products-attributes.php 的代码:

/**
 * Product attributes
 *
 * Used by list_attributes() in the products class.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-attributes.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 https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.6.0
 */

defined( 'ABSPATH' ) || exit;

if ( ! $product_attributes ) {
    return;
}
?>
<table class="woocommerce-product-attributes shop_attributes">
    <?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
        <tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
            <th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
            <td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
        </tr>
    <?php endforeach; ?>
</table>

请帮帮我.......

【问题讨论】:

    标签: php wordpress woocommerce plugins


    【解决方案1】:

    您可以在echo 中添加一个空格,如下所示:

    <td class="woocommerce-product-attributes-item__value"><?php echo ' ' . wp_kses_post( $product_attribute['value'] ); ?></td>
    

    或者您可以在 td 元素中应用一些左填充:

    .woocommerce-product-attributes-item__value {
        padding-left: 20px;
    }
    

    【讨论】:

    • 感谢您的建议,但它们都没有工作
    • @HassanMuhammadYounas 可以在这里发布您网站的网址吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    相关资源
    最近更新 更多