Кнопка добавить в корзину с пользовательскими полями и дополнительными атрибутами в категории

10 года 3 мес. назад #5193 от spro1
Всем привет!

Необходимо добавить в категорию виртумарт 2 возможность добавить товар в корзину, при этом нужно, чтобы пользовательские поля и дополнительные атрибуты так же можно было выбирать. По сути нужно сделать так, чтобы кнопка купить со всеми доп полями в категории была точно такая же, как и в карточке товара.

Кнопку купить добавить получилось, решений подобной задачи в гугле найти получилось несколько, но вот как сделать эту кнопку с остальными полями, я не знаю.

Помогите, пожалуйста!

Пожалуйста Войдите или Зарегистрируйтесь, чтобы присоединиться к беседе.

10 года 3 мес. назад #5198 от Wedal
spro1, в категории работает вот что:
$product->customfieldsCart
это для полей, являющихся атрибутом корзины.
И:
$product->customfields
для всех остальных.

Посмотреть, что там доступно, можно путем вставки в макет категории кода:
<pre><?php print_r($product->customfieldsCart); ?></pre>
или
<pre><?php print_r($product->customfields); ?></pre>

Пожалуйста Войдите или Зарегистрируйтесь, чтобы присоединиться к беседе.

10 года 3 мес. назад - 10 года 3 мес. назад #5201 от spro1
После вставки кода
<pre><?php print_r($product->customfieldsCart); ?></pre>
у меня на сайте появился следующий код
Array
(
    [0] => stdClass Object
        (
            [virtuemart_custom_id] => 23
            [custom_title] => Размер
            [custom_value] => 90; 100; 110; 120
            [custom_field_desc] => 
            [custom_tip] => 
            [field_type] => V
            [virtuemart_customfield_id] => 63
            [is_hidden] => 0
            [options] => Array
                (
                    [60] => stdClass Object
                        (
                            [virtuemart_product_id] => 123
                            [custom_params] => 0
                            [custom_element] => 0
                            [virtuemart_custom_id] => 23
                            [virtuemart_customfield_id] => 60
                            [custom_value] => 90
                            [custom_price] => 
                            [custom_param] => 
                            [text] => 90 
                        )
 
                    [61] => stdClass Object
                        (
                            [virtuemart_product_id] => 123
                            [custom_params] => 0
                            [custom_element] => 0
                            [virtuemart_custom_id] => 23
                            [virtuemart_customfield_id] => 61
                            [custom_value] =>  100
                            [custom_price] => 
                            [custom_param] => 
                            [text] =>  100 
                        )
 
                    [62] => stdClass Object
                        (
                            [virtuemart_product_id] => 123
                            [custom_params] => 0
                            [custom_element] => 0
                            [virtuemart_custom_id] => 23
                            [virtuemart_customfield_id] => 62
                            [custom_value] =>  110
                            [custom_price] => 
                            [custom_param] => 
                            [text] =>  110 
                        )
 
                    [63] => stdClass Object
                        (
                            [virtuemart_product_id] => 123
                            [custom_params] => 0
                            [custom_element] => 0
                            [virtuemart_custom_id] => 23
                            [virtuemart_customfield_id] => 63
                            [custom_value] =>  120
                            [custom_price] => 
                            [custom_param] => 
                            [text] =>  120 
                        )
 
                )
 
            [display] => [b]тут выводиться мое пользовательское поле, но без названия [/b] 
 
 
 
 
 
 
        )
 
)


Дело за малым, нужно убрать его и сделать, чтобы перед самим пользовательским полем выводилось его название

Простите за глупые вопросы, у меня нет совсем никаких знаний в области php.

Пожалуйста Войдите или Зарегистрируйтесь, чтобы присоединиться к беседе.

10 года 3 мес. назад #5202 от spro1
нашел ответ

поля корректно отображаются после вставки кода
<!-- Пытаемся вставить ручные поля  -->
  <?php // Product custom_fields
  if (!empty($product->customfieldsCart)) {  ?>
  <div class="product-fields">
      <?php foreach ($product->customfieldsCart as $field)
      { ?><div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
        <span class="product-fields-title" ><b><?php echo  JText::_($field->custom_title)?></b></span>
        <?php //echo JHTML::tooltip($field->custom_tip,  JText::_($field->custom_title), 'tooltip.png'); ?>
        <span class="product-field-display"><?php echo $field->display ?></span>
 
        <span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
        </div><br/ >
        <?php
      }
      ?>
  </div>
  <?php }
    /* Product custom Childs
    * to display a simple link use $field->virtuemart_product_id as link to child product_id
    * custom_value is relation value to child
    */
 
  if (!empty($product->customsChilds)) {  ?>
      <div class="product-fields">
        <?php foreach ($product->customsChilds as $field) {  ?>
            <div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field->field_type ?>">
            <span class="product-fields-title" ><b><?php echo JText::_($field->field->custom_title)?></b></span>
            <span class="product-field-desc"><?php echo JText::_($field->field->custom_value)?></span>
            <span class="product-field-display"><?php echo $field->display ?></span>
 
            </div><br/ >
            <?php
        } ?>
      </div>
  <?php } ?>

Пожалуйста Войдите или Зарегистрируйтесь, чтобы присоединиться к беседе.