skip to Main Content

I would like to open a popup on the Thank-You-Page (Order-received Endpoint) of a Woocommerce Store that I have created with Elementor. – Independent of payment method. (Paypal, Cash on Delivery, etc.)

The Popup Shortcode:
[elementor-template id="6485"]

I have now added the following code to the Function.php

add_action('woocommerce_thankyou_', 'nlmedia1_thankyou');

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

I also tried it for different payment gateways.

add_action('woocommerce_thankyou_COD', 'nlmedia1_thankyou');

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

Unfortunately, none of this has worked and I have not been able to find anything in this regard until now.

I would be glad about any help regarding the embedding of the trigger for an elementor popup. LG

2

Answers


  1. Chosen as BEST ANSWER

    Done.

    #1

    Downloaded this Plugin: Popup Trigger URL for Elementor Pro - Suki WordPress Theme

    = Shows Popup 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 = Enter the URL of your Popup. (Dashboard > Templates > Popups > Trigger URLs > Show URLs)

    • /Kasse = Checkout.

  2. I think, it’s the best solution for this

    // 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);
        },
      });
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search