здравствуйте.
добавил опции на страницу каталога. все в принципе ок. но неверно отображается цена опций.
твиг:
<div class="button-group but_box">
<input type="hidden" name="product_id" value="{{ product.product_id }}">
<input type="hidden" name="quantity" value="{{ product.minimum }}">
<button type="button" class="add_cart" onclick="cart.add2('{{ product.product_id }}');">{{ button_cart }}</button>
<span class="dop_but">
<button type="button" data-toggle="tooltip" title="{{ button_compare }}" onclick="compare.add('{{ product.product_id }}');"><img src="/image/catalog/icons/compare.png"></button>
<button type="button" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product.product_id }}');"><img src="/image/catalog/icons/like.png"></button>
</span>
</div>
контроллер:
$options = array();
foreach ($this->model_catalog_product->getProductOptions($result['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']) {
$opt_price = $this->currency->format($this->tax->calculate($option_value['price'], $result['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']);
} else {
$opt_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']
);
}
}
$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']
);
}
common.js
'add2': function(product_id) {
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: $('#product'+product_id+' input[type=\'text\'], #product'+product_id+' input[type=\'hidden\'], #product'+product_id+' input[type=\'radio\']:checked, #product'+product_id+' input[type=\'checkbox\']:checked, #product'+product_id+' select, #product'+product_id+' textarea'),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
},
success: function(json) {
$('.alert-dismissible, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['success']) {
$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
$('.cart_num').html('<div class="flex3">' + json['total'] + '</div>');
$('html, body').animate({ scrollTop: 0 }, 'slow');
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
результат:
https://prnt.sc/cy4qOvx4j9yP
т.е. вместо цены опции выводит цену товара без скидки.