【问题标题】:error in printing form in woocommercewoocommerce中的打印表单错误
【发布时间】:2015-09-24 06:52:29
【问题描述】:

我正在为我的支付网关创建一个用于 woocommerce 的支付网关插件。 在我通过我的支付网关点击结帐页面后。我收到语法错误。我想我没有错,下面是我的 process_payment 功能代码

         /**
         * Process the payment and return the result
         **/
        function process_payment($order_id){
            global $woocommerce;
            $order = new WC_Order($order_id);
            $order_id = $order_id;
            $the_order_total = $order->order_total;
            $mercahntId=$this->merchant_id;
            $merchantPassword=$this ->merchant_password;
            $retrunUrl=$this->notify_url;
            $paymentGatewayUrl=$this ->liveurl;

            echo '<form name="Generator" method="post" action="' . $paymentGatewayUrl . '">';
            echo '<input type="hidden" name="UID" value="' . $mercahntId . '">';
            echo '<input type="hidden" name="PWD" value="' . $merchantPassword . '">';
            echo '<input type="hidden" name="ProductDesc" value="' . $order_id . '">';
            echo '<input type="hidden" name="returnURL" value="' . $retrunUrl . '">';
            echo '<input type="hidden" name="Amount" value="' . $the_order_total . '">';
            echo'</form>';
            die();

            //return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url( true ));
        }

它给我一个错误 SyntaxError: Unexpected token

我认为我在 woocommerce 中使用正确的语法来打印表单。有什么想法吗?

还有一个问题,我如何才能找出错误在哪个页面和行号上。在 woocommerce 中。

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    产生错误的可能不是 HTML 的语法。服务器可能正在生成 HTML 响应(以 &lt; 开头),而执行请求的客户端并不期望它。响应可能是包裹在 HTML 中的 HTTP 状态代码,也可能是您打印的 HTML 表单。

    【讨论】:

      【解决方案2】:

      当用户在 WooCommerce 中提交订单时,会触发支付网关的 process_payment 方法。该功能使用 Ajax 运行。我相信尝试在该函数内打印任何内容都会导致错误。如果您在开发和调试插件时需要查看数据,请尝试使用 wc_add_notice 函数,不要将结果返回为成功。

      【讨论】:

        猜你喜欢
        • 2011-07-10
        • 2015-11-30
        • 2018-07-01
        • 2019-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多