Jump to content
Sign in to follow this  
ionchev

Сделать отображение всех акционных цена на странице продукта.

Recommended Posts

Сделать отображение всех акционых цена на странице продукта.

Есть пять груп Default, Opt1, Opt2, Opt3, Opt4.

Для каждой групы своя цена указана через акции.

Нужно на странице продукта сделать вывод цен:

Розница (Default): 820.00 руб.

Опт1: 780.00 руб.

Опт2: 750.00 руб.

Опт3: 735.00 руб.

Опт4: 725.00 руб.

Share this post


Link to post
Share on other sites

как вариант (вместо "Розница (Default): 820.00 руб." стандартный вывод цены):

[=== catalog/controller/product/product.php ===]

перед

$this->data['options'] = array();
добавить

			$this->load->model('account/customer_group');
			$customerGroupsList = $this->model_account_customer_group->getCustomerGroups();
			
			if ($this->customer->isLogged()) {
				$webme_customer_group_id = $this->customer->getCustomerGroupId();
			} else {
				$webme_customer_group_id = $this->config->get('config_customer_group_id');
			}
			foreach ($customerGroupsList as $customerGroup) {
				if ($customerGroup['customer_group_id'] != $webme_customer_group_id) {
					$customerGroupName = $customerGroup['name'];
					
					$webmeSpecial = $this->model_catalog_product->getWholeProductSpecialData($this->request->get['product_id'], $customerGroup['customer_group_id']);
					
					if ($webmeSpecial) {
						$this->data['webmeSpecials'][] = array(
							'price'    => $this->currency->format($this->tax->calculate($webmeSpecial['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))),
							'customerGroup' => $customerGroupName
						);
					}
				}
			}
[=== catalog/model/catalog/product.php ===]

перед

public function getProductSpecials($data = array()) {
добавить

	public function getWholeProductSpecialData($product_id, $customer_group_id_listed) {
		$query = $this->db->query("SELECT `price`, `date_end`, `customer_group_id` FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$customer_group_id_listed . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");

		if ($query->num_rows) {
			return $query->row;
		} else {
			return FALSE;
		}
	}
[=== catalog/view/theme/default/template/product/product.tpl ===]

где надо, например перед

      </div>
      <?php } ?>
      <?php if ($options) { ?>
добавить

        <?php if ($webmeSpecials) { ?>
        <br />
        <div class="discount">
          <?php foreach ($webmeSpecials as $webmeSpecial) { ?>
			<?php echo "Для группы ".$webmeSpecial['customerGroup'].": ".$webmeSpecial['price'].""; ?>
			<br />
          <?php } ?>
        </div>
        <?php } ?>
обратите внимание:

текст "Для группы " забит прямо в код в шаблоне.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.