How to call Iframe from an Iframe using jQuery in Wordpress Plugin?












1















I have an app (WordPress Plugin) called from an iFrame in Wordpress Woocommerce store. All works fine.
The app generates products and adds them to the cart and allowing the visitor to get to the cart and pay. Using jQuery Modals.



Currently I am using redirect to provide the visitor access to the cart.
BUT, I would like the visitor to stay (come back) after the checkout.
The idea is that all visitor interaction is handled with Modals
Such that the visitor can continue using the app and generate more products.



Is that possible?
Is there a better option?



My current code is as follows:



function contact_woo_shop(orderfilename, urlAtts, counts, table){
var pid=0
jQuery.post(
ts_woo.ajax_url,
{'action': 'do_ts_woo','order': orderfilename,
'board': urlAtts,'table': table},
function(response) {
if(response.success){
pid = response.data;
console.log("do_ts_woo. SUCCESS response="+response.data);
/* I WISH TO CANCEL THIS REDIRECT in favor of another MOdal with Iframe below*/
window.location.replace("https://orig-site.co.il/cart/?add-to-cart="+response.data);

} else {
console.log("do_ts_woo. FAILURE response="+response.data);
}
}
).done(function(response) {
console.log("DONE do_ts_woo. DONE response="+response.data);

/* I wish to have the Modal & Iframe here */
jQuery("#dialog").dialog({
autoOpen: false,
show: "fade",
hide: "fade",
modal: true,
open: function (ev, ui) {
jQuery('#myIframe').attr('src',"https://orig-site.co.il/cart/?add-to-cart="+pid);
},
height: 'auto',
width: 'auto',
resizable: true,
title: 'Tilesim'
});

jQuery("#opener").click(function () {
jQuery("#dialog").dialog("open");
return false;
})

})
.fail(function(msg) {
alert( "error msg="+msg );
})
.always(function() {
// alert( "finished" );
});


}










