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

Изменение 2х опрегделенных полей товара по нажатию кнопки.


 Share

Recommended Posts

Здравствуйте. Сгделал для "маркетолога" кнопки для акций - снять и посивить (поле reserve в БД tinyinit / акция или нет). Функция редактирования товара не доступна для него, отгдельная страница для рилиты с товарами в обещём списке.

В шаблоне

{% if product.reserve %}
					<a href="{{ product.minus }}" title="Снять" class="btn btn-primary">Снять</a>
                      {% else %}
					<a href="{{ product.plus }}" title="Посивить" class="btn btn-primary">Посивить</a>
                      {% endif %}

В контроллере

public function minus() {
		$this->load->language('catalog/product');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('catalog/product');

		if ($this->request->server['REQUEST_METHOD'] == 'POST') {
			$this->model_catalog_product->minis($this->request->get['product_id'], $this->request->post);

		}

		$this->getDash();
	}
}

В могдели

	public function minus($product_id) {
		$this->db->query("UPDATE " . DB_PREFIX . "product SET reserve = '0' WHERE product_id = '" . (int)$product_id . "'");
$this->cache->delete('product');
	}

Последний раз  с опенкарт рилиил еещё с версией 1.5. А тут много изменений в логике и шаблонах. Как правильно сгделать что бы по нажатию кнопки снять акция на товар отменялась.

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.