在默认的opencart结帐示例中工作得很好。
如何使它与journal3一签出页面一起工作?
opencart 3.0.2.0
发布于 2022-08-18 02:43:44
有2 ,您可以选择或一个来实现基于哪一种方法更适合您的情况:
修改html
我假设您已经知道如何注册一个事件,下面的示例演示了如何实现该方法。请给我留言,如果你不知道如何注册一个事件,请告诉我。
1.在呈现输出之前替换视图文件
创建一个事件脚本: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);
}
}创建您自己的结帐页面视图:catalog/view/theme/journal3/template/journal3/checkout/my_checkout_page.twig
<div>
I have replace the original view with this!
</div>结果:

2.通过输出修改html
创建一个事件脚本: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);
}
}结果:

发布于 2022-08-19 09:18:54
现在我遇到了新的问题,当用户在默认的6步签出中单击此按钮(繼續===continue)时,我可以执行一些代码。
$this->model_name_event->addEvent(‘name’,'catalog/controller/checkout/payment_method/save/after','function');

但是在journal3中,一个步骤签出没有那个按钮。
https://stackoverflow.com/questions/73382680
复制相似问题