Adding 2 Variables for Total

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi I need help for the code to add these 2 variables together for a total:

$'.$_SESSION["grandtotal"].'

'.$_POST['shipping'].'
 
Code:
$grandTotalToRuleThemAll = floatval(($_SESSION['grandtotal'] ?? 0)) + floatval(($_POST['shipping'] ?? 0));
This, however, just silently totals them without letting you know if they are missing; if missing they are defaulted to zero.
 
Sorry I should add that what I said above uses PHP 7.x. If you are on a version before 7.x you need to use the isset() function and test the global array values, and then if they are "set" or at least converted to a default value of zero or something, use a numeric conversion function like floatval() and then do the addition. Lot's of fun.
 
Hi thank you. But am having trouble to make it work.

Here's the pages. Just click the cart button bottom left after selecting USA then add to cart button: https://tvconnect.us/plans.php

I also want the shipping to write there below activation but it will only write in that column which I don't want at all.

Can you please check the code?

Code:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title class="cushycms" title="Page Title">TV Connect.US Order Check Out</title>
<link href="ezhoneybee.ico" rel="shortcut Icon">
<?php
		if(isset($_GET["id"]))
		{
			if($_SESSION["cnt"]>0)
			{
				$_SESSION["cntqty"] = $_SESSION["cntqty"] - $_SESSION["qty".$_GET["id"]];
				for ( $counter = $_GET["id"]; $counter < $_SESSION["cnt"]; $counter += 1) 
				{
					$incr = $counter+1;
					$_SESSION["title".$counter] = $_SESSION["title".$incr];
					$_SESSION["paymentmethod".$counter] = $_SESSION["paymentmethod".$incr];
					$_SESSION["price".$counter] = $_SESSION["price".$incr];
					$_SESSION["qty".$counter] = $_SESSION["qty".$incr];
					$_SESSION["total".$counter] = $_SESSION["total".$incr];
				}
				$_SESSION["cnt"] = $_SESSION["cnt"]-1;
				$_SESSION["grandtotal"] = $_SESSION["grandtotal"] - $_SESSION["total".$_GET["id"]];
				
			}
		
		}
		else if(isset($_GET["prod"]))
		{
			$_SESSION["cnt"] = $_SESSION["cnt"]+1;
			$_SESSION["title".$_SESSION["cnt"]] = $_GET["prod"];
			$_SESSION["paymentmethod".$_SESSION["cnt"]] = $_GET["pmode"];
			$_SESSION["price".$_SESSION["cnt"]] = $_GET["price"];
			$_SESSION["qty".$_SESSION["cnt"]] = $_GET["qty"];
			$_SESSION["total".$_SESSION["cnt"]] = $_GET["price"]*$_GET["qty"];
			$_SESSION["grandtotal"] = $_SESSION["grandtotal"] + $_SESSION["total".$_SESSION["cnt"]]; 
			
		}
	?>
		<? $_SESSION['discount'] = $discount; ?>
	<? $_SESSION['reducedTotal'] = $reducedTotal; ?>
	<style type="text/css">

/*Credits: Dynamic Drive CSS Library */
/*URL: http://www.dynamicdrive.com/style/ */

.thumbnail{
position: relative;
z-index: 0;
}

.thumbnail:hover{
background-color: transparent; border:none;
z-index: 50;
}

.thumbnail span{ /*CSS for enlarged image*/
position: absolute;
background-color: lightyellow;
padding: 6px;
left: -1000px;
border: 1px dashed gray;
visibility: hidden;
color: black;
text-decoration: none;
}

.thumbnail span { /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 0;
left: 60px; /*position where enlarged image should offset horizontally */

}

    </style>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">

</style>
<script language="JavaScript" type="text/javascript">
//will take any number of string element id's as arguments,
//followed by the display state desired must be last string fed in
//EXAMPLE: showhide('elementOneId', 'elementTwoId', 'elementThreeId', 'block');
function showhide() {
    var el,
        i = 0,
        a = arguments,
        len = a.length - 1,
        state = a[len];
    while (i < len) {
        el = document.getElementById(a[i++]);
        if (el !== null) {
            el.style.display = state;
        }}
    }
function addContent(divName, content) {
     document.getElementById(divName).innerHTML = content;
}
</script>


<link href="style.css" rel="stylesheet" type="text/css" /> 
 <style type="text/css">

 </style>
 <script type="text/javascript" src="cart.js"></script>

 <style type="text/css">

 </style>
 </head>
