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

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

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>

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

Assuming this is on a loading page....

you could do this

<?php
$x =CartSession::subtotal_cost();
if($x < 50)
{
//JS or CSS or HTML message
echo '<script type="text/javascript">';
echo 'alert("Spend more money");';
echo '</script>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.