Post by Asherah » Sat May 28, 2022 12:11 am

Anyone can help?



Warning: sprintf(): Too few arguments in /home/u0606086/public_html/catalog/controller/common/cart.php on line 50

<?php
class ControllerCommonCart extends Controller {
public function index() {
$this->load->language('common/cart');

// 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);
}

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

$this->load->model('tool/image');
$this->load->model('tool/upload');

$data['products'] = array();

foreach ($this->cart->getProducts() as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . 'image_cart_width'), $this->config->get('theme' . $this->config->get('config_theme') . '_image_cart_height'));
} else {
$image = '';
}

$option_data = array();

foreach ($product['option'] as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

if ($upload_info) {
$value = $upload_info['name'];
} else {
$value = '';
}
}

$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
'type' => $option['type']
);
}

// Display prices
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));

$price = $this->currency->format($unit_price, $this->session->data['currency']);
$total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']);
} else {
$price = false;
$total = false;
}

$data['products'][] = array(
'cart_id' => $product['cart_id'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''),
'quantity' => $product['quantity'],
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
}

// Gift Voucher
$data['vouchers'] = array();

if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $key => $voucher) {
$data['vouchers'][] = array(
'key' => $key,
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency'])
);
}
}

$data['totals'] = array();

foreach ($totals as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'], $this->session->data['currency']),
);
}

$data['cart'] = $this->url->link('checkout/cart');
$data['checkout'] = $this->url->link('checkout/checkout', '', true);

return $this->load->view('common/cart', $data);
}

public function info() {
$this->response->setOutput($this->index());
}
}

Newbie

Posts

Joined
Fri May 27, 2022 11:57 pm

Post by straightlight » Sun May 29, 2022 8:05 pm

OC version. Lack of info. Server error logs.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xxvirusxx » Tue May 31, 2022 2:03 pm

Asherah wrote:
Sat May 28, 2022 12:11 am
$data['text_items_mobile'] = sprintf($this->language->get('text_items_mobile'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0));
Possible theme issue or some ocmod extension. That code is not in a clean file.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: jagall, JNeuhoff, SohBH and 249 guests