<body><noscript><div align="center">Javascript must be enabled for this site to function properly. <br>
                  Please <a href="http://www.google.com/support/bin/answer.py?answer=23852"  target=".blank">enable it</a> and reload your browser (F5).</div></noscript>

<table border="0" align="center" cellpadding="0" cellspacing="0" style="border-radius:12px">
  
  <tr>
    <td height="3" background="images/base.png"></td>
  </tr>
  <tr>
    <td  bgcolor="#050505" class="cellbg"><br />
      <table border="0" align="center" cellpadding="0" cellspacing="0" style="border-radius:12px">
        <tr>
          <td style="padding:10px;"><form name="frmCart" id="frmCart" action="cart.php" method="post" onsubmit="window.opener.location.reload();">
              <table border="0" cellspacing="0" cellpadding="7" align="center" bgcolor="#050505" style="width:100%; max-width:700px">
                <tr>
                  <td height="35" colspan="6" bgcolor="#333333" class="style1"><div align="center"><img src="images/logo.png" width="171" height="125" />     <br />
                      <br />
                       <a href="plans.php" style="color:#FFFF00">Click Here</a> to continue shopping. 
<br />
      Do NOT hit the Back button as this can cause an error. <br />
            <br />
                        </div>
                    <div align="center">  <strong class="bluebold"> <br />
                        <span class="pink">Your Order Cart Details</span></strong><br />
                    </div>
                  </div></td>
                </tr>
                <tr bgcolor="#B2B2B2">
                  <td  bgcolor="#CF6505" class="white" style="border-right:#F2BC86 1px solid"><span class="style52">Product</span></td>
                  <td bgcolor="#CF6505" class="white" style="border-right:#F2BC86 1px solid"><span class="style52">Price</span></td>
                  <td  bgcolor="#CF6505" class="white" style="border-right:#F2BC86 1px solid"><span class="style52">Qty</span></td>
                  <td  bgcolor="#CF6505" class="white" style="border-right:#F2BC86 1px solid"><strong>Shipping</strong></td>
                  <td  bgcolor="#CF6505" class="white" style="border-right:#F2BC86 1px solid"><span class="style52">Total</span></td>
                  <td  bgcolor="#CF6505" class="white"><span class="style52">Remove</span></td>
                </tr>
             <?php
	for ( $counter = 1; $counter <= $_SESSION["cnt"]; $counter += 1) 
	{	
		if(($counter%2)==0)	
		{
		?>
                <tr>
                  <?php
		}
		?>
                  <td bgcolor="#121212" class="lglr"><?php echo($_SESSION["title".$counter]); ?></td>
                  <td bgcolor="#121212"  class="lglr">$<?php echo($_SESSION["price".$counter]); ?></td>
                  <td bgcolor="#121212" class="lglr"><?php echo($_SESSION["qty".$counter]); ?></td>
                  <td bgcolor="#121212" class="lglr"><?php echo($_SESSION["paymentmethod".$counter]); ?></td>
                  <td bgcolor="#121212" class="lglr">$<?php echo($_SESSION["total".$counter]); ?></td>
                  <td bgcolor="#121212" class="lglr2"><span class="bubble" style="width:20px; overflow:hidden"> <a href="#" alt="SORRY Google Chrome users, this feature does not work in Chrome. If you are using Chrome please close the browser and re-open ezhoneybee.com to empty your cart."> <span class="bubble2">SORRY Google Chrome users, this feature does not work in Chrome, if you are using Chrome to empty your cart please simply close the browser and re-open tvconnect.us.</span>
                        <input name="button" type="button" class="red" onclick="remove('<?php echo($counter); ?>')" value="X"/>
                  </a> </td>
                </tr>
                <?php
	}
	?>
                <tr>
                  <td colspan="6" align="right" valign="middle" background="images/base.png" style="height:2px; padding:0px" ></td>
                </tr>
                <tr>
                  <td colspan="3" align="right" valign="middle" bgcolor="#1F1F1F" class="tableborder"><span class="style51">Sub Total:</span></td>
                  <td colspan="3" valign="middle" bgcolor="#1F1F1F" class="tableborder" style="padding-left:6px"> $<?php echo($_SESSION["grandtotal"]); ?></td>
                </tr>
                
                <tr>
                  <td colspan="3" align="right" valign="middle" bgcolor="#373737" class="tableborder">Activation:</td>
                  <td colspan="3" valign="middle" bgcolor="#373737" class="tableborder">$25</td>
                </tr>
                <tr>
                  <td colspan="3" align="right" valign="middle" bgcolor="#373737" class="tableborder"><span class="style51">Shipping:</span></td>
                  <td colspan="3" valign="middle" bgcolor="#373737" class="tableborder">$<?php echo($_SESSION["paymentmethod"]); ?></td>
                </tr>
                
                <tr>
                  <td colspan="3" align="right" valign="middle" bgcolor="#1F1F1F" class="tableborder"><span class="style51">Grand Total: </span></td>
                  <td colspan="3" valign="middle" bgcolor="#1F1F1F" class="tableborder" style="text-align:left; padding-left:6px">
                  $<strong><?php $grandTotalToRuleThemAll = floatval(($_SESSION['grandtotal'] ?? 0)) + floatval(($_POST['paymentmethod'] ?? 0)) + '25';?></strong></td>
                </tr>
              </table>
          </form>

