NOIP
Гуру форума
- Регистрация
- 17 Фев 2008
- Сообщения
- 327
- Реакции
- 77
- Автор темы
- #1
Помогите пожалуйста, как вывести опции в категории.
То что отвечает за опции в карточке товара. Пытался добавлять в категории и нечего не вышло.
В шаблон тоже выносил
Может кто сталкивался?
То что отвечает за опции в карточке товара. Пытался добавлять в категории и нечего не вышло.
Код:
$data['options'] = array();
foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
$product_option_value_data = array();
foreach ($option['product_option_value'] as $option_value) {
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
$price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']);
} else {
$price = false;
}
$product_option_value_data[] = array(
'product_option_value_id' => $option_value['product_option_value_id'],
'option_value_id' => $option_value['option_value_id'],
'name' => $option_value['name'],
'image' => $this->model_tool_image->resize($option_value['image'], 50, 50),
'price' => $price,
'price_prefix' => $option_value['price_prefix']
);
}
}
$data['options'][] = array(
'product_option_id' => $option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $option['option_id'],
'name' => $option['name'],
'type' => $option['type'],
'value' => $option['value'],
'required' => $option['required']
);
}
В шаблон тоже выносил
Код:
<div class="us-product-action-left">
{% if options %}
<div class="us-product-option" id="us-product-options-box">
<div class="us-product-option-title" style="display: none;">{{ text_option }}</div>
{% for option in options %}
{% if option.type == 'select' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<select name="option[{{ option.product_option_id }}]" id="input-option{{ option.product_option_id }}" class="us-acc-select">
<option value="">{{ text_select }}</option>
{% for option_value in option.product_option_value %}
<option value="{{ option_value.product_option_value_id }}">{{ option_value.name }}
{% if option_value.price %}
({{ option_value.price_prefix }}{{ option_value.price }})
{% endif %}
</option>
{% endfor %}
</select>
</div>
{% endif %}
{% if option.type == 'radio' %}
<div class="form-group">
<label class="control-label">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<div id="input-option{{ option.product_option_id }}" class="options-box d-xl-flex flex-wrap align-items-center">
{% for option_value in option.product_option_value %}
<div class="radio">
<label data-toggle="tooltip" data-trigger="hover" class="optid {{ option.product_option_id }} not-selected{% if option_value.image %} radio-img{% endif %}" {% if option_value.price %}title="{{ option_value.price_prefix }}{{ option_value.price }}"{% endif %}>
<input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" class="d-none" />
{% if option_value.image %}
<img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" />
{% else %}
{{ option_value.name }}
{% endif %}
</label>
<script>
$(document).ready(function() {
$('label.optid.{{ option.product_option_id }}').click(function(){
$('label.optid.{{ option.product_option_id }}').removeClass('selected').addClass('not-selected');
$(this).removeClass('not-selected').addClass('selected');
});
});
</script>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if option.type == 'checkbox' %}
<div class="us-form-checkbox-group">
<div class="control-label">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</div>
<div id="input-option{{ option.product_option_id }}">
{% for option_value in option.product_option_value %}
<div class="checkbox">
<input type="checkbox" id="option[{{ option.product_option_id }}][{{ option_value.product_option_value_id }}]" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" class="us-form-checkbox-input" />
<label for="option[{{ option.product_option_id }}][{{ option_value.product_option_value_id }}]" class="d-flex align-items-center">{% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %}
<span>{{ option_value.name }}
{% if option_value.price %}
({{ option_value.price_prefix }}{{ option_value.price }})
{% endif %}</span></label>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if option.type == 'text' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control" />
</div>
{% endif %}
{% if option.type == 'textarea' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<textarea name="option[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}" class="form-control">{{ option.value }}</textarea>
</div>
{% endif %}
{% if option.type == 'file' %}
<div class="form-group">
<label class="control-label">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<button type="button" id="button-upload{{ option.product_option_id }}" data-loading-text="{{ text_loading }}" class="us-module-btn"><i class="fa fa-upload"></i> {{ button_upload }}</button>
<input type="hidden" name="option[{{ option.product_option_id }}]" value="" id="input-option{{ option.product_option_id }}" />
</div>
{% endif %}
{% if option.type == 'date' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<div class="input-group date">
<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD" id="input-option{{ option.product_option_id }}" class="form-control" />
<span class="input-group-btn">
<button class="us-module-btn" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
{% endif %}
{% if option.type == 'datetime' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<div class="input-group datetime">
<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="YYYY-MM-DD HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" />
<span class="input-group-btn">
<button type="button" class="us-module-btn"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
{% endif %}
{% if option.type == 'time' %}
<div class="form-group">
<label class="control-label" for="input-option{{ option.product_option_id }}">{% if option.required %}<span class="required">*</span> {% endif %}{{ option.name }}</label>
<div class="input-group time">
<input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}" data-date-format="HH:mm" id="input-option{{ option.product_option_id }}" class="form-control" />
<span class="input-group-btn">
<button type="button" class="us-module-btn"><i class="fa fa-calendar"></i></button>
</span>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% if recurrings %}
<div class="us-product-option">
<div class="us-product-option-title">{{ text_payment_recurring }}</div>
<div class="form-group required">
<select name="recurring_id" class="form-control">
<option value="">{{ text_select }}</option>
{% for recurring in recurrings %}
<option value="{{ recurring.recurring_id }}">{{ recurring.name }}</option>
{% endfor %}
</select>
<div class="help-block" id="recurring-description"></div>
</div>
</div>
{% endif %}
<div class="us-product-quantity">
<label class="control-label product-quantity-label" for="input-quantity">{{ entry_qty }}:</label>
<div class="btn-group us-product-quantity" role="group">
<button type="button" class="us-product-quantity-btn" onclick="updateValueProduct(true, false, false);">-</button>
<input type="text" class="form-control" name="quantity" value="{{ minimum }}" id="input-quantity" />
<input type="hidden" name="product_id" value="{{ product_id }}" />
<button type="button" class="us-product-quantity-btn" onclick="updateValueProduct(false, true, false);">+</button>
<input type="hidden" id="min-product-quantity" value="{{ minimum }}" name="min_quantity">
<input type="hidden" id="max-product-quantity" value="{{ max_quantity }}" name="max_quantity">
</div>
{% if minimum > 1 %}
<div class="us-product-minimum"><i class="fas fa-info-circle"></i> {{ text_minimum }}</div>
{% endif %}
</div>
<button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="us-product-btn us-product-btn-active">{{ button_cart }}</button>
{% if product_js_button is defined and product_js_button %}
<div class="us-product-social-buttons">{{ product_js_button }}</div>
{% endif %}
</div>
Может кто сталкивался?