Post by Clog Father » Fri Dec 02, 2016 9:50 pm

I'm running opencart 2.0.1.1 with default
at http://www.themorrisshop.com/store

I've recently installed;
"Optionalfee Giftwrap in Checkout Cart"
I fount it here:
https://www.opencart.com/index.php?rout ... cense=free

I now get this error:

Code: Select all

"Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /home/themorri/public_html/store/vqmod/vqcache/vq2-catalog_controller_checkout_cart.php on line 230"
Also customers seems unable to edit, add or remove items from Cart. it gets stuck at "LOADING..."
hoping some kind person can fix this error for me pplease as I dont know what to do, ive tryed uninstalling it but it still has the problem and i can still see "Giftwrap" code in the file after i uninstaall?
many thanks
Shaun

Here is the file mentioned in the error;

Code: Select all

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

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

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

		$data['breadcrumbs'][] = array(
			'href' => $this->url->link('common/home'),
			'text' => $this->language->get('text_home')
		);

		$data['breadcrumbs'][] = array(
			'href' => $this->url->link('checkout/cart'),
			'text' => $this->language->get('heading_title')
		);

		if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {
			$data['heading_title'] = $this->language->get('heading_title');

			$data['text_recurring_item'] = $this->language->get('text_recurring_item');
			$data['text_next'] = $this->language->get('text_next');
			$data['text_next_choice'] = $this->language->get('text_next_choice');

			$data['column_image'] = $this->language->get('column_image');
			$data['column_name'] = $this->language->get('column_name');
			$data['column_model'] = $this->language->get('column_model');
			$data['column_quantity'] = $this->language->get('column_quantity');
			$data['column_price'] = $this->language->get('column_price');
			$data['column_total'] = $this->language->get('column_total');

			$data['button_update'] = $this->language->get('button_update');
			$data['button_remove'] = $this->language->get('button_remove');
			$data['button_shopping'] = $this->language->get('button_shopping');
			$data['button_checkout'] = $this->language->get('button_checkout');

			if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
				$data['error_warning'] = $this->language->get('error_stock');
			} elseif (isset($this->session->data['error'])) {
				$data['error_warning'] = $this->session->data['error'];

				unset($this->session->data['error']);
			} else {
				$data['error_warning'] = '';
			}

			if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
				$data['attention'] = sprintf($this->language->get('text_login'), $this->url->link('account/login'), $this->url->link('account/register'));
			} else {
				$data['attention'] = '';
			}

			if (isset($this->session->data['success'])) {
				$data['success'] = $this->session->data['success'];

				unset($this->session->data['success']);
			} else {
				$data['success'] = '';
			}

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

			if ($this->config->get('config_cart_weight')) {
				$data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
			} else {
				$data['weight'] = '';
			}

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

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

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

			foreach ($products as $product) {
				$product_total = 0;

				foreach ($products as $product_2) {
					if ($product_2['product_id'] == $product['product_id']) {
						$product_total += $product_2['quantity'];
					}
				}

				if ($product['minimum'] > $product_total) {
					$data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
				}

				if ($product['image']) {
					$image = $this->model_tool_image->resize($product['image'], $this->config->get('config_image_cart_width'), $this->config->get('config_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)
					);
				}

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

				// Display prices
				if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
					$total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
				} else {
					$total = false;
				}

				$recurring = '';

				if ($product['recurring']) {
					$frequencies = array(
						'day'        => $this->language->get('text_day'),
						'week'       => $this->language->get('text_week'),
						'semi_month' => $this->language->get('text_semi_month'),
						'month'      => $this->language->get('text_month'),
						'year'       => $this->language->get('text_year'),
					);

					if ($product['recurring']['trial']) {
						$recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' ';
					}

					if ($product['recurring']['duration']) {
						$recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
					} else {
						$recurring .= sprintf($this->language->get('text_payment_cancel'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
					}
				}

				$data['products'][] = array(
					'key'       => $product['key'],
					'thumb'     => $image,
					'name'      => $product['name'],
					'model'     => $product['model'],
					'option'    => $option_data,
					'recurring' => $recurring,
					'quantity'  => $product['quantity'],
					'stock'     => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
					'reward'    => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
					'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']),
						'remove'      => $this->url->link('checkout/cart', 'remove=' . $key)
					);
				}
			}

			// Totals
			$this->load->model('extension/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_extension_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);
			}

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

			foreach ($total_data as $total) {
				
				if(isset($total['remove'])) {
					$remove = $total['remove'];
				} else {
					$remove = '';
				}
			
					'title' => $total['title'],
					
				'text'  => $this->currency->format($total['value']),
				'remove' => $remove
			
				);
			}

			$data['continue'] = $this->url->link('common/home');

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

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

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

			$data['coupon'] = $this->load->controller('checkout/coupon');
			$data['voucher'] = $this->load->controller('checkout/voucher');

				$data['giftwrap'] = $this->load->controller('checkout/giftwrap');
			
			$data['reward'] = $this->load->controller('checkout/reward');
			$data['shipping'] = $this->load->controller('checkout/shipping');
			$data['column_left'] = $this->load->controller('common/column_left');
			$data['column_right'] = $this->load->controller('common/column_right');
			$data['content_top'] = $this->load->controller('common/content_top');
			$data['content_bottom'] = $this->load->controller('common/content_bottom');
			$data['footer'] = $this->load->controller('common/footer');
			$data['header'] = $this->load->controller('common/header');

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/cart.tpl')) {
				$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/checkout/cart.tpl', $data));
			} else {
				$this->response->setOutput($this->load->view('default/template/checkout/cart.tpl', $data));
			}
		} else {
			$data['heading_title'] = $this->language->get('heading_title');

			$data['text_error'] = $this->language->get('text_empty');

			$data['button_continue'] = $this->language->get('button_continue');

			$data['continue'] = $this->url->link('common/home');

			unset($this->session->data['success']);

			$data['column_left'] = $this->load->controller('common/column_left');
			$data['column_right'] = $this->load->controller('common/column_right');
			$data['content_top'] = $this->load->controller('common/content_top');
			$data['content_bottom'] = $this->load->controller('common/content_bottom');
			$data['footer'] = $this->load->controller('common/footer');
			$data['header'] = $this->load->controller('common/header');

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
				$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data));
			} else {
				$this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data));
			}
		}
	}

	
			 
				public function removeGiftwrap() {
					if(isset($this->session->data['giftwrap'])) {
					
						$this->load->language('total/giftwrap');
					
						unset($this->session->data['giftwrap']);
						
						$this->session->data['success'] = $this->language->get('text_remove_giftwrap');
						
						$this->response->redirect($this->url->link('checkout/cart', '', 'SSL'));
					}
				}
			
			 
			
		$this->load->language('checkout/cart');

		$json = array();

		if (isset($this->request->post['product_id'])) {
			$product_id = (int)$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 = (int)$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 (isset($this->request->post['recurring_id'])) {
				$recurring_id = $this->request->post['recurring_id'];
			} else {
				$recurring_id = 0;
			}

			$recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']);

			if ($recurrings) {
				$recurring_ids = array();

				foreach ($recurrings as $recurring) {
					$recurring_ids[] = $recurring['recurring_id'];
				}

				if (!in_array($recurring_id, $recurring_ids)) {
					$json['error']['recurring'] = $this->language->get('error_recurring_required');
				}
			}

			if (!$json) {
				$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option, $recurring_id);

				$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('extension/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_extension_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->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
	
.......

Attachments

Last edited by straightlight on Mon Apr 27, 2020 8:49 am, edited 1 time in total.
Reason: Added code tags.

Newbie

Posts

Joined
Fri Dec 02, 2016 9:32 pm

Post by thekrotek » Sat Dec 03, 2016 2:42 am

Error is in this piece of code:

Code: Select all

[color=#FF0000]'title' => $total['title'],
'text' => $this->currency->format($total['value']),
'remove' => $remove
);
It is a part of some array, which is not defined (probably it's a totals array). I guess, your VQMod is improperly placing this code.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Clog Father » Sat Dec 03, 2016 5:29 am

many thanks,
any suggestions to how it should look, please?
perhaps something i could cut and past?
shaun

Newbie

Posts

Joined
Fri Dec 02, 2016 9:32 pm

Post by thekrotek » Sat Dec 03, 2016 6:50 am

Clog Father wrote:many thanks,
any suggestions to how it should look, please?
perhaps something i could cut and past?
shaun
For starters you need to find out, which particular VQMod does that.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Clog Father » Sat Dec 03, 2016 7:38 pm

I've isolated a file by renaming it; /xml/giftwrapincart.xml1
now my website seems to be working again

could it be the error you mention is in this file?
It would be great if the Gift Wrapping mod could be got working, please
Could you take a look and see if its an obvious fix for me please.
Many thanks

Code: Select all

<?xml version="1.0"?>

-<modification>


-<id>

-<![CDATA[Extra Brochure]]>
</id>


-<version>

-<![CDATA[1.0]]>
</version>


-<vqmver>

-<![CDATA[2.5.1]]>
</vqmver>


-<author>

-<![CDATA[mash0028]]>
</author>


-<file name="catalog/controller/checkout/cart.php">


-<operation>


-<search position="before">

-<![CDATA[
				$data['reward'] = $this->load->controller('checkout/reward');]]>
</search>


-<add>

-<![CDATA[
				$data['giftwrap'] = $this->load->controller('checkout/giftwrap');
			]]>
</add>

</operation>

</file>


-<file name="catalog/view/theme/*/template/checkout/cart.tpl">


-<operation>


-<search position="replace">

-<![CDATA[|| $shipping ]]>
</search>


-<add>

+<![CDATA[]]>
</add>

</operation>


-<operation>


-<search position="replace">

-<![CDATA[<?php echo $shipping; ?>]]>
</search>


-<add>

-<![CDATA[<?php echo $shipping; ?><?php echo $giftwrap; ?>]]>
</add>

</operation>

</file>


-<file path="catalog/controller/checkout/cart.php">


-<operation>


-<search>

-<![CDATA[public function add() {]]>
</search>


-<add position="before">

-<![CDATA[
				public function removeGiftwrap() {
					if(isset($this->session->data['giftwrap'])) {
					
						$this->load->language('total/giftwrap');
					
						unset($this->session->data['giftwrap']);
						
						$this->session->data['success'] = $this->language->get('text_remove_giftwrap');
						
						$this->response->redirect($this->url->link('checkout/cart', '', 'SSL'));
					}
				}
			
			 ]]>
</add>

</operation>


-<operation>


-<search>

-<![CDATA[$data['totals'][] = array(]]>
</search>


-<add position="before">

-<![CDATA[
				if(isset($total['remove'])) {
					$remove = $total['remove'];
				} else {
					$remove = '';
				}
			]]>
</add>

</operation>


-<operation>


-<search>

-<![CDATA['text'  => $this->currency->format($total['value'])]]>
</search>


-<add position="replace">

-<![CDATA[
				'text'  => $this->currency->format($total['value']),
				'remove' => $remove
			]]>
</add>

</operation>

</file>


-<file path="catalog/view/theme/*/template/checkout/cart.tpl">


-<operation>


-<search>

-<![CDATA[<td><strong><?php echo $total['title']; ?>:</strong></td>]]>
</search>


-<add position="replace">

-<![CDATA[
				<td><strong><?php if(isset($total['remove']) && $total['remove']) { ?> <a href="<?php echo $total['remove']; ?>" data-toggle="tooltip" title="Removed"> <i class="fa fa-trash-o"></i></a> <?php } ?> &nbsp;<?php echo $total['title']; ?>:</strong></td>
	      		
	      	]]>
</add>

</operation>

</file>

</modification>

Attachments

Last edited by straightlight on Mon Apr 27, 2020 8:50 am, edited 1 time in total.
Reason: Added code tags.

Newbie

Posts

Joined
Fri Dec 02, 2016 9:32 pm
Who is online

Users browsing this forum: No registered users and 1 guest