Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

попытка добавить опции на страницу каталога


 Share

Recommended Posts

здравствуйте.

добавил опции на страницу каталога. все в принципе ок. но неверно отображается цена опций.

 

твиг:

<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">&times;</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

 

т.е. вместо цены опции выводит цену товара без скидки.

 

 

 

Link to comment
Share on other sites


В 27.12.2022 в 11:40, LeonidoPapagatto сказав:

Покупателя надо побуждать зайти в карточку товара

в категориях у товара опции не нужны

 

нужно вывести одну опцию.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.