NIe ma tu edytuj czy ja nie widzę.
Czy mówiąc o kontrolerze masz na myśli "catalog/controller/product/product.php" tą ścieżkę? Ale która funkcja oblicza cenę?? nie widzę
public function write() {
$this->language->load('product/product');
$this->load->model('catalog/review');
$json = array();
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
$json['error'] = $this->language->get('error_name');
}
if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
$json['error'] = $this->language->get('error_text');
}
if (empty($this->request->post['rating'])) {
$json['error'] = $this->language->get('error_rating');
}
if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$json['error'] = $this->language->get('error_captcha');
}
if (!isset($json['error'])) {
$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
$json['success'] = $this->language->get('text_success');
}
}
$this->response->setOutput(json_encode($json));
}
public function add() {
$this->language->load('checkout/cart');
$json = array();
if (isset($this->request->post['product_id'])) {
$product_id = $this->request->post['product_id'];
} else {
$product_id = 0;
}
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if (isset($this->request->post['quantity'])) {
$quantity = $this->request->post['quantity'];
} else {
$quantity = 1;
}
if (isset($this->request->post['option'])) {
$option = array_filter($this->request->post['option']);
} else {
$option = array();
}
$product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
}
}
if (!$json) {
$this->cart->add($this->request->post['product_id'], $quantity, $option);
$json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('checkout/cart'));
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
// Totals
$this->load->model('setting/extension');
$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();
// Display prices
if (($this->config->get('config_customer_price') && $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($value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);
$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
$sort_order = array();
foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $total_data);
}
}
$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));
} else {
$json['redirect'] = str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
}
}
$this->response->setOutput(json_encode($json));
}
if ($product_info) {
if (isset($this->request->post['quantity'])) {
$quantity = $this->request->post['quantity'];
} else {
$quantity = 1;
}
if (isset($this->request->post['cena'])) {
$price = $this->request->post['cena'];
}
Powrót do Dyskusje ogólne o Opencart
Użytkownicy przeglądający ten dział: Brak zidentyfikowanych użytkowników i 1 gość