Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

what is wrong with this code?


Guest

Recommended Posts

Hi

 

what is wrong with my code?

 

it is not passing the price value.

 

 

	<?php
$orders_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL. " where orders_id = '" . (int)$oID . "'");
$orders_array = tep_db_fetch_array($orders_query);
$ordert = $orders_array['value'];
	?>


(this is only part of the form)
<input type="hidden" name="item_name" value="test2" />
<input type="hidden" name="item_number" value="test2" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="a3" value=".$ordert." />
<input type="hidden" name="p3" value="1" />

 

can you help me please?

Link to comment
Share on other sites

what is wrong with my code?

it is not passing the price value.

 

(this is only part of the form)

<input type="hidden" name="a3" value=".$ordert." />

 

can you help me please?

 

Errrr, what about trying to pass the value like this?

 <input type="hidden" name="a3" value="<?php echo $ordert; ?>" />

You'd then be in with a chance... :)

Link to comment
Share on other sites

Errrr, what about trying to pass the value like this?

 <input type="hidden" name="a3" value="<?php echo $ordert; ?>" />

You'd then be in with a chance... :)

 

this did not work?

Link to comment
Share on other sites

this did not work?

Oh, I'm surprised, well in that case have you checked that

	<?php
$orders_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL. " where orders_id = '" . (int)$oID . "'");
$orders_array = tep_db_fetch_array($orders_query);
$ordert = $orders_array['value'];
	?>

sets $ordert to something sensible before trying to pass it to the hidden field?

 

Try printing some debug to echo $ordert or var_dump($ordert) before passing it so you can see what it contains.

 

Try temporarily hard coding $ordert to something like

$ordert = "1.23";

immediately before passing it to your form to see that it's passed properly to the hidden field. Then we'll be able to narrow down where things are going wrong.

 

By that I mean temporarily try this...

<input type="hidden" name="a3" value="<?php $ordert="1.23"; echo $ordert; ?>" />

just to check that something really silly isn't happening.

 

When you say "it doesn't work?", I presume you've checked your form to see that a3 is set but is empty? You can do this by examining your DOM perhaps, or are you just checking the values sent when the form is submitted?

 

Please be a bit more specific than "it doesn't work". You haven't given us very much to go on. The answers to the questions I raised here would be useful, and by finding them you might even solve the problem.

 

Perhaps you can paste a bit more code if you still can't find the solution, all the lines from where you set $ordert to where it is put in the hidden field?

Link to comment
Share on other sites

Hi

 

<!-- PayPal Subscritions Button Start  //-->

<?php
$orders_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL. " where orders_id = '" . (int)$oID . "'");
$orders_array = tep_db_fetch_array($orders_query);
echo $ordert = $orders_array['value'];
	?>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="[email protected]" />
<input type="hidden" name="item_name" value="test2" />
<input type="hidden" name="item_number" value="test2" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="a3" value="<?php echo $ordert; ?>" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="return" value="http://www.westonehosting.com/account.php" />
<input type="hidden" name="cancel_return" value="http://www.westonehosting.com/account.php" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="receiver_email" value="[email protected]" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="image" name="submit" src="http://images.paypal.com/images/x-click-butcc-subscribe.gif" border="0" alt="Make payments with PayPal, it's fast, free, and secure!" />
</form>

<!-- PayPal Subscritions Button END  //-->

 

 

and this is the full file:

 

