Post by onlinephilately » Wed Aug 24, 2011 12:17 am

Hi

How can I add a function so that the customer can clear his product compare list with one button "Clear all"?

New member

Posts

Joined
Thu Jan 27, 2011 3:14 am

Post by uksitebuilder » Wed Aug 24, 2011 1:32 am

You will need to add a link to the compare.tpl that links to itself with a querystring like

index.php?route=product/compare&removeall=1

then in the compare controller add a conditional to unset all session data for compare

i.e.

if(isset($this->request->get[removeall'])){

foreach($this->session->data['compare'] as $key => $value){
unset($this->session->data['compare'][$key]);
}

$this->redirect($this->url->link('product/compare'));
}

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by onlinephilately » Wed Aug 24, 2011 1:23 pm

This worked perfect - thx!

The code had one typo so use this code:

Code: Select all

if(isset($this->request->get['removeall'])) {

			foreach($this->session->data['compare'] as $key => $value) {
				unset($this->session->data['compare'][$key]);
		}

		$this->redirect($this->url->link('product/compare'));
		}

New member

Posts

Joined
Thu Jan 27, 2011 3:14 am
Who is online

Users browsing this forum: Semrush [Bot] and 73 guests