Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Сгделать список этон опций без нулей после точки


Recommended Posts

Всё разобрался, говорил же надо проверить массивы и циклы

 

вот правильное решение кому может поможет

в  category.TWIG

добавляем вот это

 

<div class="cart-button">				
                    {% if product.price and false %}
                        <div class="price">
                            {% if not product.special %}
                                {{ product.price }}
                            {% else %}
                                <span class="price-new">{{ product.special }}</span> 
								<span class="price-old">{{ product.price }}</span>
                            {% endif %}
								{% if product.tax %}
                                <span class="price-tax">{{ text_tax }} {{ product.tax }}</span>
								{% endif %}
                        </div>
					{% endif %}				
										
				<ul class="see">
					{% if product.options %}
						{% set i = 1 %}
						{% for option in product.options %}
							{% if option.type == 'radio' %}
								{% for option_value in option.product_option_value %}
									<li class="s{{ product.product_id }}{{ i }}" style="">
									<input type="hidden" name="quantity" size="2" value="1" />
									<input type="hidden" name="product_id" size="2" value="{{ product.product_id }}" />
									<input type="hidden" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" />
									<span class="price_box">
									<span class="weight">{{ option_value.name }}</span>
										{% if option_value.price %}
											<span class="price">{{ option_value.price }}р.</span> 
										{% endif %}
									</span>
									<a class="btn-add-cart" onclick="ser('s{{ product.product_id }}{{ i }}')">Купить</i></a>
									</li>								   
								{% set i = i + 1 %}
								{% endfor %}
							{% endif %}
						{% endfor %}
					{%  else  %}
						<li><span class="price_box"><span class="price">{{ product.price }}</span></span>
						<a class="btn-add-cart" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');">Купить (неправильно)</a></li>
					{% endif %}
				</ul>
			<div class="clearr"></div>
		</div>
		      
  </div> 

а в контроллере category.php вот это 

 

внутри цикла result создаем переменные чтобы они не затерались
foreach ($results as $result) {
				$product_option_value=array();
				$options_help=array();

------------------------------------------------
Дальше вот это

$options = $this->model_catalog_product->getProductOptions($result['product_id']);				
				foreach ($options as $option) {	
						foreach ($option['product_option_value'] as $option_value) {															
								$product_option_value[] = 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'                   => (int)$option_value['price']
								);
								//echo $option_value['price'];
						}
						foreach ($product_option_value as $option_value) {															
								echo ' пп'.$option_value['price'];
						}
						//echo count($option['product_option_value']);
						$options_help[] = array(
							'product_option_id'    => $option['product_option_id'],
							'product_option_value' => $product_option_value,
							'option_id'            => $option['option_id'],
							'name'                 => $option['name'],
							'type'                 => $option['type'],
							'value'                => $option['value'],
							'required'             => $option['required']
						);
				}
				$options=$options_help;
				
				foreach ($options as $option) {	
						foreach ($option['product_option_value'] as $option_value) {
							echo ' пп'.$option_value['price'];
							
						}
				}
				
				$data['products'][] = array(
					'product_id'  => $result['product_id'],
					'options' 	  => $options,
					'thumb'       => $image,
					'name'        => $result['name'],
					'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
			}

 

 

 

 

говорил же вам посмотрите циклы как рилииют!просто пропарсить надо было посмотреть ггде что затерается!!!

 

ВСЕМ СПАСИБО - УДАЧИ ВСЕМ И КРЕПКОГО ЗДОРОВЬЯ!

ТЕМУ МОЖНО ЗАКРЫВАТЬ!!

Edited by Dimusik
  • +1 1
Link to comment
Share on other sites


5 minutes ago, Venter said:

я чет сам затупил 

Просто когда у человека много знаний и он хорошо разбирается в чем то, он пересиет замечать простые вещи и вскакие мелоли (а у меня как раз икая ситуация была) и думает что проблема в чем то крупном и потому чтолее сложном кроется.

Мне от вас всего то и нужно было в данной задаче ваше знание PHP. НО НИКТО МЕНЯ НЕ УСЛЫШАЛ

СОВЕТ!черт кроется в мелочах

 

обращайте внимание чаещё на мелоли прежгде чем что то крупное ворочать!!

Edited by Dimusik
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.