<?php
/*
 $Id: account_history_info.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) {
tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
 }

 $customer_info_query = tep_db_query("select o.customers_id from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS . " s where o.orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1'");
 $customer_info = tep_db_fetch_array($customer_info_query);
 if ($customer_info['customers_id'] != $customer_id) {
tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
 $breadcrumb->add(sprintf(NAVBAR_TITLE_3, $HTTP_GET_VARS['order_id']), tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $HTTP_GET_VARS['order_id'], 'SSL'));

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order($HTTP_GET_VARS['order_id']);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH_LEFT_IS; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH_LEFT_IS; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_history.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td align="center">
<!-- PayPal Subscritions Button Start  //-->

<?php
$orders_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL. " where orders_id = '" . (int)$oID . "'");
$orders_array = tep_db_fetch_array($orders_query);
echo $ordert = $orders_array['value'];
	?>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="[email protected]" />
<input type="hidden" name="item_name" value="test2" />
<input type="hidden" name="item_number" value="test2" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="a3" value="<?php echo $ordert; ?>" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="return" value="http://www.westonehosting.com/account.php" />
<input type="hidden" name="cancel_return" value="http://www.westonehosting.com/account.php" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="receiver_email" value="[email protected]" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="image" name="submit" src="http://images.paypal.com/images/x-click-butcc-subscribe.gif" border="0" alt="Make payments with PayPal, it's fast, free, and secure!" />
</form>

<!-- PayPal Subscritions Button END  //-->

	</td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main" colspan="2"><b><?php echo sprintf(HEADING_ORDER_NUMBER, $HTTP_GET_VARS['order_id']) . ' <small>(' . $order->info['orders_status'] . ')</small>'; ?></b></td>
	  </tr>
	  <tr>
		<td class="smallText"><?php echo HEADING_ORDER_DATE . ' ' . tep_date_long($order->info['date_purchased']); ?></td>
		<td class="smallText" align="right"><?php echo HEADING_ORDER_TOTAL . ' ' . $order->info['total']; ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
<?php
 if ($order->delivery != false) {
?>
		<td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="main"><b><?php echo HEADING_DELIVERY_ADDRESS; ?></b></td>
		  </tr>
		  <tr>
			<td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td>
		  </tr>
<?php
if (tep_not_null($order->info['shipping_method'])) {
?>
		  <tr>
			<td class="main"><b><?php echo HEADING_SHIPPING_METHOD; ?></b></td>
		  </tr>
		  <tr>
			<td class="main"><?php echo $order->info['shipping_method']; ?></td>
		  </tr>
<?php
}
?>
		</table></td>
<?php
 }
?>
		<td width="<?php echo (($order->delivery != false) ? '70%' : '100%'); ?>" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
		  <tr>
			<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if (sizeof($order->info['tax_groups']) > 1) {
?>
			  <tr>
				<td class="main" colspan="2"><b><?php echo HEADING_PRODUCTS; ?></b></td>
				<td class="smallText" align="right"><b><?php echo HEADING_TAX; ?></b></td>
				<td class="smallText" align="right"><b><?php echo HEADING_TOTAL; ?></b></td>
			  </tr>
<?php
 } else {
?>
			  <tr>
				<td class="main" colspan="3"><b><?php echo HEADING_PRODUCTS; ?></b></td>
			  </tr>
<?php
 }

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
echo '		  <tr>' . "\n" .
	 '			<td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
	 '			<td class="main" valign="top">' . $order->products[$i]['name'];

if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
  }
}

echo '</td>' . "\n";

if (sizeof($order->info['tax_groups']) > 1) {
  echo '			<td class="main" valign="top" align="right">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";
}

echo '			<td class="main" align="right" valign="top">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" .
	 '		  </tr>' . "\n";
 }
?>
			</table></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td class="main"><b><?php echo HEADING_BILLING_INFORMATION; ?></b></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="main"><b><?php echo HEADING_BILLING_ADDRESS; ?></b></td>
		  </tr>
		  <tr>
			<td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br>'); ?></td>
		  </tr>
		  <tr>
			<td class="main"><b><?php echo HEADING_PAYMENT_METHOD; ?></b></td>
		  </tr>
		  <tr>
			<td class="main"><?php echo $order->info['payment_method']; ?></td>
		  </tr>
		</table></td>
		<td width="70%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {
echo '			  <tr>' . "\n" .
	 '				<td class="main" align="right" width="100%">' . $order->totals[$i]['title'] . '</td>' . "\n" .
	 '				<td class="main" align="right">' . $order->totals[$i]['text'] . '</td>' . "\n" .
	 '			  </tr>' . "\n";
 }
?>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td class="main"><b><?php echo HEADING_ORDER_HISTORY; ?></b></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 $statuses_query = tep_db_query("select os.orders_status_name, osh.date_added, osh.comments from " . TABLE_ORDERS_STATUS . " os, " . TABLE_ORDERS_STATUS_HISTORY . " osh where osh.orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "' and osh.orders_status_id = os.orders_status_id and os.language_id = '" . (int)$languages_id . "' and os.public_flag = '1' order by osh.date_added");
 while ($statuses = tep_db_fetch_array($statuses_query)) {
echo '			  <tr>' . "\n" .
	 '				<td class="main" valign="top" width="70">' . tep_date_short($statuses['date_added']) . '</td>' . "\n" .
	 '				<td class="main" valign="top" width="70">' . $statuses['orders_status_name'] . '</td>' . "\n" .
	 '				<td class="main" valign="top">' . (empty($statuses['comments']) ? ' ' : nl2br(tep_output_string_protected($statuses['comments']))) . '</td>' . "\n" .
	 '			  </tr>' . "\n";
 }
?>
		</table></td>
	  </tr>
	</table></td>
  </tr>
<?php
 if (DOWNLOAD_ENABLED == 'true') include(DIR_WS_MODULES . 'downloads.php');
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
</table></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH_RIGHT_IS; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH_RIGHT_IS; ?>" cellspacing="0" cellpadding="2"> 
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

I am trying to put a button on my invoices so my client can pay for there invoice each month.

 

I will be copying the invoice each time?

 

hope this helps

Link to comment
Share on other sites

Hi

 

This is what I see at pypal :

You have entered an invalid amount. Please make sure that all punctuation marks are in the correct places and that you only include the number. For example, if the amount is £5.00 GBP, you would enter 5.00.

 

and I put this in the code:

 

<?php

$orders_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL. " where orders_id = '" . (int)$oID . "'");

$orders_array = tep_db_fetch_array($orders_query);

echo $ordert = $orders_array['value'];

?>

 

it show a price but it is not the one to the product id it is to anther one

 

it shows 15.2200

 

this workes:

echo $ordert = 4.00;
Link to comment
Share on other sites

Well, for starters, your SQL query needs more in it. If you look at the orders_total table, then for each order there will be 4 entries in the table. That explains why you're pulling out the wrong number. You also need to add something like "AND 'class' = 'ot_total'" to it to pick out the one you're interested in.

 

You say "15.2200" didn't work, but "4.00" did work when sending the form to PayPal? Perhaps you need to chop it to 2 decimal places to please PayPal, I don't know about that though.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...