<tfoot id='stSa0'></tfoot>
  • <i id='stSa0'><tr id='stSa0'><dt id='stSa0'><q id='stSa0'><span id='stSa0'><b id='stSa0'><form id='stSa0'><ins id='stSa0'></ins><ul id='stSa0'></ul><sub id='stSa0'></sub></form><legend id='stSa0'></legend><bdo id='stSa0'><pre id='stSa0'><center id='stSa0'></center></pre></bdo></b><th id='stSa0'></th></span></q></dt></tr></i><div id='stSa0'><tfoot id='stSa0'></tfoot><dl id='stSa0'><fieldset id='stSa0'></fieldset></dl></div>
    1. <legend id='stSa0'><style id='stSa0'><dir id='stSa0'><q id='stSa0'></q></dir></style></legend>

    2. <small id='stSa0'></small><noframes id='stSa0'>

        <bdo id='stSa0'></bdo><ul id='stSa0'></ul>

        如何为创建的每个新订单、产品等订阅 DrupalCommerce 2X 事件

        How to Subscribe to DrupalCommerce 2X Events for every new Order, Product etc is created(如何为创建的每个新订单、产品等订阅 DrupalCommerce 2X 事件)

        1. <i id='B8cGN'><tr id='B8cGN'><dt id='B8cGN'><q id='B8cGN'><span id='B8cGN'><b id='B8cGN'><form id='B8cGN'><ins id='B8cGN'></ins><ul id='B8cGN'></ul><sub id='B8cGN'></sub></form><legend id='B8cGN'></legend><bdo id='B8cGN'><pre id='B8cGN'><center id='B8cGN'></center></pre></bdo></b><th id='B8cGN'></th></span></q></dt></tr></i><div id='B8cGN'><tfoot id='B8cGN'></tfoot><dl id='B8cGN'><fieldset id='B8cGN'></fieldset></dl></div>

          <legend id='B8cGN'><style id='B8cGN'><dir id='B8cGN'><q id='B8cGN'></q></dir></style></legend>

          <small id='B8cGN'></small><noframes id='B8cGN'>

            <tfoot id='B8cGN'></tfoot>

              <bdo id='B8cGN'></bdo><ul id='B8cGN'></ul>
                <tbody id='B8cGN'></tbody>
                  本文介绍了如何为创建的每个新订单、产品等订阅 DrupalCommerce 2X 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要能够编写一个插件来获取订单、产品等,每当在 DrupalCommerce 2X 中创建新订单、产品时.但我似乎无法弄清楚商务部希望我怎么做.我没有看到任何可以为我提供数据的 *events 文件.

                  I need to be able to write a Plugin that gets the orders, product, etc., whenever a new Order, Product is created in DrupalCommerce 2X. but I can't seem to figure out how Commerce wants me to do it. I don't see any *events files that would give me the data.

                  看起来 Commerce 希望我创建一个单独的事件流插件来添加我想要的步骤,但我似乎找不到关于实现我自己的事件流的文档.

                  It looks like Commerce wants me to create a separate Event Flow plugin that would add the step I want, but I can't seem to find documentation about implementing my own Event Flow.

                  您能否在创建订单或产品时指导我运行我的代码的正确路径?我在正确的道路上吗?你能指出事件/事件订阅者流的开发文档吗?

                  Can you guide me to the right path of running my code when the order or product is created? Am I on the right path? Can you point to Events/EventSubscriber Flow development docs?

                  推荐答案

                  订单完成后,系统调用 commerce_order.place.post_transition.所以您需要在结帐完成时创建一个事件.

                  On order complete, system call the commerce_order.place.post_transition. so You need to create an Event on Checkout complete.

                  对转型做出反应

                  示例 - 对订单放置"转换做出反应.

                  Example - reacting to the order 'place' transition.

                  // mymodule/src/EventSubscriber/MyModuleEventSubscriber.php
                  namespace Drupalmy_moduleEventSubscriber;
                  
                  use SymfonyComponentEventDispatcherEventSubscriberInterface;
                  use Drupalstate_machineEventWorkflowTransitionEvent;
                  
                  class MyModuleEventSubscriber implements EventSubscriberInterface {
                  
                    public static function getSubscribedEvents() {
                      // The format for adding a state machine event to subscribe to is:
                      // {group}.{transition key}.pre_transition or {group}.{transition key}.post_transition
                      // depending on when you want to react.
                      $events = ['commerce_order.place.post_transition' => 'onOrderPlace'];
                      return $events;
                    }
                  
                    public function onOrderPlace(WorkflowTransitionEvent $event) {
                      // @todo Write code that will run when the subscribed event fires.
                    }
                  }
                  

                  告诉 Drupal 关于你的事件订阅者

                  Telling Drupal About Your Event Subscriber

                  您的事件订阅者应添加到模块基本目录中的 {module}.services.yml.

                  Your event subscriber should be added to {module}.services.yml in the base directory of your module.

                  以下将注册上一节中的事件订阅者:

                  The following would register the event subscriber in the previous section:

                  # mymodule.services.yml
                  services:
                    my_module_event_subscriber:
                      class: 'Drupalmy_moduleEventSubscriberMyModuleEventSubscriber'
                      tags:
                        - { name: 'event_subscriber' }
                  

                  有关更多参考,请查看以下 URL:https://docs.drupalcommerce.org/commerce2/developer-guide/orders/react-to-workflow-transitions#reacting-to-transitions

                  For more reference review the following URL: https://docs.drupalcommerce.org/commerce2/developer-guide/orders/react-to-workflow-transitions#reacting-to-transitions

                  这篇关于如何为创建的每个新订单、产品等订阅 DrupalCommerce 2X 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <tfoot id='NMbSP'></tfoot>
                      <bdo id='NMbSP'></bdo><ul id='NMbSP'></ul>
                          <legend id='NMbSP'><style id='NMbSP'><dir id='NMbSP'><q id='NMbSP'></q></dir></style></legend>

                            <i id='NMbSP'><tr id='NMbSP'><dt id='NMbSP'><q id='NMbSP'><span id='NMbSP'><b id='NMbSP'><form id='NMbSP'><ins id='NMbSP'></ins><ul id='NMbSP'></ul><sub id='NMbSP'></sub></form><legend id='NMbSP'></legend><bdo id='NMbSP'><pre id='NMbSP'><center id='NMbSP'></center></pre></bdo></b><th id='NMbSP'></th></span></q></dt></tr></i><div id='NMbSP'><tfoot id='NMbSP'></tfoot><dl id='NMbSP'><fieldset id='NMbSP'></fieldset></dl></div>

                              <tbody id='NMbSP'></tbody>
                          1. <small id='NMbSP'></small><noframes id='NMbSP'>