AbanteCart Community

Shopping Cart Operations => Support => Topic started by: Billy0298 on November 11, 2013, 03:57:10 PM

Title: Need to create a POPUP
Post by: Billy0298 on November 11, 2013, 03:57:10 PM
Hello,

I Need to create a pop up window when customers access my store. I would like to put a warning message Like disclaimer before the enter the site. How can i make this possible do ineed to create block and then enter code in index. php t call for that pop up/block on enter to my site? if so can some one please help me with the code and instructions.

Your help is very much appreciated
Title: Re: Need to create a POPUP
Post by: Billy0298 on November 11, 2013, 07:52:16 PM
any one please help
Title: Re: Need to create a POPUP
Post by: abantecart on November 12, 2013, 09:33:36 AM
Simple approach:
Create HTML block with JavaScript to show warning and assign this block to main page layout

If you need separate page, this is a harder approach.
You will need to create new extension/controller and add predespatch controller before loading index page.

Similar approach implemented in 'login to view products' extension.   
Title: Re: Need to create a POPUP
Post by: Billy0298 on November 12, 2013, 12:38:32 PM
sounds difficult is there an easy way may be to put this code in index.php

<script type="text/javascript">

function popup(){
  cuteLittleWindow = window.open("page.html", "littleWindow", "location=no,width=320,height=200");
}

</script>
Title: Re: Need to create a POPUP
Post by: Billy0298 on November 12, 2013, 12:50:22 PM
:( that didn't work can, you please walk me through as to what i need to do to  create a pop up html window on the start of my store. so for example customer enters my store and a pop up window shows up with a disclaimer customer click on the link in that window i have the disclaimer written and links in htm to either enter the store or not. I have to make sure that the store is opened in the background and a small html window as pop up at the same time
Title: Re: Need to create a POPUP
Post by: Billy0298 on November 13, 2013, 01:49:28 PM
PLEASE CAN SOMEBODY HELP ME i CANT USE THE STORE WITH OUT THE DISCLAIMER MY CREDIT CARD PROCESSOR REQUIRES THIS POP UP WINDOW - DON'T WANT TO GO TO PRESTASHOP OR OSCOMMERCE THESE ARE THE ONLY SHOPPING CARTS THAT HAVE THIS OPTION AVAILABLE,

I LOVE THIS SHOPPING CART THERE IS GOT TO BE A SOLUTION HERE PLEASE SUPPORT ME

PAUL
Title: Re: Need to create a POPUP
Post by: JHammond53 on November 13, 2013, 02:46:09 PM
Paul,

Here are 2 different options to achieve what you want

Browse to the following file public_html  ->  storefront  ->  view  ->  default_html5  ->  template  ->  pages  ->  index  ->  home.tpl

Modify home.tpl with the following code.



OPTION 1 -> Popup alert (just a string of text) (won't be blocked by pop up blockers)

Blue is existing
red is new code
purple is where you put your message


<section class="container">
   <div class="welcome_msg">
      <?php echo $welcome; ?>
   </div>
</section>

<script>
  $(document).ready(function(){
    alert('MESSAGE HERE');
  });
</script>



OPTION 2 -> Popup window (opens url) (will be blocked by pop up blockers)

Blue is existing
red is new code
purple is where you put URL


<section class="container">
   <div class="welcome_msg">
      <?php echo $welcome; ?>
   </div>
</section>

<script>
  $(document).ready(function(){
    testwindow = window.open("URL HERE", "mywindow", "location=1,status=1,scrollbars=1,width=100,height=100");
    testwindow.moveTo(0, 0);
  });
</script>
Title: Re: Need to create a POPUP
Post by: Billy0298 on November 13, 2013, 04:05:45 PM
THANK YOU SOOOOO MUCH THAT WORKED  :) :) :) :)
Title: Re: Need to create a POPUP
Post by: abantecart on November 14, 2013, 08:24:45 AM
That works, but careful on upgrades if this file is part of update script.
Title: Re: Need to create a POPUP
Post by: JHammond53 on November 14, 2013, 09:17:21 AM
Quote from: abantecart on November 14, 2013, 08:24:45 AM
That works, but careful on upgrades if this file is part of update script.

I have also achieved it by creating a block and applying to home layout page per your first comment and it works the same as the second option I posted. Its just a more permanent effect if an upgrade were to happen like you said. His response to your first post was that it seemed too difficult (IMO easier than the options I gave).

Paul, if you want to have a more permanent option do the following:
   1.   Log into the admin side of the cart, browse to Design -> Blocks
   2.   Click on the "Insert" icon to the right of the page
   3.   Give your popup a name and title
   4.   Add the following code to the custom block content (make sure you click "Source" to enter the code side of the editor)
         <script>
         $(document).ready(function(){
            testwindow = window.open("URL HERE", "mywindow", "location=1,status=1,scrollbars=1,width=500,height=500");
            testwindow.moveTo(0, 0);
         });
         </script>

   5.   Click Save, then browse to Design -> Layouts
   6.   On the left, click Home Page
   7.   At the top, find a slot that has "--- None ---" and click the drop down. Find "html_block:: YOUR POPUP NAME" 
   8.   Click Save.
   9.   Try it out
Title: Re: Need to create a POPUP
Post by: abolabo on November 14, 2013, 07:03:25 PM
also do not forget attribute type for script tag for html-validation pass.
i mean <script type="text/javascript">