2015-10-17 4 views
1

Я хочу сделать небольшое изменение на странице с одним продуктом о отображении вариантов.Изменение формы продукта в версии 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> 

означает, что я wantto имеют метки внутри ряд чуть выше опций.

Как мы можем это сделать?

ответ

1

Я получил решение самостоятельно.

Существует variable.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> 

Результат был, как я хотел.

Извините за нарушение.

Смежные вопросы