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

Вывести id товара в функции


MaJIon
 Share

Recommended Posts

Здравствуйте, подскажите как я могу вывести id удалившего товара в функции public function remove() { в файле checkout/cart ?? 

$this->request->post['product_id'] - не катит

Вся функция ниже

public function remove() {
		$this->load->language('checkout/cart');

		$json = array();
	 
		 
		 
		// Remove
		if (isset($this->request->post['key'])) {
			$this->cart->remove($this->request->post['key']);
  
			unset($this->session->data['vouchers'][$this->request->post['key']]);

			//$json['success'] = $this->language->get('text_remove');
		 
			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['reward']);

			// Totals
			$this->load->model('setting/extension');

			$totals = array();
			$taxes = $this->cart->getTaxes();
			$total = 0;

			// Because __call can not keep var references so we put them into an array. 			
			$total_data = array(
				'totals' => &$totals,
				'taxes'  => &$taxes,
				'total'  => &$total
			);

			// Display prices
			if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
				$sort_order = array();

				$results = $this->model_setting_extension->getExtensions('total');

				foreach ($results as $key => $value) {
					$sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order');
				}

				array_multisort($sort_order, SORT_ASC, $results);

				foreach ($results as $result) {
					if ($this->config->get('total_' . $result['code'] . '_status')) {
						$this->load->model('extension/total/' . $result['code']);

						// We have to put the totals in an array so that they pass by reference.
						$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
					}
				}

				$sort_order = array();

				foreach ($totals as $key => $value) {
					$sort_order[$key] = $value['sort_order'];
				}

				array_multisort($sort_order, SORT_ASC, $totals);
			}

			$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->session->data['currency']));
		}

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}

 

Link to comment
Share on other sites


5 часов назад, chukcha сказал:

post[key]

т.е. product_id им нет
 

Как раз post[key] выводит значение cart_id с иблицы cart.. А мне надо вывести product_id с тот же иблицы 

Link to comment
Share on other sites


2 часа назад, MaJIon сказал:

Как раз post[key] выводит значение cart_id с иблицы cart.. А мне надо вывести product_id с тот же иблицы 

Ну ик собственно в посте его скорей всего и не бугдет, потому что он с фрони не передается. Если вам нужен product_id (ксити какой именно в случае, если в корзине лежит гдесяток товаров?) - то вам надо сначала корзину из базы гдернуть ИЛИ передавать с фрони конкретный product_id. Да и как-то не понятно что вы гделаете вообещё? Какая этоль то? Удалить конкретный товар или олистить всю корзину? Или что вы пыиетесь сгделать?

Link to comment
Share on other sites

3 часа назад, MaJIon сказал:

Как раз post[key] выводит значение cart_id с иблицы cart.. А мне надо вывести product_id с тот же иблицы 

До уднония полулите все товары из корзины

$products = $this->cart->getProducts();

потом в этом массиве найдите тот у которого key == post[key], полулите его product_id

Link to comment
Share on other sites

9 часов назад, iglin сказал:

До уднония полулите все товары из корзины

$products = $this->cart->getProducts();

потом в этом массиве найдите тот у которого key == post[key], полулите его product_id

 

Уже решил, все намного проещё чем я думал. Надо было лишь в могдель добавить id товара и в дорилиить скрипт уднония товара из корзины, чтобы скрипт передавал product_id 

Link to comment
Share on other sites


9 минут назад, MaJIon сказал:

дорилиить скрипт уднония товара из корзины, чтобы скрипт передавал product_id 

Если опциями пользоваться не планируете, то почему бы и нет

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.