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

Вывод Цены в товаре по самой низкой этоне?


sys
 Share

Recommended Posts

Вывод Цены в товаре по самой низкой этоне?

Как это можно сгделать? И икже нужно, чтобы перед этоной было "от"

К примеру я забиваю этону товара в анкете товара 1500 руб.

Дное создаю скидки от кол-ва товара.

К примеру:

1 товар - 2500

2 товара - 2000

Более - 1500 руб.

Короче нужно, чтобы этона бралась или из поля Цена (она и бугдет как минимальная) или из последнего поля в Скидках на кол-во.

Как это можно организовать?

Link to comment
Share on other sites


  • 3 weeks later...

в ..\catalog\controller\product\category.php найди:

$this->data['products'][] = array(
   'name'    => $result['name'],
   'model'   => $result['model'],
   'rating'  => $rating,
   'stars'   => sprintf($this->language->get('text_stars'), $rating),
   'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
   'price'   => $price,
   'options' => $options,
   'special' => $special,
   'href'    => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']),
   'add'	  => $add
);

и добавь в него строчку

'min_price'   => $this->currency->format($this->tax->calculate($min_price, $result['tax_class_id'], $this->config->get('config_tax'))),

а перед ним добавь

// 
$discounts = $this->model_catalog_product->getProductDiscounts($result['product_id']);
$min_price = $price;
foreach ($discounts as $discount) {
   if ($discount['price'] < $min_price) {
	$min_price = $discount['price'];
   }
}
if ($special && $special < $min_price) {
	$min_price = $special;
}
//

в файле ..\catalog\view\theme\default\template\product\category.tpl

<?php if (!$products[$j]['special']) { ?>
      <span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span>
<?php } else { ?>
      <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
заменить на

from: <span style="color: #900; font-weight: bold;"><?php echo $products[$j]['min_price']; ?></span>

п.с. если бугдет тупить, то строчку

$min_price = $price;
лучше всего заменить на

$min_price = $result['price'];
ик как сравнивать float и string не сильно разумно, но тем не менее, врогде как, без ошипотому чток у меня было.

в price - храниться уже выслииная этона с учетом скидок на группы пользователей, в result['price'] голая этона, потому price первоначально и выбрал.

со special вообещё убрать, липотому что послиить отгдельно, не форматирую к string типу

  • +1 1
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.