[Prestashop help] How to creating a “Clear cart” button for clear all products from a Cart in PrestaShop 1.6?
If you want display a “Clear Cart” button in Mini Cart or in Cart page of Prestashop 1.6. When click this button, it will clear all products from a Cart in PrestaShop 1.6 like this image
You can follow steps
Step 1: Open file
PRESTASHOP_ROOT\themes\YOURTHEME\shopping-cart.tpl
Example:
PRESTASHOP_ROOT\themes\default-bootstrap\shopping-cart.tpl
Add this source code below: {if isset($account_created)} …{/if} or any placements which you want display “Clear Cart” button
<!– add Clear Cart button –>
<a href=”{$link->getPageLink(“cart”, true, null, ‘clearcart=1′)|escape:”html”:”UTF-8″}” class=”btn” style=”margin: 10px 0;”>
{l s=’Clear Cart’}
</a>
<!– end Clear Cart –>
See my picture
If you use One-page checkout setting from Prestashop backoffice
You must open file:
PRESTASHOP_ROOT\themes\YOURTHEME\order-opc.tpl
Add this source code:
<!– add Clear Cart button –>
<a href=”{$link->getPageLink(“cart”, true, null, ‘clearcart=1′)|escape:”html”:”UTF-8″}” class=”btn” style=”margin: 10px 0;”>
{l s=’Clear Cart’}
</a>
<!– end Clear Cart –>
After line: {if $productNumber}
See this picture:
Step 2: Edit CartController.php
Open the file: PRESTASHOP_ROOT\controllers\front\CartController.php
find a function: init()()
Add this source code
if (Tools::getIsset(‘clearcart’)) {
$this->context->cart->delete();
$this->context->cookie->id_cart = 0;
Tools::redirect(‘index.php’);
}
After line
parent::init();
See my picture:
Also you can put that Clear Cart button on anywhere in your Prestashop 1.6 website
Leave a reply
You must be logged in to post a comment.