Opencart Ajax快速结账,如何在单击确认订单按钮时实现新操作


Opencart Ajax quickcheckout , how to implement a new action when confirm order button is clicked

我试图在opencart中实现订单到ajax快速结账的SMS验证。http://www.opencart.com/index.php?route=extension/extension/info&extension_id=15580

扩展插件在默认签出模板上运行良好。它会弹出一个窗口来输入收到的代码。当输入正确的代码时,结账功能就完成了,订单也就下了。但是,如果我想让AJAX快速结账,我该怎么办。我已经提供了vQmod xml文件,它是默认模板,我需要它来处理ajax结账。

这是短信验证模块的vQmod xml。默认签出。

<modification>
<id><![CDATA[sms-confirmation-of-payment-methods-oc2-extension]]></id>
<version><![CDATA[3.2.0]]></version>
<author><![CDATA[dev@smshare.fr - http://www.smshare.fr]]></author>
<vqmver><![CDATA[2.5.1]]></vqmver>
<file name="catalog/view/theme/*/template/checkout/checkout.tpl">
    <operation info="Intercept clicks on the button that validate payment method choice">
        <search position="before" offset="1"><![CDATA[url: 'index.php?route=checkout/confirm',]]></search>
        <add><![CDATA[
    var wait_for_confirmation = false;
    $.ajax({
        async: false,
        url  : 'index.php?route=checkout/smshare_scpm/payment_method_chosen', 
        type : 'post',            
        dataType: 'json',
        success: function(json) {
            console.log(json['scpm_code_status']);
            if(json['scpm_code_status'] === 'scpm_code_sent'){
                wait_for_confirmation = true;
                //show the popup to confirm the code.
                //$.magnificPopup.open({
                //    modal: true,
                //    items: {
                //        src: '#smshare-popup', // can be a HTML string, jQuery object, or CSS selector
                //        type: 'inline'
                //    }
                //});
                $.magnificPopup.open({
                    modal: true,
                    items: {
                        src: 'index.php?route=checkout/smshare_scpm/load_popup_content',
                        type: 'ajax'
                    }
                });  
            }
        }
    });
    if(wait_for_confirmation) return;
        ]]></add>
    </operation>
</file>

<file name="catalog/controller/checkout/checkout.php">
    <operation info="Inject somewhere popup scripts">
        <search position="after"><![CDATA[$this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');]]></search>
        <add><![CDATA[
        //SCPM: popup
        $this->document->addScript('catalog/view/javascript/smshare/popup/jquery.magnific-popup.js');
        $this->document->addStyle('catalog/view/javascript/smshare/popup/magnific-popup.css');
        //SCPM: ladda
        $this->document->addScript('catalog/view/javascript/smshare/ladda/spin.min.js');
        $this->document->addScript('catalog/view/javascript/smshare/ladda/ladda.min.js');
        $this->document->addStyle('catalog/view/javascript/smshare/ladda/ladda-themeless.min.css');
        ]]></add>
    </operation>
</file>

对于订单短信,我以前也这样做过。相反,使用JavaScript解决方案的是Native opencart解决方案。

catalog/model/checkout/order.php

addOrderHistory功能下

寻找下列

// If order status is 0 then becomes greater than 0 send main html email
if (!$order_info['order_status_id'] && $order_status_id) {

在这之后,这条线调用你的方法

可能像这个

$this->load->model('module/sms');   
$this->model_module_sms->on_order_add($order_id, $order_info['total']);

我不建议直接修改原始文件。请改用vqmod。