share|improve this question



























    1















    I have an app (WordPress Plugin) called from an iFrame in Wordpress Woocommerce store. All works fine.
    The app generates products and adds them to the cart and allowing the visitor to get to the cart and pay. Using jQuery Modals.



    Currently I am using redirect to provide the visitor access to the cart.
    BUT, I would like the visitor to stay (come back) after the checkout.
    The idea is that all visitor interaction is handled with Modals
    Such that the visitor can continue using the app and generate more products.



    Is that possible?
    Is there a better option?



    My current code is as follows:



    function contact_woo_shop(orderfilename, urlAtts, counts, table){
    var pid=0
    jQuery.post(
    ts_woo.ajax_url,
    {'action': 'do_ts_woo','order': orderfilename,
    'board': urlAtts,'table': table},
    function(response) {
    if(response.success){
    pid = response.data;
    console.log("do_ts_woo. SUCCESS response="+response.data);
    /* I WISH TO CANCEL THIS REDIRECT in favor of another MOdal with Iframe below*/
    window.location.replace("https://orig-site.co.il/cart/?add-to-cart="+response.data);

    } else {
    console.log("do_ts_woo. FAILURE response="+response.data);
    }
    }
    ).done(function(response) {
    console.log("DONE do_ts_woo. DONE response="+response.data);

    /* I wish to have the Modal & Iframe here */
    jQuery("#dialog").dialog({
    autoOpen: false,
    show: "fade",
    hide: "fade",
    modal: true,
    open: function (ev, ui) {
    jQuery('#myIframe').attr('src',"https://orig-site.co.il/cart/?add-to-cart="+pid);
    },
    height: 'auto',
    width: 'auto',
    resizable: true,
    title: 'Tilesim'
    });

    jQuery("#opener").click(function () {
    jQuery("#dialog").dialog("open");
    return false;
    })

    })
    .fail(function(msg) {
    alert( "error msg="+msg );
    })
    .always(function() {
    // alert( "finished" );
    });


    }










    share|improve this question

























      1












      1








      1








      I have an app (WordPress Plugin) called from an iFrame in Wordpress Woocommerce store. All works fine.
      The app generates products and adds them to the cart and allowing the visitor to get to the cart and pay. Using jQuery Modals.



      Currently I am using redirect to provide the visitor access to the cart.
      BUT, I would like the visitor to stay (come back) after the checkout.
      The idea is that all visitor interaction is handled with Modals
      Such that the visitor can continue using the app and generate more products.



      Is that possible?
      Is there a better option?



      My current code is as follows:



      function contact_woo_shop(orderfilename, urlAtts, counts, table){
      var pid=0
      jQuery.post(
      ts_woo.ajax_url,
      {'action': 'do_ts_woo','order': orderfilename,
      'board': urlAtts,'table': table},
      function(response) {
      if(response.success){
      pid = response.data;
      console.log("do_ts_woo. SUCCESS response="+response.data);
      /* I WISH TO CANCEL THIS REDIRECT in favor of another MOdal with Iframe below*/
      window.location.replace("https://orig-site.co.il/cart/?add-to-cart="+response.data);

      } else {
      console.log("do_ts_woo. FAILURE response="+response.data);
      }
      }
      ).done(function(response) {
      console.log("DONE do_ts_woo. DONE response="+response.data);

      /* I wish to have the Modal & Iframe here */
      jQuery("#dialog").dialog({
      autoOpen: false,
      show: "fade",
      hide: "fade",
      modal: true,
      open: function (ev, ui) {
      jQuery('#myIframe').attr('src',"https://orig-site.co.il/cart/?add-to-cart="+pid);
      },
      height: 'auto',
      width: 'auto',
      resizable: true,
      title: 'Tilesim'
      });

      jQuery("#opener").click(function () {
      jQuery("#dialog").dialog("open");
      return false;
      })

      })
      .fail(function(msg) {
      alert( "error msg="+msg );
      })
      .always(function() {
      // alert( "finished" );
      });


      }










      share|improve this question














      I have an app (WordPress Plugin) called from an iFrame in Wordpress Woocommerce store. All works fine.
      The app generates products and adds them to the cart and allowing the visitor to get to the cart and pay. Using jQuery Modals.



      Currently I am using redirect to provide the visitor access to the cart.
      BUT, I would like the visitor to stay (come back) after the checkout.
      The idea is that all visitor interaction is handled with Modals
      Such that the visitor can continue using the app and generate more products.



      Is that possible?
      Is there a better option?



      My current code is as follows:



      function contact_woo_shop(orderfilename, urlAtts, counts, table){
      var pid=0
      jQuery.post(
      ts_woo.ajax_url,
      {'action': 'do_ts_woo','order': orderfilename,
      'board': urlAtts,'table': table},
      function(response) {
      if(response.success){
      pid = response.data;
      console.log("do_ts_woo. SUCCESS response="+response.data);
      /* I WISH TO CANCEL THIS REDIRECT in favor of another MOdal with Iframe below*/
      window.location.replace("https://orig-site.co.il/cart/?add-to-cart="+response.data);

      } else {
      console.log("do_ts_woo. FAILURE response="+response.data);
      }
      }
      ).done(function(response) {
      console.log("DONE do_ts_woo. DONE response="+response.data);

      /* I wish to have the Modal & Iframe here */
      jQuery("#dialog").dialog({
      autoOpen: false,
      show: "fade",
      hide: "fade",
      modal: true,
      open: function (ev, ui) {
      jQuery('#myIframe').attr('src',"https://orig-site.co.il/cart/?add-to-cart="+pid);
      },
      height: 'auto',
      width: 'auto',
      resizable: true,
      title: 'Tilesim'
      });

      jQuery("#opener").click(function () {
      jQuery("#dialog").dialog("open");
      return false;
      })

      })
      .fail(function(msg) {
      alert( "error msg="+msg );
      })
      .always(function() {
      // alert( "finished" );
      });


      }







      jquery wordpress iframe woocommerce






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 0:07









      MulliMulli

      359214




      359214
























          2 Answers
          2






          active

          oldest

          votes


















          0















          1. You could look at a plugin that is already accomplishing this and see how they are accomplishing this: [https://wordpress.org/plugins/woo-awesome-checkout-popup-form/][1]


          2. Or you could accomplish this by automatically re-directing the user on the order accomplished page after a certain amount of time. For example, wait 1 second and then re-direct back to a store page.







          share|improve this answer
























          • thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

            – Mulli
            Jan 3 at 1:30



















          0














          I managed to open an iFrame from within an iFrame using the nice & clean solution for jquery iframe dialog As it seems, technically, there is no limit to this sequence.
          @NickC Thanks for your help!



          Final note: Untill now I was trying to avoid iframe at all cost.
          This is the first example where application (SAAS) is running clients' code on behalf of the client. This use case is different from running (dumb) iFrame(some.html).






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014791%2fhow-to-call-iframe-from-an-iframe-using-jquery-in-wordpress-plugin%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0















            1. You could look at a plugin that is already accomplishing this and see how they are accomplishing this: [https://wordpress.org/plugins/woo-awesome-checkout-popup-form/][1]


            2. Or you could accomplish this by automatically re-directing the user on the order accomplished page after a certain amount of time. For example, wait 1 second and then re-direct back to a store page.







            share|improve this answer
























            • thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

              – Mulli
              Jan 3 at 1:30
















            0















            1. You could look at a plugin that is already accomplishing this and see how they are accomplishing this: [https://wordpress.org/plugins/woo-awesome-checkout-popup-form/][1]


            2. Or you could accomplish this by automatically re-directing the user on the order accomplished page after a certain amount of time. For example, wait 1 second and then re-direct back to a store page.







            share|improve this answer
























            • thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

              – Mulli
              Jan 3 at 1:30














            0












            0








            0








            1. You could look at a plugin that is already accomplishing this and see how they are accomplishing this: [https://wordpress.org/plugins/woo-awesome-checkout-popup-form/][1]


            2. Or you could accomplish this by automatically re-directing the user on the order accomplished page after a certain amount of time. For example, wait 1 second and then re-direct back to a store page.







            share|improve this answer














            1. You could look at a plugin that is already accomplishing this and see how they are accomplishing this: [https://wordpress.org/plugins/woo-awesome-checkout-popup-form/][1]


            2. Or you could accomplish this by automatically re-directing the user on the order accomplished page after a certain amount of time. For example, wait 1 second and then re-direct back to a store page.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 3 at 0:47









            NickCNickC

            345




            345













            • thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

              – Mulli
              Jan 3 at 1:30



















            • thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

              – Mulli
              Jan 3 at 1:30

















            thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

            – Mulli
            Jan 3 at 1:30





            thanks. I prefer the first option. I shall look at it. Did you tryit? Does it handles all the links the Woocomrece comes with? I can get the checkout into jQuery modal - not as iFarme, so any link will take you out of the Modal window. I need solution for this case I wonder if the plugin on your first option support that?

            – Mulli
            Jan 3 at 1:30













            0














            I managed to open an iFrame from within an iFrame using the nice & clean solution for jquery iframe dialog As it seems, technically, there is no limit to this sequence.
            @NickC Thanks for your help!



            Final note: Untill now I was trying to avoid iframe at all cost.
            This is the first example where application (SAAS) is running clients' code on behalf of the client. This use case is different from running (dumb) iFrame(some.html).






            share|improve this answer




























              0














              I managed to open an iFrame from within an iFrame using the nice & clean solution for jquery iframe dialog As it seems, technically, there is no limit to this sequence.
              @NickC Thanks for your help!



              Final note: Untill now I was trying to avoid iframe at all cost.
              This is the first example where application (SAAS) is running clients' code on behalf of the client. This use case is different from running (dumb) iFrame(some.html).






              share|improve this answer


























                0












                0








                0







                I managed to open an iFrame from within an iFrame using the nice & clean solution for jquery iframe dialog As it seems, technically, there is no limit to this sequence.
                @NickC Thanks for your help!



                Final note: Untill now I was trying to avoid iframe at all cost.
                This is the first example where application (SAAS) is running clients' code on behalf of the client. This use case is different from running (dumb) iFrame(some.html).






                share|improve this answer













                I managed to open an iFrame from within an iFrame using the nice & clean solution for jquery iframe dialog As it seems, technically, there is no limit to this sequence.
                @NickC Thanks for your help!



                Final note: Untill now I was trying to avoid iframe at all cost.
                This is the first example where application (SAAS) is running clients' code on behalf of the client. This use case is different from running (dumb) iFrame(some.html).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 3 at 7:09









                MulliMulli

                359214




                359214






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014791%2fhow-to-call-iframe-from-an-iframe-using-jquery-in-wordpress-plugin%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                    How to fix TextFormField cause rebuild widget in Flutter