I have a client that want to have an iframe based checkout ( and I can not tell her otherwise ). I have writen a wp – woocommerce plugin for that. My problem is that after presing the “place order” button it fires ajax call and returns my code to show iframe and json response and that is what triggers the error.

I call the execution of iframe with do_action in class after payment process. If I call it on hook like “woocommerce_checkout_order_processed” I get previus order data into iframe.

Code that makes iframe:

function makeIframe()
{

    $log = new logger("WP_order", "MakeIframe - fired", "order");
    $retrive_data = WC()->session->get( 'pw' ); 
    $log = new logger ("WP_log", $retrive_data, "Data from session for iframe");
    unset($log);

    if($retrive_data)
    {        
       $url = $retrive_data;
       ?>
        <script>
        if( typeof jQuery != 'undefined') 
        {
            var j = jQuery.noConflict();                

             j(document).ready(function($) {

                  var url = "<?php echo $url; ?>";
                  $("form.woocommerce-checkout").on('submit', function() {
                      if( $( "#payment_method_paywiser_gateway").is( ":checked" ))
                      {
                          $( "#customer_details,#order_review_heading,.woocommerce-checkout-review-order-table,#place_order" ).hide();
                          $( "div.payment_method_paywiser_gateway" ).html( "<iframe src='" + url + "' width='100%' height='400' scroling='no' sandbox='allow-same-origin allow-scripts allow-forms allow-top-navigation'></iframe>" );
                          $( "div.payment_method_paywiser_gateway" ).focus();
                      }
                  });

              });
         }
        </script>
        <?php
    }
    return 0;

}

The order of calls to function is:

  • 16.05.2017 – 22:25:24 | ORDER : Paywiser_gateway_init – fired
  • 16.05.2017 – 22:25:24 | ORDER : process_payment – fired
  • 16.05.2017 – 22:25:24 | ORDER : Initialise_Payment – fired
  • 16.05.2017 – 22:25:24 | ORDER : empty_cart – done
  • 16.05.2017 – 22:25:24 | ORDER : NoError – fired
  • 16.05.2017 – 22:25:24 | ORDER : MakeIframe – fired
  • 16.05.2017 – 22:25:55 | ORDER : Paywiser_gateway_init – fired

Pleas help I am new to WP and I am stuck on this any idea or ponit in the right direction is very helpfull..

p.s. sorry for bad english

Read more here: woocommerce checkout iframe json error


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: