Hi
How can I add a function so that the customer can clear his product compare list with one button "Clear all"?
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'));
}
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'));
}
This worked perfect - thx!
The code had one typo so use this code:
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'));
}
Who is online
Users browsing this forum: No registered users and 90 guests