I have this php code which determines if the user has already voted or not.
$row_content['Vote_Who'] contains a list of all users who have previously voted, and is formatted like "User_1 User_2 User_3"
$_SESSION['Username'] is the current username of the user who is signed in. Yes this works, as I have called it elsewhere on the page.
<?php if(strpos($row_content['Vote_Who'], $_SESSION['Username']) !== false){?>
<input type="button" value="Thanks for voting!">
<?php }
else{ ?>
<input type="submit" value="<?php echo $row_content['Votes']?>: Vote Up! ▲" width="75px">
<input type="hidden" name="MM_update" value="vote">
<?php } ?>
But when I see the result in the web browser, both the buttons are displayed at once.
How can I fix that?
Thanks in advance.
UPDATE: Image that proves both buttons display at the same time
UPDATE:
Full code section:
<?php
if ($totalRows_content > 0){
do {?>
<table width="100%">
<tr>
<td width="75px" height="75px" align="right">
<img src="<?php echo $row_content['User_Pic']?>" width="50px" height="50px">
<br />
<?php echo $row_content['Author']?>
</td>
<td colspan="2">
<h2>
<?php echo $row_content['Title']?>
</h2>
</td>
</tr>
<tr>
<td>
</td>
<td style="vertical-align:top">
<h3>
<?php echo $row_content['Content']?>
<br />
<br />
</h3>
</td>
<td width="150px" style="vertical-align:top">
<img src="<?php echo $row_content['Picture']?>" style="max-width:150px; max-height:100px">
<h3>
<?php echo $row_content['Published']?>
</h3>
<br />
<?php if(isset ($_SESSION['Username'])){?>
<form method="POST" action="<?php echo $editFormAction; ?>" name="vote">
<input type="text" hidden="hidden" name="ID" value="<?php echo $row_content['ID']?>">
<input type="text" hidden="hidden" name="votes_up" value="<?php echo ($row_content['Votes'] + 1)?>">
<?php if(strpos($row_content['Vote_Who'], $_SESSION['Username']) !== false){?>
<input type="button" value="Thanks for voting!">
<?php }
else{ ?>
<input type="submit" value="<?php echo $row_content['Votes']?>: Vote Up! ▲" width="75px">
<input type="hidden" name="MM_update" value="vote">
<?php } ?>
</form>
<a href="comments.php?ID=<?php echo $row_content['ID']?>">
<input type="button" value="See Comments">
</a>
<?php }
else{?>
<?php echo $row_content['Votes']?> Votes - You must be signed in to vote
<?php }?>
</td>
</tr>
</table>
<?php }while ($row_content = mysql_fetch_assoc($content));}
else{?>
there is nothing
<?php }
?>
The problem was where I'd used the operator of
!==
when what I should have used was
!=
Example:
strpos($row_content['Vote_Who'], $_SESSION['Username']) != false
Thanks to everyone who offered assistance with this issue.
Related
I want to make a cell's data different in each row of the same column, according to the value of the $row['epilogh']:
<tr>
<td> <?php echo $row['id']; ?> </td>
<td> <?php echo $row['epilogh']; ?> </td>
<td> <?php echo $row['um_username']; ?> </td>
<td> <?php echo $row['myrole'];?> </td>
<td> <?php echo $row['request_date'];?> </td>
<!-- i want the following 2 td to be one and work in the above different cases -->
<td style="max-width: 250px; text-align: center;">
<?php echo ''.$row['id'].'';?>
<form action="../make-solemn-declaration-pdf/?id=<?php echo $id; ?>" method="POST" target="_blank">
<button type="submit" name="btn-pdf">Make a PDF</button>
</form>
</td>
<td style="max-width: 250px">
<form method="POST" enctype="multipart/form-data" action="../upload-file/?id=<?php echo $row['id']; ?>">
<input type="file" name="fileToUpload" id="fileToUpload" accept=".pdf" required />
<br><hr>
<input type="submit" name="submit" value="Upload" />
<? echo "$pdf";?>
</form>
</td>
<td> Delete </td>
</tr>
So let's say that if $row['epilogh'] is 'A' I want a form so a file could be uploaded. On the other hand when $row['epilogh'] is 'B' I want to have a link there for another page. How can I do this?
if i understand you correctly, you can do this:
just use one td:
<td style="max-width: 250px;<?php if($row['epilogh'] == 'A') echo 'text-align: center;' ?> ">
<?php
if($row['epilogh'] == 'A'){
echo "your upload form"
}
else{
echo "your link to another page"
}
?>
</td>
I want to send an Id by the form in foreach loop but when I click on each button it sends me the first form.
It means when I click on the second button it sends me the value of the first form the value of input hidden is right but the first value every time sent.
<?PHP
if ($transactions) {
foreach ($transactions as $transaction) {
?>
<td class="text-left">
<?php echo $transaction['invoice_id']; ?>
</td>
<td class="text-left">
<?php echo $transaction['invoice_type']; ?>
</td>
<td class="text-left">
<?php echo $transaction['ref_id']; ?>
</td>
<td class="text-left">
<?php echo $transaction['gateway']; ?>
</td>
<td class="text-left">
<?php echo $transaction['payment_date']; ?>
</td>
<td class="text-right">
<?php
if($transaction['payment_status'] == 'not paid') {
?>
<form
method="POST"
action="<?php echo $gate_url; ?>"
>
<input type="hidden" name="invoiceId" value="<?php echo $transaction['invoice_id']; ?>">
<button class="btn btn-md btn-primary" type="submit" >
<?php echo $pay; ?>
</button>
</form>
<?php
}
?>
</td>
<?php
}
You have an array of the values, so this:
<input type="hidden" name="invoiceId" value="<?php echo $transaction['invoice_id']; ?>">
replace with:
<input type="hidden" name="invoiceId[]" value="<?php echo $transaction['invoice_id']; ?>">
am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is the one i have tried
if ((['yes'])) {
// Yes
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center" >
<tr>
<td align="center" style="padding:0px"><span id="sprytextfield1">
<input name="cot" type="text" id="cot" size="10" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield2">
<input name="tax" type="text" id="tax" size="10" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield3">
<input name="imf" type="text" id="imf" size="10" />
<span class="textfieldRequiredMsg"></span></span><br /> <span id="error">
wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px"><input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
} else {
// No
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center" >
<tr>
<td align="center" style="padding:0px"><span id="sprytextfield1">
<input name="cot" type="hidden" id="cot" value="<?php echo $_POST['cot'];?>" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield2">
<input name="tax" type="hidden" id="tax" value="<?php echo $_POST['tax'];?>" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield3">
<input name="imf" type="hidden" id="imf" value="<?php echo $_POST['imf'];?>" />
<span class="textfieldRequiredMsg"></span></span><br /> <span id="error">
wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px"><input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
}
You mean something like this?
.error {
display: none
}
<?php
$yes = $_GET["yes"] == "yes"; ?>
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center">
<tr>
<td align="center" style="padding:0px">
<span id="sprytextfield1"><input name="cot" type="<?php echo $yes ? "text" : "hidden"; ?>" id="cot" size="10" /></span>
<span class="textfieldRequiredMsg"></span>
<span id="sprytextfield2"><input name="tax" type="<?php echo $yes ? "text" : "hidden"; ?>" id="tax" size="10" /></span>
<span class="textfieldRequiredMsg"></span>
<span id="sprytextfield3"><input name="imf" type="<?php echo $yes ? "text" : "hidden"; ?>" id="imf" size="10" /></span>
<span class="textfieldRequiredMsg"></span><br />
<span id="error">wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px">
<input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
</table>
</div>
Ιf I understand your answered correct, than you want to display a specific HTML part if a given variable in php is 'yes'. Otherwise you want to show a different part of the HTML.
Then you can use this syntax:
<?php if ($val == 'YES'): ?>
<!-- Yes part -->
<?php else: ?>
<!-- No part -->
<?php endif; ?>
Hello guys thank for your help i thin i get it
<?php if ($yes = $_GET["yes"] == "yes"): ?>
html code to run if condition is empty
<?php else: ?>
html code to run if condition is yes
<?php endif ?>
if the == "yes" is yes it show yes condition but if empty it show the empty part
One of my html forms is not POSTing data, the submit button respect the action attribute and redirect the page as spected BUT $_POST[] is empty for some reason. could sonebody help me find the issue here?
I already tried using html method POST and even ajax to process the form and submit the data, and theres no case. $_POST[] will allways stay empty (this is the only page that does that, I hava an exact copy of the form but without the GET method and it works fine...
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="nocep-rules.css" rel="stylesheet" type="text/css">
<?php
session_start();
$link = mysqli_connect("localhost", "xxxx", "xxxx", "xxxxxx");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
<?php
if(!isset($_SESSION['logged'])){
header("location: /bubale/login.php");
}
?>
</head>
<body>
<div class="header">
<img class="logo" src="/bubale/img/logo1.png" alt="" />
<img class="foro-title" src="/bubale/img/loja_title.png" alt="" />
</div>
<div class="menu">
<nav class="site-nav">
<ul>
<li>HOME</li>
<li>LOJA</li>
<li>FORUM</li>
<li>CHECKOUT</li>
<li>SAIR</li>
</ul>
</nav>
</div>
<div class="info">
<table width="100%">
<tr>
<td width="20%">
<h2 class="text">USUÁRIO:</h2>
<?php echo $_SESSION['logged']; ?>
<h2 class="text2">PONTOS:</h2>
<?php
$sql5= "Select points from profile where user = '".$_SESSION['logged']."'";
$result5 = mysqli_query($link, $sql5);
if(mysqli_num_rows($result5)==1){
while($row5 = mysqli_fetch_assoc($result5)) {
echo $row5['points'];
}
}
?>
</td>
<td width="30%">
<?php
$sql2= "select * from bolsinhas where user = '".$_SESSION['logged']."' && rev_id = '0'";
$result2 = mysqli_query($link, $sql2);
$count = mysqli_num_rows($result2);
?>
<h2 class="text">BOLSINHAS:</h2>
<?php echo $count; ?>
<h2 class="text2">PRODUTOS:</h2>
<?php
$sql3= "select * from fullsize where user = '".$_SESSION['logged']."' && rev_id = '0'";
$result3 = mysqli_query($link, $sql3);
$count3 = mysqli_num_rows($result3);
echo $count3;
?>
</td>
<td>
<?php
if(!empty($_SESSION["shopping_cart"])) {
$cart_count = count(array_keys($_SESSION["shopping_cart"]));
}else{$cart_count = "0";}
?>
<img id="icon1" src="img/basket.png" title="Compras" ><span id = "count_wrapper"><a id="count">
<?php echo $cart_count; ?></a></span>
<img class="icon" src="img/sale.png" title="Promoção" alt="" >
<img class="icon" src="img/points.png" title="Fidelidade Buba'le" alt="" >
</td>
</table>
</div>
<h1 class="frete">FRETE:</h1>
<div class="wrapper_frete">
<?php
$rua1 = $_GET['1'];
$numero1 = $_GET['2'];
$apt1 = $_GET['3'];
$cep1 = $_GET['4'];
?>
<table id="forma_frete" width="100%">
<tbody>
<th>DADOS PESSOAIS</th>
<th>OOPS!!!</th>
<tr>
<form id="modform" method="POST" action="nocep2.php">
<td width="40%" class="td2">
<table id="nested" width="100%">
<tr>
<td id="td-nested-left" width="30%">
<label class="label-form" for="user">USUÁRIO:</label><br>
<label class="label-form" for="rua">RUA:</label><br>
<label class="label-form" for="numero">NÚMERO:</label><br>
<label class="label-form" for="apt">APT:</label><br>
<label class="label-form" for="cep">CEP:</label><br>
</td>
<td id="td-nested-right">
<input name="user" form="buttons" type="text" maxlenght="20" disabled value="<?php echo $_SESSION['logged']; ?>" /><br>
<input name="rua" form="buttons" type="text" value="<?php echo $rua1; ?>" /><br>
<input name="numero" form="buttons" type="text" value="<?php echo $numero1;?>" /><br>
<input name="apt" form="buttons" type="text" value="<?php echo $apt1; ?>" /><br>
<input name="cep" form="buttons" type="text" value="<?php echo $cep1;?>" />
</td>
</tr>
</table>
<input type="submit" class="refresh" value="ATUALIZAR">
</td>
</form>
<td id="td_mensage">
<h3 id="mensage">-irrelevant text-. </h3>
</td>
</tr>
<tr>
<td id="td_ob" colspan="2">
<h3 id="comentario">OBSERVAÇAÕ:</h3>
<textarea form="buttons" name="observacion" id="text_ob" placeholder="Deixe aqui sua observaçaõ..."></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<h1 class="frete">SUA COMPRA:</h1>
<?php
if(isset($_SESSION["shopping_cart"])){
$total_price = 0;
?>
<?php } ?>
<table class="table">
<tbody>
<tr>
<th></th>
<th>PRODUTO</th>
<th>QUANTIDADE</th>
<th>VALOR UNITARIO</th>
<th>VALOR TOTAL</th>
</tr>
<?php
foreach ($_SESSION["shopping_cart"] as $product){
?>
<tr>
<td id="imgtd"><img src='<?php echo $product["image"]; ?>' width="90" height="80" /></td>
<td><?php echo $product["name"]; ?><br />
<form method='post' action=''>
<input type='hidden' name='code' value="<?php echo $product["code"]; ?>" />
</form></td>
<td><form method='post' action=''>
<input type='hidden' name='code2' value="<?php echo $product["code"]; ?>" />
<?php echo $product["quantity"];?>
</form></td>
<td><?php echo "R$".$product["price"]; ?></td>
<td><?php echo "R$".$product["price"]*$product["quantity"]; ?></td>
</tr>
<?php
$total_price += ($product["price"]*$product["quantity"]);
}
?>
<tr>
<td class="td_tot" colspan="5" align="right"><strong id="total">TOTAL: <?php echo "R$".$total_price; ?></strong></td>
</tr>
</tbody>
</table>
<form method="post" action="contact-venta.php" id="buttons">
<?php
?>
<input type="hidden" name="compras" value="<?php echo print_r($_SESSION["shopping_cart"], TRUE); ?>"/>
<input type="hidden" name="total" value="<?php echo $total_price; ?>">
<input type="submit" id="submit" value="ENVIAR">
</form>
<?php mysqli_close($link); ?>
</body>
</html>
the issue is with the first submit (the one with the value ACTUALIZAR), the form will go to nocep2.php BUT $_POST[] will remain empty .... I posted the entire page just in case there is an issue I'm not seeing....
Your HTML is rather confused.
Firstly, <form> is not a valid element in <tr>. The browser is rendering them outside the table, and separate from your <input>. Move your form tags inside the <td>, or move them outside the <table>
Eg
<table>
<tr>
<td>
<form method="POST">
<input type="text" name="inputName">
<input type="submit">
</form>
</td>
</tr>
</table>
Or, if you need to spread your form over several cells:
<form method="POST">
<table>
<tr>
<td>
<input type="text" name="inputName1">
</td>
<td>
<input type="text" name="inputName2">
</td>
<td>
<input type="submit">
</td>
</tr>
</table>
</form>
Secondly, you're creating a number of <input> elements of type "hidden", each with their own form tags, so they are each part of a different form. Reorder your code so that the hidden elements appear within the same <form> as the rest of your <input>
I'm about to ask a tough question, and I apologize in advance for the fact that I'm a n00b at javascript!
Basically I am looking to integrate MailChimp list signup into the WP E-Commerce plugin. If I understand correctly, this could be accomplished with Javascript where I send the data to two separate locations.
I found some pretty good info on this process here: http://www.codeproject.com/KB/scripting/multiact.aspx and here POST to a form that POSTS to another form
First off the Requirements from the MailChimp End, pretty simple:
<form action="http://mylist.us1.mailchimp.xxx/xxx/" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
<fieldset>
<legend>join our mailing list</legend>
<div class="indicate-required">* indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <strong class="note-required">*</strong>
</label>
<input value="" name="EMAIL" class="required email" id="mce-EMAIL" type="text">
</div>
<div id="mce-responses">
<div class="response" id="mce-error-response" style="display: none;"></div>
<div class="response" id="mce-success-response" style="display: none;"></div>
</div>
<div><input value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" type="submit"></div>
</fieldset>
Close
</form>
Now for the tougher part... the WP E-Commerce source code. This is a huge plugin (I think 73 files) but the relevant code is all found in "shopping_cart_page.php"... here is the source for that:
Does anyone know exactly what the final code would look like if I were to integrate the MailChimp code above into the WP E-commerce code below? I'm looking to have a checkbox that gives WP E-commerce store customers the option of opting-in to the MailChimp mailing list so that when they hit "Buy Now" their data is submitted to both the local (WordPress) database as well as the external (MailChimp) database.
<?php
global $wpsc_cart, $wpdb, $wpsc_checkout, $wpsc_gateway, $wpsc_coupons;
$wpsc_checkout = new wpsc_checkout();
$wpsc_gateway = new wpsc_gateways();
$wpsc_coupons = new wpsc_coupons($_SESSION['coupon_numbers']);
//echo "<pre>".print_r($wpsc_cart,true)."</pre>";
// echo "<pre>".print_r($wpsc_cart,true)."</pre>";
if(wpsc_cart_item_count() > 0) :
?>
<p><?php echo TXT_WPSC_REVIEW_YOUR_ORDER; ?></p>
<table class="productcart">
<tr class="firstrow">
<td class='firstcol'></td>
<td><?php echo TXT_WPSC_PRODUCT; ?>:</td>
<td><?php echo TXT_WPSC_QUANTITY; ?>:</td>
<td><?php echo TXT_WPSC_PRICE; ?>:</td>
<td></td>
</tr>
<?php while (wpsc_have_cart_items()) : wpsc_the_cart_item(); ?>
<?php //this displays the confirm your order html ?>
<tr class="product_row">
<td class="firstcol"><img src='<?php echo wpsc_cart_item_image(48,48); ?>' alt='<?php echo wpsc_cart_item_name(); ?>' title='<?php echo wpsc_cart_item_name(); ?>' /></td>
<td class="firstcol">
<a href='<?php echo wpsc_cart_item_url();?>'><?php
echo wpsc_cart_item_name();
if(wpsc_cart_item_custom_message()) {
?> (<?php echo wpsc_cart_item_custom_message() ?>)<?php
}
?></a>
</td>
<td>
<form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
<input type="text" name="quantity" size="2" value="<?php echo wpsc_cart_item_quantity(); ?>" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<input type="submit" value="<?php echo TXT_WPSC_APPLY; ?>" name="submit" />
</form>
</td>
<td><span class="pricedisplay"><?php echo wpsc_cart_item_price(); ?></span></td>
<td>
<form action="<?php echo get_option('shopping_cart_url'); ?>" method="post" class="adjustform">
<input type="hidden" name="quantity" value="0" />
<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>" />
<input type="hidden" name="wpsc_update_quantity" value="true" />
<button class='remove_button' type="submit"><span><?php echo TXT_WPSC_REMOVE; ?></span></button>
</form>
</td>
</tr>
<?php endwhile; ?>
<?php //this HTML displays coupons if there are any active coupons to use ?>
<?php if(wpsc_uses_coupons()): ?>
<?php if(wpsc_coupons_error()): ?>
<tr><td><?php echo TXT_WPSC_COUPONSINVALID; ?></td></tr>
<?php endif; ?>
<tr>
<td colspan="2"><?php _e('Enter your coupon number'); ?> :</td>
<td colspan="3" align='left'>
<form method='post' action="<?php echo get_option('shopping_cart_url'); ?>">
<input type='text' name='coupon_num' id='coupon_num' value='<?php echo $wpsc_cart->coupons_name; ?>' />
<input type='submit' value='<?php echo TXT_WPSC_APPLY ?>' />
</form>
</td>
</tr>
<?php endif; ?>
</table>
<?php //this HTML dispalys the calculate your order HTML ?>
<?php if(isset($_SESSION['nocamsg']) && isset($_GET['noca']) && $_GET['noca'] == 'confirm'): ?>
<p class='validation-error'><?php echo $_SESSION['nocamsg']; ?></p>
<?php endif; ?>
<?php if($_SESSION['categoryAndShippingCountryConflict'] != '') : ?>
<p class='validation-error'><?php echo $_SESSION['categoryAndShippingCountryConflict']; ?></p>
<?php
endif;
if($_SESSION['WpscGatewayErrorMessage'] != '') :
?>
<p class='validation-error'><?php echo $_SESSION['WpscGatewayErrorMessage']; ?></p>
<?php
endif;
?>
<?php do_action('wpsc_before_shipping_of_shopping_cart'); ?>
<div id='wpsc_shopping_cart_container'>
<?php if(wpsc_uses_shipping()) : ?>
<h2><?php echo TXT_WPSC_SHIPPING_COUNTRY; ?></h2>
<table class="productcart">
<tr>
<td colspan='5'>
<?php echo TXT_WPSC_SHIPPING_DETAIL; ?>
</td>
</tr>
<?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
<?php if (($_SESSION['wpsc_zipcode'] == '') || ($_SESSION['wpsc_zipcode'] == 'Your Zipcode')) : // No valid shipping quotes ?>
<?php if ($_SESSION['wpsc_update_location'] == true) :?>
<tr>
<td colspan='5' class='shipping_error' >
<?php echo TXT_WPSC_NO_ZIPCODE; ?>
</td>
</tr>
<?php endif; ?>
<?php else: ?>
<tr>
<td colspan='5' class='shipping_error' >
<?php echo TXT_WPSC_NO_SHIPPING_QUOTES; ?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<tr>
<td colspan='5'>
<form name='change_country' id='change_country' action='' method='post'>
<?php echo wpsc_shipping_country_list();?>
<input type='hidden' name='wpsc_update_location' value='true' />
<input type='submit' name='wpsc_submit_zipcode' value='Calculate' />
</form>
</td>
</tr>
<?php if (wpsc_have_morethanone_shipping_quote()) :?>
<?php while (wpsc_have_shipping_methods()) : wpsc_the_shipping_method(); ?>
<?php if (!wpsc_have_shipping_quotes()) { continue; } // Don't display shipping method if it doesn't have at least one quote ?>
<tr><td class='shipping_header' colspan='5'><?php echo wpsc_shipping_method_name().TXT_WPSC_CHOOSE_A_SHIPPING_RATE; ?> </td></tr>
<?php while (wpsc_have_shipping_quotes()) : wpsc_the_shipping_quote(); ?>
<tr>
<td colspan='3'>
<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_name(); ?></label>
</td>
<td style='text-align:center;'>
<label for='<?php echo wpsc_shipping_quote_html_id(); ?>'><?php echo wpsc_shipping_quote_value(); ?></label>
</td>
<td style='text-align:center;'>
<?php if(wpsc_have_morethanone_shipping_methods_and_quotes()): ?>
<input type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' <?php echo wpsc_shipping_quote_selected_state(); ?> onclick='switchmethod("<?php echo wpsc_shipping_quote_name(); ?>", "<?php echo wpsc_shipping_method_internal_name(); ?>")' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
<?php else: ?>
<input <?php echo wpsc_shipping_quote_selected_state(); ?> disabled='disabled' type='radio' id='<?php echo wpsc_shipping_quote_html_id(); ?>' value='<?php echo wpsc_shipping_quote_value(true); ?>' name='shipping_method' />
<?php wpsc_update_shipping_single_method(); ?>
<?php endif; ?>
</td>
</tr>
<?php endwhile; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wpsc_update_shipping_multiple_methods(); ?>
<?php if (!wpsc_have_shipping_quote()) : // No valid shipping quotes ?>
</table>
</div>
<?php return; ?>
<?php endif; ?>
</table>
<?php endif; ?>
<table class="productcart">
<tr class="total_price total_tax">
<td colspan="3">
<?php echo TXT_WPSC_TAX; ?>
</td>
<td colspan="2">
<span id="checkout_tax" class="pricedisplay checkout-tax"><?php echo wpsc_cart_tax(); ?></span>
</td>
</tr>
<?php if(wpsc_uses_shipping()) : ?>
<tr class="total_price total_shipping">
<td colspan="3">
<?php echo TXT_WPSC_TOTALSHIPPING; ?>
</td>
<td colspan="2">
<span id="checkout_shipping" class="pricedisplay checkout-shipping"><?php echo wpsc_cart_shipping(); ?></span>
</td>
</tr>
<?php endif; ?>
<?php if(wpsc_uses_coupons() && (wpsc_coupon_amount(false) > 0)): ?>
<tr class="total_price">
<td colspan="3">
<?php echo TXT_WPSC_COUPONS; ?>
</td>
<td colspan="2">
<span id="coupons_amount" class="pricedisplay"><?php echo wpsc_coupon_amount(); ?></span>
</td>
</tr>
<?php endif ?>
<tr class='total_price'>
<td colspan='3'>
<?php echo TXT_WPSC_TOTALPRICE; ?>
</td>
<td colspan='2'>
<span id='checkout_total' class="pricedisplay checkout-total"><?php echo wpsc_cart_total(); ?></span>
</td>
</tr>
</table>
<?php do_action('wpsc_before_form_of_shopping_cart'); ?>
<form class='wpsc_checkout_forms' action='' method='post' enctype="multipart/form-data">
<?php
/**
* Both the registration forms and the checkout details forms must be in the same form element as they are submitted together, you cannot have two form elements submit together without the use of JavaScript.
*/
?>
<?php if(!is_user_logged_in() && get_option('users_can_register') && get_option('require_register')) : ?>
<h2><?php _e('Not yet a member?');?></h2>
<p><?php _e('In order to buy from us, you\'ll need an account. Joining is free and easy. All you need is a username, password and valid email address.');?></p>
<?php if(count($_SESSION['wpsc_checkout_user_error_messages']) > 0) : ?>
<div class="login_error">
<?php
foreach($_SESSION['wpsc_checkout_user_error_messages'] as $user_error ) {
echo $user_error."<br />\n";
}
$_SESSION['wpsc_checkout_user_error_messages'] = array();
?>
</div>
<?php endif; ?>
<fieldset class='wpsc_registration_form'>
<label><?php _e('Username'); ?>:</label><input type="text" name="log" id="log" value="" size="20"/>
<label><?php _e('Password'); ?>:</label><input type="password" name="pwd" id="pwd" value="" size="20" />
<label><?php _e('E-mail'); ?>:</label><input type="text" name="user_email" id="user_email" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
</fieldset>
<?php endif; ?>
<h2><?php echo TXT_WPSC_CONTACTDETAILS; ?></h2>
<?php/* echo TXT_WPSC_CREDITCARDHANDY; <br /> */?>
<?php echo TXT_WPSC_ASTERISK; ?>
<?php
if(count($_SESSION['wpsc_checkout_misc_error_messages']) > 0) {
echo "<div class='login_error'>\n\r";
foreach((array)$_SESSION['wpsc_checkout_misc_error_messages'] as $user_error ) {
echo $user_error."<br />\n";
}
echo "</div>\n\r";
}
$_SESSION['wpsc_checkout_misc_error_messages'] =array();
?>
<table class='wpsc_checkout_table'>
<?php while (wpsc_have_checkout_items()) : wpsc_the_checkout_item(); ?>
<?php if(wpsc_is_shipping_details()) : ?>
<tr>
<td colspan ='2'>
<br />
<input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' />
<label for='shippingSameBilling'>Shipping Address same as Billing Address?</label>
</td>
</tr>
<?php endif; ?>
<?php if(wpsc_checkout_form_is_header() == true) : ?>
<tr <?php echo wpsc_the_checkout_item_error_class();?>>
<td <?php if(wpsc_is_shipping_details()) echo "class='wpsc_shipping_forms'"; ?> colspan='2'>
<h4>
<?php echo wpsc_checkout_form_name();?>
</h4>
</td>
</tr>
<?php else: ?>
<?php if((!wpsc_uses_shipping()) && $wpsc_checkout->checkout_item->unique_name == 'shippingstate'): ?>
<?php else : ?>
<tr <?php echo wpsc_the_checkout_item_error_class();?>>
<td>
<label for='<?php echo wpsc_checkout_form_element_id(); ?>'>
<?php echo wpsc_checkout_form_name();?>:
</label>
</td>
<td>
<?php echo wpsc_checkout_form_field();?>
<?php if(wpsc_the_checkout_item_error() != ''): ?>
<p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php if (get_option('display_find_us') == '1') : ?>
<tr>
<td>How did you find us:</td>
<td>
<select name='how_find_us'>
<option value='Word of Mouth'>Word of mouth</option>
<option value='Advertisement'>Advertising</option>
<option value='Internet'>Internet</option>
<option value='Customer'>Existing Customer</option>
</select>
</td>
</tr>
<?php endif; ?>
<tr>
<td colspan='2'>
<?php //this HTML displays activated payment gateways?>
<?php if(wpsc_gateway_count() > 1): // if we have more than one gateway enabled, offer the user a choice ?>
<h3><?php echo TXT_WPSC_SELECTGATEWAY;?></h3>
<?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
<div class="custom_gateway">
<?php if(wpsc_gateway_internal_name() == 'noca'){ ?>
<label><input type="radio" id='noca_gateway' value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
<?php }else{ ?>
<label><input type="radio" value="<?php echo wpsc_gateway_internal_name();?>" <?php echo wpsc_gateway_is_checked(); ?> name="custom_gateway" class="custom_gateway"/><?php echo wpsc_gateway_name();?></label>
<?php } ?>
<?php if(wpsc_gateway_form_fields()): ?>
<table class='<?php echo wpsc_gateway_form_field_style();?>'>
<?php echo wpsc_gateway_form_fields();?>
</table>
<?php endif; ?>
</div>
<?php endwhile; ?>
<?php else: // otherwise, there is no choice, stick in a hidden form ?>
<?php while (wpsc_have_gateways()) : wpsc_the_gateway(); ?>
<input name='custom_gateway' value='<?php echo wpsc_gateway_internal_name();?>' type='hidden' />
<?php if(wpsc_gateway_form_fields()): ?>
<table>
<?php echo wpsc_gateway_form_fields();?>
</table>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</td>
</tr>
<?php if(get_option('terms_and_conditions') != '') : ?>
<tr>
<td colspan='2'>
<input type='checkbox' value='yes' name='agree' /> <?php echo TXT_WPSC_TERMS1;?><a class='thickbox' target='_blank' href='<?php
echo get_option('siteurl')."?termsandconds=true&width=360&height=400'"; ?>' class='termsandconds'><?php echo TXT_WPSC_TERMS2;?></a>
</td>
</tr>
<?php endif; ?>
<tr>
<td colspan='2'>
<?php if(get_option('terms_and_conditions') == '') : ?>
<input type='hidden' value='yes' name='agree' />
<?php endif; ?>
<?php //exit('<pre>'.print_r($wpsc_gateway->wpsc_gateways[0]['name'], true).'</pre>');
if(count($wpsc_gateway->wpsc_gateways) == 1 && $wpsc_gateway->wpsc_gateways[0]['name'] == 'Noca'){}else{?>
<input type='hidden' value='submit_checkout' name='wpsc_action' />
<input type='submit' value='<?php echo TXT_WPSC_MAKEPURCHASE;?>' name='submit' class='make_purchase' />
<?php }/* else: ?>
<br /><strong><?php echo TXT_WPSC_PLEASE_LOGIN;?></strong><br />
<?php echo TXT_WPSC_IF_JUST_REGISTERED;?>
</td>
<?php endif; */?>
</td>
</tr>
</table>
</form>
</div>
<?php
else:
echo TXT_WPSC_BUYPRODUCTS;
endif;
do_action('wpsc_bottom_of_shopping_cart');
?>
I am not familiar with WP e-commerce, but I've done something similar. I've added the following function and a call to the function if the 'subscribe' checkbox is checked. I am guessing that this should happen on the page AFTER the page you posted here as this looks like it's confirming the order and not processing it?
I also include a blurb in my email about signing up if they did not check the check box. Hit them again, you know?
if(isset($_REQUEST['subscribe_to_newsletter']) && $_REQUEST['subscribe_to_newsletter'] == 'yes')
{
echo mailchimp_subscribe($listid);
}
/**
* Mailchimp Subscribe
* This function subscribes people to the mailing list.
* #param string Mailchimp subscription to add users to
* #return string Success/Fail message
*/
function mailchimp_subscribe($listid)
{
require_once "{$_SERVER['DOCUMENT_ROOT']}/lib/mailchimp/MCAPI.class.php";
require_once "{$_SERVER['DOCUMENT_ROOT']}/lib/mailchimp/config.inc"; //contains username & password
$api = new MCAPI($username, $password);
if ($api->errorCode){
// an error occurred while logging in
echo "code:".$api->errorCode."\n";
echo "msg :".$api->errorMessage."\n";
//die(); // don't die, just do nothing
}
/**
Note that if you are not passing merge_vars, you will still need to pass a "blank" array. That should be either:
$merge_vars = array('');
- or -
$merge_vars = '';
Specifically, this will fail:
$merge_vars = array();
Or pass the proper data as below...
*/
$merge_vars = array( 'LNAME'=> $_REQUEST['name'], 'INTERESTS'=>'');
// By default this sends a confirmation email - you will not see new members
// until the link contained in it is clicked!
$retval = $api->listSubscribe( $listId, $_REQUEST['email_address'], $merge_vars );
if ($api->errorCode){
return "<p>Oops! We were not able to subscribe you to the e-Newsletter mailing list. Maybe you are already subscribed? Please try our <a href=\"http://www.example.com/e-newsletter-signup\">e-Newsletter Subscription page, it should work better.</p>\n<div style='color:white'>\t<span style='color:white;'>code=".$api->errorcode."\n\tmsg=".$api->errormessage."</span></div>\n";
} else {
return "<p>Thank you for subscribing to the e-Newsletter. A newsletter confirmation email has been sent to your email address.</p>\n";
}
}