Open/Toggle 一个 Elementor 弹出窗口 - 感谢页面

Open/Toggle a Elementor Popup - Thank You Page

我想在我使用 Elementor 创建的 Woocommerce 商店的感谢页面(订单接收端点)上打开一个弹出窗口。 - 独立于付款方式。 (贝宝、货到付款等)

弹出简码: [元素模板 id="6485"]

我现在已将以下代码添加到 Function.php

add_action('woocommerce_thankyou_', 'nlmedia1_thankyou');

function nlmedia1_thankyou() {
  echo do_shortcode('[elementor-template id="6485"]');
}

我也尝试了不同的支付网关。

add_action('woocommerce_thankyou_COD', 'nlmedia1_thankyou');

function nlmedia1_thankyou() {
  echo do_shortcode('[elementor-template id="6485"]');
}

不幸的是,none 已经奏效,直到现在我还没有找到这方面的任何东西。

如果您能提供有关为 elementor 弹出窗口嵌入触发器的任何帮助,我将很高兴。 LG

完成。

#1

下载此插件: Elementor Pro 的弹出触发器 URL - Suki WordPress 主题

= 显示弹出窗口 URL。

#2

Function.php:

add_action( 'template_redirect', 'woocommerce_redirect_after_checkout' );
function woocommerce_redirect_after_checkout() {
    global $wp;
    POPUP_URL_HERE
    if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) && empty($_GET['popup']) ) {

        $redirect_url = home_url('/kasse/order-received/'.$wp->query_vars['order-received'].'/?key='.$_GET['key'].'&popup=openPOPUP_URL_HERE');
        wp_redirect($redirect_url );
        exit;
    }

*POPUP_URL_HERE = 输入弹出窗口的 URL。 (仪表板 > 模板 > 弹出窗口 > 触发器 URLs > 显示 URLs)

  • /Kasse = 结帐。

我认为这是最好的解决方案

// Open Popup like Thanks you Page
jQuery(function($) {
  $.ajax = new Proxy($.ajax, {
    apply(target, prop, [options]) {
      const { url, success } = options;

      if (url === WC_CHECKOUT_URL && success) {
        const $form = $('.checkout woocommerce-checkout');

        options.success = function(result) {
          const isSuccess = 'success' === result.result && $form.triggerHandler( 'checkout_place_order_success' ) !== false;

          if (isSuccess) {
            const orderId = result.redirect.match(/\/(\d+)\//)[1];

            $('body').trigger('update_checkout');
            $form.unblock();

            // need call for detachUnloadEventsOnSubmit
            success({ result: 'fake' });

            // Open Popup
            $.magnificPopup.open({
              items: {
                src: '#modal-success-order',
              },
              mainClass: 'mfp-zoom-in',
              type: 'inline',
              closeOnBgClick: true,
              showCloseBtn:false,
              callbacks: {
                open: function() {
                  const $content = $(this.content[0]);
                  $content.find('#order_id').text(orderId);
                },
                close: function(){
                  window.location = '/';
                },
              },
            });

            return;
          }

          success(result);
        }
      }
      return target(options);
    },
  });
});