Woocommerce产品变化布局变化

时间:2015-10-17 07:46:56

标签: woocommerce

我想在单品页面上对显示变体进行一些小改动。

通常,变体显示为html。

    <table class="variations" cellspacing="0">
<tbody>

<tr>
<td class="label"><label for="group-size">Group Size</label></td>
<td class="value">
<select id="group-size" class="" name="attribute_group-size" data-attribute_name="attribute_group-size">
<option value="">Chose an options</option>
<option value="1 Person" >1 Person</option>
<option value="2 persons" >2 persons</option>
</select>
</td>
</tr>

<tr>
<td class="label"><label for="type-of-activity">Type of Activity</label></td>
<td class="value">
<select id="tipo-de-actividad" class="" name="attribute_tipo-de-actividad" data-attribute_name="attribute_type-of-activity">
<option value="">Chose an option</option>
<option value="Walking" >Walking</option>
<option value="With car" >with car</option>
</select>
<a class="reset_variations" href="#">Clean the selections</a>
</td>
</tr>

</tbody>
</table>

但我希望有这样的

    <table class="variations" cellspacing="0">
<tbody>

<tr>
<td class="label"><label for="group-size">Group Size</label></td>
</tr>
<tr>
<td class="value">
<select id="group-size" class="" name="attribute_group-size" data-attribute_name="attribute_group-size">
<option value="">Chose an options</option>
<option value="1 Person" >1 Person</option>
<option value="2 persons" >2 persons</option>
</select>
</td>
</tr>

<tr>
<td class="label"><label for="type-of-activity">Type of Activity</label></td>
</tr>
<tr>
<td class="value">
<select id="tipo-de-actividad" class="" name="attribute_tipo-de-actividad" data-attribute_name="attribute_type-of-activity">
<option value="">Chose an option</option>
<option value="Walking" >Walking</option>
<option value="With car" >with car</option>
</select>
<a class="reset_variations" href="#">Clean the selections</a>
</td>
</tr>

</tbody>
</table>

意味着我想让标签位于选项上方的行内。

我们如何做到这一点?

1 个答案:

答案 0 :(得分:2)

我自己得到了解决方案。

有变量.php 可湿性粉剂内容/插件/ woocommerce /模板/单品/添加到购物车

我打开了那个文件

ı已经改变了

<table class="variations" cellspacing="0">
            <tbody>
                <?php foreach ( $attributes as $attribute_name => $options ) : ?>
                    <tr>
                        <td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
                        <td class="value">
                            <?php
                                $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
                                wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
                                echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
                            ?>
                        </td>
                    </tr>
                <?php endforeach;?>
            </tbody>
        </table>

<table class="variations" cellspacing="0">
            <tbody>
                <?php foreach ( $attributes as $attribute_name => $options ) : ?>
                    <tr>
                        <td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
</tr>
<tr>
                        <td class="value">
                            <?php
                                $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
                                wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
                                echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
                            ?>
                        </td>
                    </tr>
                <?php endforeach;?>
            </tbody>
        </table>

结果就像我喜欢的那样。

抱歉打扰你。