Jump to content

[SOLVED] If statment with Popup, newbie needs help...


fubarur

Recommended Posts

Thanks in advance for any help...

 

I have a cart page the shows a subtotal

CartSession::subtotal_cost()

 

I want to make it so if the subtotal is below $50 it opens a Popup to send the user a message?

popup page is

/popup/50.php

 

else no popup

 

Any ideas?

 

Thanks

Link to comment
Share on other sites

You'd need to use JavaScript. Whatever the total is displayed in (ie. input / div / etc) give it an ID. In the body 'onload' event call a JavaScript function to retrieve the value of the content in that ID. Parse the data to give you the actual total and if that's below 50, display the pop up.

 

You'll find plenty of help on each step through Google!

 

Adam

Link to comment
Share on other sites

Not really a "php" question, but I will help anyhow.

 

<script type="text/javascript">
<!--
   function mySubmit() {
        if (document.getElementyById('subTotal').value < 50) {
             window.open();
        }
        document.test.submit(); // submit the form.
   }
// -->
</script>

<form name="test" method="post" action="yourpage.php">
  <input type="subTotal" value="" />
  <input type="submit" name="submit" onClick="mySubmit();" />
</form>

Link to comment
Share on other sites

Thanks premiso,

 

Not what I'm looking for, my issue is more of a PHP not a form to allow someone to enter a value.

 

So if someone adds a item to their cart that costs $20 a popup window pops and and says something like get a better shipping rate by adding more than $50

 

If they had more than $50 in the cart nothing would happen.

 

This is what displays the subtotal on the page

CartSession::subtotal_cost()

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.