douna2633
2017-04-05 16:57
浏览 47
已采纳

在OpenCart中,如何将信息传递给单独的PHP脚本?

In OpenCart 2.3.0.2, I'm trying to create a button in the Admin section that will appear on each order. Clicking this button should generate a .txt file containing certain information from that order (Customer shipping address, items ordered, etc.) in a specified folder on the server.

In a previous environment (osCommerce), I was able to achieve this by having that button be a form input, which would POST the order ID to another php script, which would use the order ID to fetch the required order information from the database and write a text file using fopen/fwrite/fclose. That script would also update the order status with a note saying the text file was created.

I guess what this boils down to is, is there a way in OpenCart to pass order information to a separate PHP script that is not natively part of the OpenCart structure?

图片转代码服务由CSDN问答提供 功能建议

在OpenCart 2.3.0.2中,我正在尝试在Admin部分创建一个按钮,该按钮将显示在每个订单上 。 单击此按钮应生成一个.txt文件,其中包含该订单中的某些信息(客户送货地址,订购的商品等)在服务器上的指定文件夹中。

在以前的环境中( osCommerce),我能够通过将该按钮作为表单输入来实现此目的,该命令将订单ID发布到另一个php脚本,该脚本将使用订单ID从数据库中获取所需的订单信息并使用以下内容编写文本文件 FOPEN / FWRITE / FCLOSE。 该脚本还会更新订单状态,并附上说明文本文件已创建的说明。

我想这归结为是,OpenCart中是否有办法将订单信息传递给 单独的PHP脚本本身不是OpenCart结构的一部分?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutan3463 2017-04-10 06:48
    已采纳
    1. Create a function in your controller, where you want to update order status and write all the order content in a file using fwrite.

    2. Modify "admin/view/template/sale/order_info.tpl". You can add a button in HTML and then using jquery, add a onclick function.

    3. In this function, you can send AJAX request to that controller. You can then receive file path of txt file in AJAX.

    4. Then open this path from jquery using "Window.open(path);" function

    Hope, it helps

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题