And the page that sends the cart order:

Code:
<?php session_start(); ?><!DOCTYPE html>
<html lang="en">
<head>
<title>Connect TV Plans</title>
	<meta name="description" content="Connect TV Internet TV box Programming Plans" />
<meta name="keywords" content="iptv, tv box, internet tv box, tv connect box" />
  <link rel="stylesheet" href="bootstrap.css">

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="style.css" type="text/css" />
  <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); }>
</script>
	<meta name="viewport" content="width=device-width, initial-scale=1">


<script src="jquery.min.js"></script>

	<style>

	/*
	Max width before this PARTICULAR table gets nasty
	This query will take effect for any screen smaller than 760px
	and also iPads specifically.
	*/
	@media
	only screen and (max-width: 760px),
	(min-device-width: 768px) and (max-device-width: 1024px)  {

		/* Force table to not be like tables anymore */
		table, thead, tbody, th, td, tr {
			display: block;
		}

		/* Hide table headers (but not display: none;, for accessibility) */
		thead tr {
			position: absolute;
			top: -9999px;
			left: -9999px;
		}

		tr { border: none }

		td {
			/* Behave  like a "row" */
			border: none;
			position: relative;
		}

		td:before {
			/* Now like a table header */
			position: absolute;
			/* Top/left values mimic padding */
			top: 6px;
			left: 6px;
			width: 100%;
			padding-right: 10px;
			white-space: nowrap;
		}


	/* Smartphones (portrait and landscape) ----------- */
	@media only screen
	and (min-device-width : 320px)
	and (max-device-width : 480px) {
		body {
			padding: 0;
			margin: 0;
			width: 320px; }
		}

	/* iPads (portrait and landscape) ----------- */
	@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
		body {
			width: 495px;
		}
	}

	.style20 {color: #66FF00}
    .style20 {color: #66FFFF}
    .style20 {color: #000000}
    .style20 {color: #000000}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    .style20 {font-weight: bold}
    </style>
	
	<script type="text/javascript" src="animatedcollapse.js">

/***********************************************
* Animated Collapsible DIV v2.4- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

<?php include_once("prices.php"); ?>
<?php

if(!isset($_SESSION["cnt"]))
{
$_SESSION["cnt"]=0;
$_SESSION["cntqty"]=0;
$_SESSION["grandtotal"]=0;
}

if(isset($_GET["prod"]))
{
$_SESSION["cnt"] = $_SESSION["cnt"]+1;
$_SESSION["title".$_SESSION["cnt"]] = $_GET["prod"];
$_SESSION["paymentmethod".$_SESSION["cnt"]] = $_GET["pmode"];
$_SESSION["price".$_SESSION["cnt"]] = $_GET["price"];
$_SESSION["qty".$_SESSION["cnt"]] = $_GET["qty"];
$_SESSION["cntqty"] = $_SESSION["cntqty"] + $_GET["qty"];
$_SESSION["total".$_SESSION["cnt"]] = $_GET["price"]*$_GET["qty"];
$_SESSION["grandtotal"] = $_SESSION["grandtotal"] + $_SESSION["total".$_SESSION["cnt"]];

?>
<script language="javascript">
val = (document.location.href).split("?");
document.location.href=val[0];
</script>
<?php
}
?>

<script language="javascript">

function showcart()
{
document.location.href='cart.php?prod='+title+'&paymentmethod='+paymentmethod+'&price='+price+'&qty='+q;
}

function showtotal()

{

window.location.href="plans.php?act=showtotal"
}
function addtocart(title,paymentmethod,price,qty)
{
	q = document.getElementById(""+qty+"").value;
	if(q=="")
	{
	q='1';
	}
	
	if(document.getElementById(""+paymentmethod+"").value == "")
	{
		alert("Please select a payment method.");
		document.getElementById(""+paymentmethod+"").focus();
		return false;
	}
	
	pmode = document.getElementById(""+paymentmethod+"").value;
	
	document.location.href=document.location.href+'?prod='+title+'&paymentmethod='+paymentmethod+'&price='+price+'&qty='+q+'&pmode='+pmode;
}




</script>

</script>
<link href="tvconnect.ico" rel="shortcut Icon"></head><body>
<noscript><div align="center">Javascript must be enabled for this site to function properly. <br>
                  Please <a href="http://www.google.com/support/bin/answer.py?answer=23852"  target="_blank">enable it</a> and reload your browser (F5).</div></noscript>

<div class="gray">
<span class="menu"> <img src="images/icon.png" style="vertical-align:middle; float:right; padding:24px;" alt="Menu"/></span><a href="index.html"><img src="images/logo.png" width="134" height="24" border="0" style="float:left; padding: 26px 0px 12px 20px"></a><span class="navg" >
<ul class="res">
<li class="dropdown">
<button class="dropbtn"><a href="countries.html" style="text-decoration:none; color:#FFFFFF">Channels</a></button>
<div class="dropdown-content">
<a href="adult_live_channels.html">Adult</a>
<a href="african_live_channels.html">African</a>
<a href="asian_live_channels.html">Asian</a>
<a href="english_live_channels.html">English</a>
<a href="middle_east_live_channels.html">Middle East</a>
<a href="portuguese_live_channels.html">Portuguese</a><a href="spanish_live_channels.html">Spanish</a>

<a href="sports_live_channels.html">Sports</a>
</div></li>


<li class="dropdown2">
<button class="dropbtn2"><a href="#">Accessories</a></button> 
<div class="dropdown2-content">
<a href="hd_local_antena.html">HD Local Antena</a>
<a href="hdmi_cable.html">HDMI Cable</a>
<a href="keyboard.html">Keyboard</a>
<a href="power_adapter.html">Power Adapter</a>
<a href="remote.html">Remote</a>
</div></li>


<li class="dropdown3"><button class="dropbtn3"><a href="internet.html" style="text-decoration:none; color:#FFFFFF">Devices</a></button>
  <div class="dropdown3-content">
<a href="tv_connect_basic.html">Connect TV Basic</a>
</div></li>


<li class="dropdown4"><a href="how_to_order.html"><button class="dropbtn4">How to Order</button></a>

</li>

<li class="dropdown4"><a href="plans.html"><button class="dropbtn4">Plans</button></a>
</li>
</li>
<li class="dropdown4"><a href="contact.html"><button class="dropbtn4" style="margin-left:-4px">Support</button></a>
<div class="dropdown4-content" style="margin-top:-8px; margin-left:4px">
<a href="index.html#channel_details">Channel Lists</a>
<a href="contact.html">Contact</a>

</div></li>
</ul> 
  <script>
							   $( "span.menu" ).click(function() {
								 $( "ul.res" ).slideToggle( 300, function() {
								 // Animation complete.
								  });
								 });							</script></span></div></div><div style="background-image:url(images/gray-bg.png)"><div style="padding:15px 30px 30px 30px"><h1><span class="style16">Plans</span></h1>
							 
							  <h3>Packages and Plans for Connect IP TV for International Packages</h3>
							  <hr>
                             <strong class="pink">$<?php echo $Lifetime_Subscription ?></strong></span><strong> </strong>-- Lifetime Subscription with 2 Years Hardware and Software warranty <br>
- No more monthly or yearly Subscription<br>
<table border="0" cellpadding="4" cellspacing="0">
              <tr>
                <td><select name="paymentmethod1" class="width" id="paymentmethod1">
                  <option selected="selected" value="" >Select</option>
                  <option value="19.95">USA: $19.95 3-5 Business Days</option>
                  <option value="MasterCard">MasterCard</option>
                  <option value="Discover">Discover</option>
                  <option value="American Express">American Express</option> </select>  
				  
		
				  
<td>
<input name="Lifetime_Subscription" type="text" class="w" id="Lifetime_Subscription" value="1" maxlength="2"/></td>
<td><input type="image" class="i" onclick="addtocart('Lifetime Subscription IP TV','paymentmethod1','<?php echo $Lifetime_Subscription; ?>','Lifetime_Subscription')" value="Add To Cart" src="images/addtocart.png" />


</td>



              </tr>
          </table>
 
No, I'm sorry. I can't bring myself to help you on this further. I told you how to add two global array variables even with uncertainty about what they present. Adding two variables. Super sorry, I can't take your hand and take you all the way to the dance.
 
I was thinking this would work but not:

<?php
$sum = gmp_add("25", "echo($_SESSION['paymentmethod'", "echo($_SESSION['grandtotal'");
echo gmp_strval($sum) . "\n";
?>
 
Function gmp_add only takes two arguments. And even the arguments you had, you were missing brackets for the session variables.
This would be correct:
Code:
$sum = 25 + $_SESSION['paymentmethod'] + $_SESSION['grandtotal'];
echo strval($sum) . "\n";
 
Thank you Rob. It is working except somehow the shipping price variable is not passing through to be included in the math: $_SESSION['paymentmethod']

Any idea why?
 
I hope you got it working by now, but if you want to just copy and paste exactly where and how the variable is set--that would help us help you and make it less painful to give answers. Haystacks of code are no fun to go through. Thanks.
 
Here's the relevant code from the cart page:

Code:
<--- Head tag ---- >

<?php
		if(isset($_GET["id"]))
		{
			if($_SESSION["cnt"]>0)
			{
				$_SESSION["cntqty"] = $_SESSION["cntqty"] - $_SESSION["qty".$_GET["id"]];
				for ( $counter = $_GET["id"]; $counter < $_SESSION["cnt"]; $counter += 1) 
				{
					$incr = $counter+1;
					$_SESSION["title".$counter] = $_SESSION["title".$incr];
					$_SESSION["paymentmethod".$counter] = $_SESSION["paymentmethod".$incr];
					$_SESSION["price".$counter] = $_SESSION["price".$incr];
					$_SESSION["qty".$counter] = $_SESSION["qty".$incr];
					$_SESSION["total".$counter] = $_SESSION["total".$incr];
				}
				$_SESSION["cnt"] = $_SESSION["cnt"]-1;
				$_SESSION["grandtotal"] = $_SESSION["grandtotal"] - $_SESSION["total".$_GET["id"]];
				
			}
		
		}
		else if(isset($_GET["prod"]))
		{
			$_SESSION["cnt"] = $_SESSION["cnt"]+1;
			$_SESSION["title".$_SESSION["cnt"]] = $_GET["prod"];
			$_SESSION["paymentmethod".$_SESSION["cnt"]] = $_GET["pmode"];
			$_SESSION["price".$_SESSION["cnt"]] = $_GET["price"];
			$_SESSION["qty".$_SESSION["cnt"]] = $_GET["qty"];
			$_SESSION["total".$_SESSION["cnt"]] = $_GET["price"]*$_GET["qty"];
			$_SESSION["grandtotal"] = $_SESSION["grandtotal"] + $_SESSION["total".$_SESSION["cnt"]]; 
			
		} ?>
		
	<--- End of Header Tag ---->
	
             <?php
	for ( $counter = 1; $counter <= $_SESSION["cnt"]; $counter += 1) 
	{	
		if(($counter%2)==0)	
		{
		?>
                <tr>
                  <?php
		}
		?>
                  <td bgcolor="#121212"><?php echo($_SESSION["title".$counter]); ?></td>
                  <td align="center" bgcolor="#121212">$<?php echo($_SESSION["price".$counter]); ?></td>
                  <td bgcolor="#121212" align="center"><?php echo($_SESSION["qty".$counter]); ?></td>
                  <td align="center" bgcolor="#121212" class="lglr">$<?php echo($_SESSION["total".$counter]); ?></td>
                  <td bgcolor="#121212" align="center">$<?php echo($_SESSION["paymentmethod".$counter]); ?></td>
                  <td align="center" bgcolor="#121212"><span class="bubble" style="width:20px; overflow:hidden"> <a href="#" alt="If your cart won't empty this item please simply close the browser and re-open tvconnect.us."> <span class="bubble2">If your cart item won't empty this item please simply close the browser and re-open tvconnect.us.</span>
                        <input name="button" type="button" class="red" onclick="remove('<?php echo($counter); ?>')" value="X"/>
                  </a> </td>
                </tr>              
                <?php
	}
	?>
 <tr>
                  <td colspan="4" align="right" valign="middle" bgcolor="#1F1F1F" class="tableborder"><span class="style51">Sub Total:</span></td>
                  <td valign="middle" bgcolor="#1F1F1F" class="tableborder" style="padding-left:6px">$<?php echo($_SESSION["grandtotal"]); ?></td>
                  <td valign="middle" bgcolor="#1F1F1F" class="tableborder" style="padding-left:6px"> </td>
                </tr>  
                <tr>
                  <td colspan="4" align="right" valign="middle" bgcolor="#373737" class="tableborder">Activation:</td>
                  <td valign="middle" bgcolor="#373737" class="tableborder">$25</td>
                  <td valign="middle" bgcolor="#373737" class="tableborder"> </td>
                </tr>
                <tr>
                  <td colspan="4" align="right" valign="middle" bgcolor="#1F1F1F" class="tableborder"><span class="style51">Grand Total: </span>
                    </strong></td>
                  <td valign="middle" bgcolor="#1F1F1F" class="tableborder" style="text-align:left;">$<? $sum = 25 + $_SESSION['grandtotal'] + $_SESSION['paymentmethod'];
echo strval($sum) . "\n"; ?></td>
                  <td valign="middle" bgcolor="#1F1F1F" class="tableborder" style="text-align:left; padding-left:6px"> </td>
                </tr>
              </table>
          </form>

It seems when I move this code:
<?php
}
?>

below that variable "paymentmethod" the shipping rate writes but when I don't it doesn't. But then when I put it below it puts the shipping cost repeated for each item which I do NOT want.
 
Oh my goodness. This is frustrating for me. Is this even your php page you are dealing with? Sorry but if you don't use or have studied php and don't intend to, but if you want someone to solve this for you, please hire a contractor.
There is this session variable in the code:
$_SESSION["paymentmethod".$counter] //there is another variation similar to this in there as well.
The session variable you are trying to add is this:
$_SESSION["paymentmethod"] //<--you don't even have this in your code because of the concatenations you have done.

For $_SESSION["paymentmethod".$counter], the effective session variable could be this: "paymentmethod3"
 
Yes it is my client's site and I did hire a coder for the cart before. But lost touch with him and just need to make some changes to it. Figured myself and others could learn some things from this forum while figuring this out. I could just put grand total figure + shipping but it would look kinda lame.
 
Figured myself and others could learn some things from this forum while figuring this out.

I would recommend to start learning PHP by yourself first - just moving brackets around is not really programming. If you are a little more familar and know what you actually want (i don't get it), you may be able to reduce the problem to about 10 lines of code - people here are unlikely to make this business logic for you. var_dump() will help you on the way having a look at each variable that might me necessary.
 
It's ok just gonna go ahead with using the Grand total "+ Shipping". Thanks Rob at least I got the total + $25 worked out.
 
Hello guys. Another quick question.. Can you please check what boo boo I may have made on this PHP email output show/ hide:

Code:
  </tr>
		      ';
			 if($_POST['txtstate']="Outside of USA")
{
$message = $message.='<tr>
		    <td align="right" style="font-size:13px">Region:</td>
            <td style="font-size:13px">'.$_POST['region'].'</td></tr>';}
else if(!$_POST['txtstate']="Outside of USA")
{
$message = $message.'<tr>
            <td align="right" style="font-size:13px">State:</td>
            <td style="font-size:13px">'.$_POST['txtstate'].'</td>
          </tr>';}

  $message = $message.'

It is working for region but NOT state for some reason. Basically if someone selects outside US it shows that field and that field name and field would send in the email. Otherwise it'd be State. Region is working but not state.
 
Code:
if($_POST['txtstate']="Outside of USA")
...

else if(!$_POST['txtstate']="Outside of USA")

Should that be equals? you have used assign; don't know if that's the only problem.
 
hyper said:
Code:
if($_POST['txtstate']="Outside of USA")
...

else if(!$_POST['txtstate']="Outside of USA")

Should that be equals? you have used assign; don't know if that's the only problem.

Yes trying to make it so that if the value selected is "Outside of USA" the Region field will pass through the email form to email. Otherwise the State will.
 
You're missing the point:
Code:
<?php
$a = 1;
$b = 2;
if ($a = $b){
  echo 'Ooops'; # $a does not equal $b
}
echo ' $a now is assigned with:', $a;

$a = 5;
$b = 537;
if ($a = $b){
    echo '<br>Ooops'; # $a does not equal $b
}
echo ' $a now is assigned with:', $a;

$a=1;
$b=2;
if ($a == $b){
  echo '<br>Ooops'; # $a does not equal $b
}
$a = 5;
$b = 537;
if ($a == $b){
    echo '<br>Ooops'; # $a does not equal $b
}
 
Am NOT here to know I am wrong I already know that! Am here to find the SOLUTION!
 
Back
Top