In this blog we are going to learn how to show custom block in cart summary on checkout page at front end in PrestaShop.
Sometimes we need to show some additional information or we want to display some custom block on the cart page or checkout page on the front end. So, we can achieve the same by following steps.
Let’s Do A Live Test..!!!
Firstly, We can make changes in directly on core PrestaShop tpl file to achieve your requirement. You can directly add text or HTML on your desired location in below listed files.
File Path:
/themes/classic/templates/checkout/_partials/cart-summary.tpl
/themes/classic/templates/checkout/_partials/cart-detailed-totals.tpl
By using PrestaShop hooks:
We can achieve this by registering two hooks ‘displayCheckoutSummaryTop‘ and ‘displayCheckoutSubtotalDetails‘ in custom module. You can also create a separate small module to manage things separatly.
Cart Page :
$this->registerHook('displayCheckoutSubtotalDetails'); // to show custom block on cart summary
After that, We need to create a function to call the tpl & assign variable to get desired content.
/**
* Function to show free shipping alert on cart page
*/
public function hookDisplayCheckoutSubtotalDetails()
{
if ('cart' == $this->context->controller->php_self) {
$this->context->smarty->assign(
array(
'message' => $this->l('Add $226.5 more to avail free shipping.'),
)
);
return $this->fetch(
'module:MODULE_NAME/views/templates/hook/TPL_FILE_NAME.tpl'
);
}
}
Now create a tpl file on this path “/views/templates/hook” to call in the above function & here is the result below. You can manage the hook positions according to your need from BackOffice.

Checkout Page:
$this->registerHook('displayCheckoutSummaryTop'); // to show custom block on checkout subtotal section
After that, We need to create a function related to this registered hook.
/**
* Function to show free shipping alert on checkout page
*/
public function hookDisplayCheckoutSummaryTop()
{
if ('order' == $this->context->controller->php_self) {
$this->context->smarty->assign(
array(
'message' => $this->l('Add $226.5 more to avail free shipping.'),
)
);
return $this->fetch(
'module:MODULE_NAME/views/templates/hook/TPL_FILE_NAME.tpl'
);
}
}
Here is the result below.

Note:
This is a basic example in which we shows only one custom field. You can follow same for the multiple columns/fields.
Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.
For any doubt contact us at support@webkul.com

Be the first to comment.