Registration page of opencart - php

I want to edit my register.tpl file of registration process of my opencart page.
I just want to keep the email, password and confirm password fields. When I remove all other fields including first name, last name, address etc and only leave in email, password and confirm password fields, it stops registration. How can I make it continue registration with only 3 fields and also agree to the terms check box I have to keep.
This is the register.tpl file
<div id="content"><?php echo $content_top; ?>
<h1><?php echo $heading_title; ?></h1>
<p><?php echo $text_account_already; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<h2><?php echo $text_your_details; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
<td><input class="form-control" type="text" name="firstname" value="<?php echo $firstname; ?>" />
<?php if ($error_firstname) { ?>
<span class="error"><?php echo $error_firstname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
<td><input class="form-control" type="text" name="lastname" value="<?php echo $lastname; ?>" />
<?php if ($error_lastname) { ?>
<span class="error"><?php echo $error_lastname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_email; ?></td>
<td><input class="form-control" type="text" name="email" value="<?php echo $email; ?>" />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
<td><input class="form-control" type="text" name="telephone" value="<?php echo $telephone; ?>" />
<?php if ($error_telephone) { ?>
<span class="error"><?php echo $error_telephone; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_fax; ?></td>
<td><input class="form-control" type="text" name="fax" value="<?php echo $fax; ?>" /></td>
</tr>
</table>
</div>
<h2><?php echo $text_your_address; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><?php echo $entry_company; ?></td>
<td><input class="form-control" type="text" name="company" value="<?php echo $company; ?>" /></td>
</tr>
<tr style="display: <?php echo (count($customer_groups) > 1 ? 'table-row' : 'none'); ?>;">
<td><?php echo $entry_customer_group; ?></td>
<td><?php foreach ($customer_groups as $customer_group) { ?>
<?php if ($customer_group['customer_group_id'] == $customer_group_id) { ?>
<input type="radio" name="customer_group_id" value="<?php echo $customer_group['customer_group_id']; ?>" id="customer_group_id<?php echo $customer_group['customer_group_id']; ?>" checked="checked" />
<label for="customer_group_id<?php echo $customer_group['customer_group_id']; ?>"><?php echo $customer_group['name']; ?></label>
<br />
<?php } else { ?>
<input type="radio" name="customer_group_id" value="<?php echo $customer_group['customer_group_id']; ?>" id="customer_group_id<?php echo $customer_group['customer_group_id']; ?>" />
<label for="customer_group_id<?php echo $customer_group['customer_group_id']; ?>"><?php echo $customer_group['name']; ?></label>
<br />
<?php } ?>
<?php } ?></td>
</tr>
<tr id="company-id-display">
<td><span id="company-id-required" class="required">*</span> <?php echo $entry_company_id; ?></td>
<td><input class="form-control" type="text" name="company_id" value="<?php echo $company_id; ?>" />
<?php if ($error_company_id) { ?>
<span class="error"><?php echo $error_company_id; ?></span>
<?php } ?></td>
</tr>
<tr id="tax-id-display">
<td><span id="tax-id-required" class="required">*</span> <?php echo $entry_tax_id; ?></td>
<td><input class="form-control" type="text" name="tax_id" value="<?php echo $tax_id; ?>" />
<?php if ($error_tax_id) { ?>
<span class="error"><?php echo $error_tax_id; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
<td><input class="form-control" type="text" name="address_1" value="<?php echo $address_1; ?>" />
<?php if ($error_address_1) { ?>
<span class="error"><?php echo $error_address_1; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_address_2; ?></td>
<td><input class="form-control" type="text" name="address_2" value="<?php echo $address_2; ?>" /></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_city; ?></td>
<td><input class="form-control" type="text" name="city" value="<?php echo $city; ?>" />
<?php if ($error_city) { ?>
<span class="error"><?php echo $error_city; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span id="postcode-required" class="required">*</span> <?php echo $entry_postcode; ?></td>
<td><input class="form-control" type="text" name="postcode" value="<?php echo $postcode; ?>" />
<?php if ($error_postcode) { ?>
<span class="error"><?php echo $error_postcode; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_country; ?></td>
<td><select class="form-control" name="country_id">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($countries as $country) { ?>
<?php if ($country['country_id'] == $country_id) { ?>
<option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
<?php } ?>
<?php } ?>
</select>
<?php if ($error_country) { ?>
<span class="error"><?php echo $error_country; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_zone; ?></td>
<td><select class="form-control" name="zone_id">
</select>
<?php if ($error_zone) { ?>
<span class="error"><?php echo $error_zone; ?></span>
<?php } ?></td>
</tr>
</table>
</div>
<h2><?php echo $text_your_password; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><span class="required">*</span> <?php echo $entry_password; ?></td>
<td><input class="form-control" type="password" name="password" value="<?php echo $password; ?>" />
<?php if ($error_password) { ?>
<span class="error"><?php echo $error_password; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_confirm; ?></td>
<td><input class="form-control" type="password" name="confirm" value="<?php echo $confirm; ?>" />
<?php if ($error_confirm) { ?>
<span class="error"><?php echo $error_confirm; ?></span>
<?php } ?></td>
</tr>
</table>
</div>
<h2><?php echo $text_newsletter; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><?php echo $entry_newsletter; ?></td>
<td><?php if ($newsletter) { ?>
<input type="radio" name="newsletter" value="1" checked="checked" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" />
<?php echo $text_no; ?>
<?php } else { ?>
<input type="radio" name="newsletter" value="1" />
<?php echo $text_yes; ?>
<input type="radio" name="newsletter" value="0" checked="checked" />
<?php echo $text_no; ?>
<?php } ?></td>
</tr>
</table>
</div>
<?php if ($text_agree) { ?>
<div class="buttons">
<div class="right"><?php echo $text_agree; ?>
<?php if ($agree) { ?>
<input type="checkbox" name="agree" value="1" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="agree" value="1" />
<?php } ?>
<input type="submit" value="<?php echo $button_continue; ?>" class="button" />
</div>
</div>
<?php } else { ?>
<div class="buttons">
<div class="right">
<input type="submit" value="<?php echo $button_continue; ?>" class="button" />
</div>
</div>
<?php } ?>
</form>
<?php echo $content_bottom; ?></div>

Go to catalog/controller/account/register.php (controller) and into the function validate(). Remove the unnecessary fields. Then remove the fields from your tpl. In this way, you will be able to proceed with only three fields.

Related

How to edit the link of a variable in opencart register.tpl file?

Here is the code of register.tpl file. The variable is called and this $action variable called the account/login.php file how to I can change the link of $action variable.
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
<h2><?php echo $text_your_details; ?></h2>
<div class="content">
<table class="form">
<tr>
<td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
<td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
<?php if ($error_firstname) { ?>
<span class="error"><?php echo $error_firstname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
<td><input type="text" name="lastname" value="<?php echo $lastname; ?>" />
<?php if ($error_lastname) { ?>
<span class="error"><?php echo $error_lastname; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_email; ?></td>
<td><input type="text" name="email" value="<?php echo $email; ?>" />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
<td><input type="text" name="telephone" value="<?php echo $telephone; ?>" />
<?php if ($error_telephone) { ?>
<span class="error"><?php echo $error_telephone; ?></span>
<?php } ?></td>
</tr>
Try searching for $data['action'] variable in controller (register.php). It is there.
The solution is below. But please explain WHY you want to change it and maybe someone can offer some consultancy or a better solution...
The file is inside
/opencart/catalog/controller/account/register.php
The line is
$data['action'] = $this->url->link('account/register', '', 'SSL');
You can change it here if you wish. I would advice caution. Example would be to replace the line with:
// #CORECHANGE - Find later for upgrading
//$data['action'] = $this->url->link('account/register', '', 'SSL');
$newRegisterActionURL = "account/register/epos";
$data['action'] = $this->url->link($newRegisterActionURL, '', 'SSL');
The path for the html code for the register file in opencart project is:
/public_html/catalog/view/theme/megashop/template/account/register.tpl

php form - reload on submit

I'm required to edit someone else's code on a website (that person is not reachable) and I don't have much experience on php. At the momment this form redirects to a previous page on submit. I must change it to reload the current page. I've made numerous attempts changing the action field of the form but they all lead to either a blank page or the page it was allready redirecting to. Can someone share a little knowledge here?
<div id="tab-general" class="tab-content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
<table>
<tr>
<td><span class="required">*</span> <?php echo $entry_title; ?></td>
<td><input type="text" value="<?php echo $title; ?>" name="title" id="title" /><br />
<?php if ($error_title) { ?>
<span class="error"><?php echo $error_title; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_name; ?></td>
<td><input type="text" value="<?php echo $name; ?>" name="name" id="name" /><br />
<?php if ($error_name) { ?>
<span class="error"><?php echo $error_name; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_email; ?></td>
<td><input type="text" value="<?php echo $email; ?>" name="email" id="email" /><br />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><span class="required">*</span> <?php echo $entry_end_date; ?></td>
<td><input type="text" value="<?php echo $end_date; ?>" name="end_date" id="end_date" /><br />
<?php if ($error_end_date) { ?>
<span class="error"><?php echo $error_end_date; ?></span>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_type; ?></td>
<td><select name="type" id="type" class="type_list">
<?php if ($type) { ?>
<option value="1" selected="selected"><?php echo $text_private; ?></option>
<option value="0"><?php echo $text_public; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_private; ?></option>
<option value="0" selected="selected"><?php echo $text_public; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><?php echo $entry_status; ?></td>
<td><select name="status">
<?php if ($status) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><br /><h2><?php echo $text_invitees; ?></h2></td>
<td></td>
</tr>
</table>
<table id="attendee" class="list">
<thead>
<tr>
<td class="left"><?php echo $entry_att_name; ?></td>
<td class="right"><?php echo $entry_att_email; ?></td>
<td></td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"></td>
<td class="left"><a onclick="addAttendee();" class="button"><?php echo $button_add; ?></a></td>
</tr>
</tfoot>
<?php $attendee_row = 0; ?>
<?php if ($attendees) { ?>
<?php foreach ($attendees as $attendee) { ?>
<tbody id="attendee-row<?php echo $attendee_row; ?>">
<tr>
<td class="left"><input type="text" name="attendee[<?php echo $attendee_row; ?>][name]" value="<?php echo $attendee['name']; ?>" size="18" />
<?php if (isset($error_name_attendee[$attendee_row])) { ?>
<span class="error"><?php echo $error_name_attendee[$attendee_row]; ?></span>
<?php } ?>
</td>
<td class="right"><input type="text" name="attendee[<?php echo $attendee_row; ?>][email]" value="<?php echo $attendee['email']; ?>" size="18" />
<?php if (isset($error_email_attendee[$attendee_row])) { ?>
<span class="error"><?php echo $error_email_attendee[$attendee_row]; ?></span>
<?php } ?>
</td>
<td class="left"><a onclick="$('#attendee-row<?php echo $attendee_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a>
</td>
</tr>
</tbody>
<?php $attendee_row++; ?>
<?php } ?>
<?php } ?>
</table>
<div class="buttons"><div class="left">
<a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a></div><div class="right"><a onclick="location = '<?php echo $cancel; ?>';" class="button"><?php echo $button_cancel; ?></a>
</div></div>
</div>
After checking the content of the $action variable it turns out that it holds the link of the current page. It SHOULD reload the page but it doesn't.
example: this is the link
localhost/index.php?route=account/projects/editProject&project_id=1&akey=98c27892d1e2a13c0dfb9086539f8275
and it is stored in the $action variable. Instead the direction is to the link
localhost/index.php?route=account/projects
Make Sure your action has path equal to your page path then it will submit your form values and will stay on same page
if this page has path like e.g /home/index.php
then
<form action="/home/index.php" method="post" enctype="multipart/form-data" id="form">
and if you have get path from your $action variable then try echo $action; to make sure that you have same path of your current page
The $action variable here om the second row should result in the page that you want to reload.
If you want the form to submit to the current page, simply, remove action attribute from your form tag. However, you have to perform a check for a data submision is occured or not to prevent rendering the form or reapeated submitting of the form some thing like the following:
<?php if (isset($_POST['title']) && $_POST['title'] != ''): ?>
//Perform form data processing
<?php else: ?>
// Your form code
<?php endif; ?>

Opencart - Undefined variable in new shipping module

I'm making a new shipping module for opencart. Which simply takes the name and cost from the admin. But, shows an error inside the textbox.
I'm stuck in here, Really want solution. My view (.tpl) file is given below.
<div class="box">
<div class="heading">
<h1><img src="view/image/shipping.png" alt="" /> <?php echo $heading_title; ?></h1>
<div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><?php echo $button_cancel; ?></div>
</div>
<div class="content">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
<table class="form">
<tr>
<td><?php echo $entry_name; ?></td>
<td><input type="text" name="ndz_name" value="<?php echo $ndz_name; ?>" /></td>
</tr>
<tr>
<td><?php echo $entry_amount; ?></td>
<td><input type="text" name="ndz_amount" value="<?php echo $ndz_amount; ?>" /></td>
</tr>
<tr>
<td><?php echo $entry_status; ?></td>
<td><select name="ndz_status">
<?php if ($ndz_status) { ?>
<option value="1" selected="selected"><?php echo $text_enabled; ?></option>
<option value="0"><?php echo $text_disabled; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_enabled; ?></option>
<option value="0" selected="selected"><?php echo $text_disabled; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><?php echo $entry_sort_order; ?></td>
<td><input type="text" name="ndz_sort_order" value="<?php echo $ndz_sort_order; ?>" size="1" /></td>
</tr>
</table>
</form>
</div>
</div>
Opencart version : 1.5
Because you need to initialize your $ndz_name and $ndz_amount before you echos it.
$ndz_name = '';
$ndz_amount = '';
if (!empty($_POST["ndz_name"])) {
$ndz_name = $_POST["ndz_name"];
}
if (!empty($_POST["ndz_amount"])) {
$ndz_amount = $_POST["ndz_amount"];
}

1 array to soon issue mySQL and php

I have this strange issue with mySQL and PHP, it seems the output of the mySQL is 1 array to soon. It puts the output data from the dropdownboxes (enum) into the wrong textbox. Any help would be appreciated.
HTML
<table style="border-spacing:20px; border:2; border-color: black; border-style: solid;">
<tr>
<td>
<strong>Medewerker: *</strong><br/> <?php enumDropdown(#$table_name, #medewerker) ?><br/><br/>
<strong>Datum overboeking: </strong><br/> <input id="date" type="text" name="datum_overboeking" value="<?php echo $datum_overboeking; ?>" /><br/><br/>
<strong>Juliette geinformeerd: </strong><br/> <?php enumDropdown(#$table_name, #juliette_geinformeerd) ?><?php echo $juliette_geinformeerd; ?> <br/><br/>
<strong>Boekingsnummer: *</strong><br/> <input type="text" name="boekingsnummer" value="<?php echo $boekingsnummer; ?>" /><br/><br/>
<strong>Land: </strong><br/> <?php enumDropdown(#$table_name, #land) ?><?php echo $land; ?> <br/><br/>
</td>
<td>
<strong>Huiscode: </strong><br/> <input type="text" name="huiscode" value="<?php echo $huiscode; ?>" /><br/><br/>
<strong>Aanbieder: </strong><br/> <?php enumDropdown(#$table_name, #aanbieder) ?><?php echo $aanbieder; ?> <br/><br/>
<strong>Contractvorm: </strong><br/> <?php enumDropdown(#$table_name, #contractvorm) ?><?php echo $contractvorm; ?> <br/><br/>
<strong>Huursom: </strong><br/> <input type="text" name="huursom" value="<?php echo $huursom; ?>" /><br/><br/>
<strong>Periode van: </strong><br/> <input id="date1" type="text" name="periode_van" value="<?php echo $periode_van; ?>" /><br/><br/>
</td>
<td>
<strong>Periode tot: </strong><br/> <input id="date2" type="text" name="periode_tot" value="<?php echo $periode_tot; ?>" /><br/><br/>
<strong>Distributiekanaal: </strong><br/> <input type="text" name="distributiekanaal" value="<?php echo $distributiekanaal; ?>" /><br/><br/>
<strong>Naam klant: </strong><br/> <input type="text" name="naam_klant" value="<?php echo $naam_klant; ?>" /><br/><br/>
<strong>Reden: </strong><br/> <?php enumDropdown(#$table_name, #reden) ?><?php echo $reden; ?> <br/><br/>
<strong>Nieuwe boeking: </strong><br/> <?php enumDropdown(#$table_name, #nieuwe_boeking) ?><?php echo $nieuwe_boeking; ?> <br/><br/>
</td>
<td>
<strong>Reden geen nieuwe boeking: </strong><br/> <?php enumDropdown(#$table_name, #reden_geen_nieuwe_boeking) ?><?php echo $reden_geen_nieuwe_boeking; ?> <br/><br/>
<strong>Boete aanbieden: </strong><br/> <?php enumDropdown(#$table_name, #boete_aanbieden) ?><?php echo $boete_aanbieden; ?> <br/><br/>
<strong>Administratie geinformeerd voor inhouding boete: </strong><br/> <?php enumDropdown(#$table_name, #administratie_geinformeerd_voor_inhouding_boete) ?><?php echo $administratie_geinformeerd_voor_inhouding_boete; ?> <br/><br/>
<strong>Bedrag van boete: </strong><br/> <input type="text" name="bedrag_van_boete" value="<?php echo $bedrag_van_boete; ?>" /><br/><br/>
<strong>Coulance HappyHome: </strong><br/> <?php enumDropdown(#$table_name, #coulance_happyhome) ?><?php echo $coulance_happyhome; ?> <br/><br/>
</td>
<tr>
<td colspan="4">
<strong>Opmerking: </strong><br/> <textarea style="width: 1000px; height: 60px;" type="text" name="opmerking" value="<?php echo $opmerking; ?>"></textarea><br/><br>
</td>
</tr>
PHP
<?php
// dropdownlist met SQL values ophalen
function enumDropdown($table_name, $column_name)
{
$table_name= 'overboekingen';
$selectDropdown = "<select name=\"$column_name\">";
$result = mysql_query("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '$table_name' AND COLUMN_NAME = '$column_name'")
or die (mysql_error());
$row = mysql_fetch_array($result);
$enumList = explode(",", str_replace("'", "", substr($row['COLUMN_TYPE'], 5, (strlen($row['COLUMN_TYPE'])-6))));
foreach($enumList as $value)
$selectDropdown .= "<option value=\"$value\">$value</option>";
$selectDropdown .= "</select>";
echo $selectDropdown;
}
////////////////////////////////////////////////////////////////////////////////
?>

Integrating MailChimp into E-Commerce Shopping Cart

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";
}
}

Categories