With Module you can make a link in tpl.

spstepcheckout is the module name ane

ajax is front controller .

old way : {$link->getModuleLink(‘spstepcheckout’,’ajax’)}

new way :

{url entity=’module’ name=’spstepcheckout’ controller=’ajax’ params=[‘edited’ => 1, ‘id’ => $id]}

Without Module make a controller link.

cart is the controller name and pass parameter if need.

{url entity=cart params=[‘action’ => ‘show’]}

Example :

Like : http//www.xyz.com/cart?action=show

Page link :

{ url entity=’my-account’ params=[‘edited’ => 1, ‘id’ => $id]}

category link :

{url entity=’category’ id=19 id_lang=1}

Cms page :

{url entity=’cms’ id=3 id_lang=1}

 

Create Page Link In Controller of Cart.

OutPUT : https://elevatesilver.com/cart?cart=show

$link = new Link();
$params = [‘cart’ => ‘show’];
$cartpage = $link->getPageLink(‘cart’, true, NULL, $params);

 

AJAX CALL TO CART CONTROLLER PAGE – delete cart

{url entity=’cart’ params=[‘ajax’ => true, ‘deleteAll’ => ‘1’]}

OR

<a class=”btn btn-primary” style=”float:right” id=”removeAll” href=”javascript:void(0)”>
Empty Cart
</a>

$(‘#removeAll’).click(function(e) {
e.preventDefault()
$.ajax({
type: ‘POST’,
headers: { “cache-control”: “no-cache” },
url: prestashop.urls.base_url + “cart”,
async: true,
cache: false,
data: ‘deleteAll=1&token=’ + prestashop.token + ‘&ajax=true’,
success: function(data){
window.location.reload();
}
})
});

CARTCONTROLLER.php

protected function updateCart()
{

elseif (Tools::getIsset(‘deleteAll’)) {
// die(‘test’);
$link = new Link();
$params = [‘cart’ => ‘show’];
$cartpage = $link->getPageLink(‘cart’, true, NULL, $params);
$this->context->cart->delete();
$this->context->cookie->id_cart = 0;
Tools::redirect($cartpage);

}

}

CURRENT PAGE IN in JS:

prestashop.page.page_name

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...