work fine in default opencart checkout example..
how can i make it work with journal3 one checkout page?
opencart 3.0.2.0
There are 2 approaches, you can choose either one to implement based on which approach is more applicable to your situation:
I assuming you already know how to register an event, following example just demonstrate how to implement the approach. Leave me a comment to let me know if you not sure how to register an event.
1. Replace the view file before rendering the output
Create an event script: catalog/controller/event/my_event.php
/* before */
public function beforeLoadCheckoutView(&$route, &$args) {
/*
if the view route is 'journal3/checkout/checkout',
aka: 'catalog/view/theme/journal3/template/journal3/checkout/checkout.twig'
*/
if ($route == 'journal3/checkout/checkout') {
/*
replace the view file 'journal3/checkout/checkout' with your own view file
aka: 'catalog/view/theme/journal3/template/journal3/checkout/my_checkout_page.twig'
*/
$route = str_replace('journal3/checkout/checkout', 'journal3/checkout/my_checkout_page', $route);
}
}
Create your own checkout page view: catalog/view/theme/journal3/template/journal3/checkout/my_checkout_page.twig
<div>
I have replace the original view with this!
</div>
Result:
2. Modify the html through the output
Create an event script: catalog/controller/event/my_event.php
/* after */
public function modifyCheckoutPageHtml($route, &$args, &$output) {
/*
if the view route is 'journal3/checkout/checkout',
aka: 'catalog/view/theme/journal3/template/journal3/checkout/checkout.twig'
*/
if ($route == 'journal3/checkout/checkout') {
/* replace the title with your own title */
$output = str_replace('<h1 class="title page-title">Quick Checkout</h1>', '<h1 class="title page-title">I have changed this title!</h1>', $output);
}
}
Result: