Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$order->content_type lost ... and found on checkout_payment.php


dennish

Recommended Posts

Hello,

I want to use $order->content_type to display different content and error messages depending on the type of products the buyer has selected (virtual, physical or mixed).

My code for catalog/checkout_payment.php is:
 

<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

// Contributions added:
// - Must agree to terms (070727): lines 103, 489
// - Sisow: lines 77, 90, 123

  require('includes/application_top.php');

// load all enabled payment modules
  require(DIR_WS_CLASSES . 'payment.php');
  $payment_modules = new payment;

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

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot();
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
  if (!tep_session_is_registered('shipping')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  }

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

// Stock Check
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
        tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
        break;
      }
    }
  }

// if no billing destination address was selected, use the customers own address as default
  if (!tep_session_is_registered('billto')) {
    tep_session_register('billto');
    $billto = $customer_default_address_id;
  } else {
// verify the selected billing address
    if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) {
      $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
      $check_address = tep_db_fetch_array($check_address_query);

      if ($check_address['total'] != '1') {
        $billto = $customer_default_address_id;
        if (tep_session_is_registered('payment')) tep_session_unregister('payment');
      }
    }
  }

//  - Start
  $process = false;
  if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
    $process = true;
	
    $payment = tep_db_prepare_input($HTTP_POST_VARS['payment']);
    $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']);
//    if ($payment == 'sisowideal') {
//    $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']);
//	}
    $agree = tep_db_prepare_input($HTTP_POST_VARS['agree']);
//  - End

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

//  - Start
  $error = false;

// if ($payment == 'sisowideal') {
if ($HTTP_POST_VARS['payment'] == 'sisowideal') {
//  if (is_numeric($sisow_bank) == false) {
    if ($HTTP_POST_VARS['sisow_bank'] == '') {
      $error = true;

      $messageStack->add('checkout_payment', ENTRY_SISOWIDEAL_ERROR);
    }
}

    if ($agree == false) {
      $error = true;
	  
if ($order->content_type == 'virtual' or $order->content_type == 'mixed') {
      $messageStack->add('checkout_payment', ENTRY_LICENSE_AGREEMENT_ERROR);
      } else {
      $messageStack->add('checkout_payment', ENTRY_CONDITION_AGREEMENT_ERROR);
      }
	  
    }
//  - End

  if (!tep_session_is_registered('comments')) tep_session_register('comments');
  if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) {
    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
  }

  $total_weight = $cart->show_weight();
  $total_count = $cart->count_contents();

//  - Start
if ($error == false) {
  if ($HTTP_POST_VARS['sisow_bank'] != '') {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'sisow_bank=' . $sisow_bank . '&agree=' . $agree, 'SSL'));
  } else {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'agree=' . $agree, 'SSL'));
  }
}

}
//  - End
  
  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<script type="text/javascript"><!--
var selected;

function isEven(value) {
	if (value%2 == 0)
		return true;
	else
		return false;
}

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }
  
//  if (selected) selected.className = 'moduleRow';
if (selected) {
   if (selected.className == 'moduleRowSelected-even') {
            selected.className = 'moduleRow-even';
   }

   if (selected.className == 'moduleRowSelected-odd') {
            selected.className = 'moduleRow-odd';
   }
}

object.className = isEven(buttonSelect) == false ? "moduleRowSelected-even" : "moduleRowSelected-odd";

//selected.className = 'moduleRow';
//object.className = 'moduleRowSelected';
selected = object;
  
// one button is not an array
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;
  } else {
    document.checkout_payment.payment.checked=true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow-even') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver-even') object.className = 'moduleRow';
}

//--></script>

<?php // echo $payment_modules->javascript_validation(); ?>

<h1><?php echo HEADING_TITLE; ?></h1>

<!--  - Start //-->
<?php // echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true); ?>
<?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true) . tep_draw_hidden_field('action', 'process'); ?>
<!--  - End //-->

<div class="contentContainer">

<?php
  if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
?>

  <div class="contentText">
    <?php echo '<strong>' . tep_output_string_protected($error['title']) . '</strong>'; ?>

    <p class="messageStackError"><?php echo tep_output_string_protected($error['error']); ?></p>
  </div>

<?php
  }
?>

<!--  - Start //-->
<?php
  if ($messageStack->size('checkout_payment') > 0) {
    echo $messageStack->output('checkout_payment');
  }
?>
<!--  - End //-->

  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h2>
  </div>

  <div class="contentText">
  
<!--  - Start
    <?php echo TEXT_SELECTED_BILLING_DESTINATION; ?>
 - End //-->

<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
              <tr>
        		<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		  </tr>
              <tr>
            	<td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td width="100%"><table border="0" border-collapse="collapse" width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="main"><?php echo TITLE_BILLING_ADDRESS; ?></td>
<!--  - Start //-->
<?php
// Bij slechts 1 adres geen keuze
  $addresses_count = tep_count_customer_address_book_entries();

    if ($addresses_count > 1) {
?>
<!--  - End //-->
                    <td class="main" align="right" rowspan="2"><?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'home', tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL')); ?></td>
<!--  - Start //-->
<?php
} else {
?>
                    <td class="main" align="right" rowspan="2"></td>
<?php
}
?>
<!--  - End //-->
                  </tr>
                  <tr>
                    <td class="main"> </td>
                  </tr>
                  <tr>
                    <td colspan="2"><table border="0" border-collapse="collapse" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                        <td class="main"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?></td>
                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
            	<td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
              <tr>
        		<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		  </tr>
            </table></td>
          </tr>
        </table>

  </div>

  <div style="clear: both;"></div>

  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></h2>
  </div>

<div class="contentText">
<table class="infoBox">
  <tr>
    <td><table class="infoBoxContents">
        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      	</tr>
  
<?php
  $selection = $payment_modules->selection();

  if (sizeof($selection) > 1) {
?>

<!--  - Start
  <div class="contentText">
    <div style="float: right;">
      <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?>
    </div>

    <?php echo TEXT_SELECT_PAYMENT_METHOD; ?>
  </div>
 - End //-->

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
          <td class="main" colspan="2" width="100%" valign="top"><p><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
        </tr>
        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
        </tr>

<?php
    } else {
?>

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
          <td class="main" width="100%" colspan="2"><p><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></p></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
        </tr>

<?php
    }
?>

<?php
  $radio_buttons = 0;
  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
//    if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
//      echo '      <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
//    } else {
// - Start
//      echo '      <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      if (($i/2) == floor($i/2)) {
      echo '      <tr class="moduleRow-odd"  onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      } else {
      echo '      <tr class="moduleRow-even" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      }
// - End
//    }
?>

                    <td class="main" colspan="3" width="200" style="vertical-align:middle; padding-top:10px; padding-bottom:10px;">  <?php echo $selection[$i]['module']; ?></td>
                    <td class="main" align="right" style="vertical-align:middle; padding-top:10px; padding-right:10px; padding-bottom:10px;">

<?php
    if (sizeof($selection) > 1) {
      echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment));
    } else {
      echo tep_draw_hidden_field('payment', $selection[$i]['id']);
    }
?>

          </td></tr></table></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>

<?php
    if (isset($selection[$i]['error'])) {
?>

        <tr>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>

<?php
    } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>

        <tr>
          <td class="infoBoxMargin"><img src="images/pixel_trans.gif" style="border: 0;" alt="" width="10" height="1" /></td>
          <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<!--  - Start
        <tr>
 - End //-->
<?php
      if (($i/2) == floor($i/2)) {
?>
<tr class="moduleRow-odd_2">
<?php
      } else {
?>
<tr class="moduleRow-even_2">
<?php
      }
?>


          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">

<?php
      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>

          <tr>
            <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
            <td class="main" style="vertical-align:middle; padding-top:10px; padding-bottom:10px;"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
            <td><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
            <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          </tr>

<?php
      }
?>

          </table></td>
        </tr>

          </td></tr></table></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>
		
<?php
    }
?>

<?php
    $radio_buttons++;
  }
?>

        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      	</tr>
    </table></td>
  </tr>
</table>

  </div>
  
  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_COMMENTS; ?></h2>
  </div>

  <div class="contentText">
<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
              <tr>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  				<td valign="top" width="100%"><table width="100%">
  					 <tr>
    <td class="main"><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>
                	 </tr>
                </table></td>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
            </table></td>
          </tr>
        </table>
  </div>
  
<!-- Must agree to terms - Start //-->

  <div class="subHeader">
  <h2><?php echo TITLE_CONDITION_AGREEMENT; ?></h2>
  </div>

<div class="contentText">
<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
              <tr>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  				<td valign="top" width="100%"><table width="100%">
  					 <tr>
<?php
      if ($order->content_type == 'virtual' or $order->content_type == 'mixed') {
?>
  					 <td class="main" width="80%" align="left"><?php echo TEXT_LICENSE_AGREEMENT; ?></td>		 
<?php
      } else {
?>
  					 <td class="main" width="80%" align="left"><?php echo TEXT_CONDITION_AGREEMENT; ?></td>
<?php
    }
?>
    				 <td width="20%" align="right"><?php echo tep_draw_checkbox_field('agree','true'); ?></td>

                	 </tr>
                </table></td>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
            </table></td>
          </tr>
        </table>
  </div>
<!-- Must agree to terms - End //-->

<!--

  <div class="contentText">
    <div style="width: 60%; padding-top: 5px; margin-left: auto; margin-right: auto;">
      <div id="coProgressBar" style="height: 5px;"></div>
      <table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
          <td align="center" width="33%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
          <td align="center" width="33%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
          <td align="center" width="33%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
<?php
      } else {
?>
          <td align="center" width="50%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
          <td align="center" width="50%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
<?php
    }
?>
        </tr>
      </table>
    </div>
  </div>

<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
<script type="text/javascript">
$('#coProgressBar').progressbar({
  value: 66
});
</script>
<?php
      } else {
?>
<script type="text/javascript">
$('#coProgressBar').progressbar({
  value: 50
});
</script>
<?php
    }
?>

//-->
</div>

<!--  - Start //-->
</div> <!-- bodyContent //-->
</div>
</div>
<!--  - End //-->

  <div class="buttonSet">
    <span class="buttonAction" style="float: right;"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></span>
<!--  - Start //-->
<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); ?></span>
<?php
      } else {
?>
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL')); ?></span>

<?php
    }
?>
<!--  - End //-->
  </div>

</form>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

All is working well except for the following strange behaviour:

When I select a download (virtual product) and go from shopping_cart.php to checkout_payment.php, checkout_shipping.php is skipped as expected (confirming to me that $order->content_type is set to virtual). However, on checkout_payment.php itself content is displayed as if a physical product was selected ($order->content_type seems to be lost or reset). Only after I submit the form on checkout_payment.php (which I fill in incorrectly on purpose - e.g. don't accept the required terms - to stay on the same page checkout_payment.php and test my error handling) checkout_payment.php all at once seems to remember the item previously selected and therefore content is displayed based on a virtual product (as it should have done in the first place).

Any help to resolve this issue is very much appreciated.

Kind regards,

Dennis

 

Note: my osC version is 2.3.4.

Link to comment
Share on other sites

Hello,

 

I took a another look and discovered a small slip in my code: I made a mistake by placing this part

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

in the following if statement

if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {

thereby making the execution (receiving the order data, including the $order->content_type) dependent on submitting the form.

 

Moving the code snippet up a bit (out of the if statement) solved the issue. Here is the correct version of my checkout_payment.php (Note: modified with add-ons etc.):

<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

// Contributions added:
// - Must agree to terms (070727): lines 103, 489
// - Sisow: lines 77, 90, 123

  require('includes/application_top.php');

// load all enabled payment modules
  require(DIR_WS_CLASSES . 'payment.php');
  $payment_modules = new payment;

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

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot();
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
  if (!tep_session_is_registered('shipping')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  }

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

// Stock Check
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
        tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
        break;
      }
    }
  }

// if no billing destination address was selected, use the customers own address as default
  if (!tep_session_is_registered('billto')) {
    tep_session_register('billto');
    $billto = $customer_default_address_id;
  } else {
// verify the selected billing address
    if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) {
      $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
      $check_address = tep_db_fetch_array($check_address_query);

      if ($check_address['total'] != '1') {
        $billto = $customer_default_address_id;
        if (tep_session_is_registered('payment')) tep_session_unregister('payment');
      }
    }
  }

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;
  
//  - Start
  $process = false;
  if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
    $process = true;
	
    $payment = tep_db_prepare_input($HTTP_POST_VARS['payment']);
    $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']);
//    if ($payment == 'sisowideal') {
//    $sisow_bank = tep_db_prepare_input($HTTP_POST_VARS['sisow_bank']);
//	}
    $agree = tep_db_prepare_input($HTTP_POST_VARS['agree']);
//  - End

//  - Start
  $error = false;

// if ($payment == 'sisowideal') {
if ($HTTP_POST_VARS['payment'] == 'sisowideal') {
//  if (is_numeric($sisow_bank) == false) {
    if ($HTTP_POST_VARS['sisow_bank'] == '') {
      $error = true;

      $messageStack->add('checkout_payment', ENTRY_SISOWIDEAL_ERROR);
    }
}

    if ($agree == false) {
      $error = true;
	  
if ($order->content_type == 'virtual' or $order->content_type == 'mixed') {
      $messageStack->add('checkout_payment', ENTRY_LICENSE_AGREEMENT_ERROR);
      } else {
      $messageStack->add('checkout_payment', ENTRY_CONDITION_AGREEMENT_ERROR);
      }
	  
    }
//  - End

  if (!tep_session_is_registered('comments')) tep_session_register('comments');
  if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) {
    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
  }

  $total_weight = $cart->show_weight();
  $total_count = $cart->count_contents();

//  - Start
if ($error == false) {
  if ($HTTP_POST_VARS['sisow_bank'] != '') {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'sisow_bank=' . $sisow_bank . '&agree=' . $agree, 'SSL'));
  } else {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'agree=' . $agree, 'SSL'));
  }
}

}
//  - End
  
  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<script type="text/javascript"><!--
var selected;

function isEven(value) {
	if (value%2 == 0)
		return true;
	else
		return false;
}

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }
  
//  if (selected) selected.className = 'moduleRow';
if (selected) {
   if (selected.className == 'moduleRowSelected-even') {
            selected.className = 'moduleRow-even';
   }

   if (selected.className == 'moduleRowSelected-odd') {
            selected.className = 'moduleRow-odd';
   }
}

object.className = isEven(buttonSelect) == false ? "moduleRowSelected-even" : "moduleRowSelected-odd";

//selected.className = 'moduleRow';
//object.className = 'moduleRowSelected';
selected = object;
  
// one button is not an array
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;
  } else {
    document.checkout_payment.payment.checked=true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow-even') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver-even') object.className = 'moduleRow';
}

//--></script>

<?php // echo $payment_modules->javascript_validation(); ?>

<h1><?php echo HEADING_TITLE; ?></h1>

<!--  - Start //-->
<?php // echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true); ?>
<?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'post', 'onsubmit="return check_form();"', true) . tep_draw_hidden_field('action', 'process'); ?>
<!--  - End //-->

<div class="contentContainer">

<?php
  if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
?>

  <div class="contentText">
    <?php echo '<strong>' . tep_output_string_protected($error['title']) . '</strong>'; ?>

    <p class="messageStackError"><?php echo tep_output_string_protected($error['error']); ?></p>
  </div>

<?php
  }
?>

<!--  - Start //-->
<?php
  if ($messageStack->size('checkout_payment') > 0) {
    echo $messageStack->output('checkout_payment');
  }
?>
<!--  - End //-->

  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h2>
  </div>

  <div class="contentText">
  
<!--  - Start
    <?php echo TEXT_SELECTED_BILLING_DESTINATION; ?>
 - End //-->

<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
              <tr>
        		<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		  </tr>
              <tr>
            	<td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td width="100%"><table border="0" border-collapse="collapse" width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="main"><?php echo TITLE_BILLING_ADDRESS; ?></td>
<!--  - Start //-->
<?php
// Bij slechts 1 adres geen keuze
  $addresses_count = tep_count_customer_address_book_entries();

    if ($addresses_count > 1) {
?>
<!--  - End //-->
                    <td class="main" align="right" rowspan="2"><?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'home', tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL')); ?></td>
<!--  - Start //-->
<?php
} else {
?>
                    <td class="main" align="right" rowspan="2"></td>
<?php
}
?>
<!--  - End //-->
                  </tr>
                  <tr>
                    <td class="main"> </td>
                  </tr>
                  <tr>
                    <td colspan="2"><table border="0" border-collapse="collapse" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                        <td class="main"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?></td>
                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
            	<td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
              <tr>
        		<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		  </tr>
            </table></td>
          </tr>
        </table>

  </div>

  <div style="clear: both;"></div>

  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></h2>
  </div>

<div class="contentText">
<table class="infoBox">
  <tr>
    <td><table class="infoBoxContents">
        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      	</tr>
  
<?php
  $selection = $payment_modules->selection();

  if (sizeof($selection) > 1) {
?>

<!--  - Start
  <div class="contentText">
    <div style="float: right;">
      <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?>
    </div>

    <?php echo TEXT_SELECT_PAYMENT_METHOD; ?>
  </div>
 - End //-->

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
          <td class="main" colspan="2" width="100%" valign="top"><p><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
        </tr>
        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
        </tr>

<?php
    } else {
?>

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
          <td class="main" width="100%" colspan="2"><p><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></p></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 
        </tr>

<?php
    }
?>

<?php
  $radio_buttons = 0;
  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>

        <tr>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
//    if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
//      echo '      <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
//    } else {
// - Start
//      echo '      <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      if (($i/2) == floor($i/2)) {
      echo '      <tr class="moduleRow-odd"  onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      } else {
      echo '      <tr class="moduleRow-even" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
      }
// - End
//    }
?>

                    <td class="main" colspan="3" width="200" style="vertical-align:middle; padding-top:10px; padding-bottom:10px;">  <?php echo $selection[$i]['module']; ?></td>
                    <td class="main" align="right" style="vertical-align:middle; padding-top:10px; padding-right:10px; padding-bottom:10px;">

<?php
    if (sizeof($selection) > 1) {
      echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment));
    } else {
      echo tep_draw_hidden_field('payment', $selection[$i]['id']);
    }
?>

          </td></tr></table></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>

<?php
    if (isset($selection[$i]['error'])) {
?>

        <tr>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>

<?php
    } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
?>

        <tr>
          <td class="infoBoxMargin"><img src="images/pixel_trans.gif" style="border: 0;" alt="" width="10" height="1" /></td>
          <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<!--  - Start
        <tr>
 - End //-->
<?php
      if (($i/2) == floor($i/2)) {
?>
<tr class="moduleRow-odd_2">
<?php
      } else {
?>
<tr class="moduleRow-even_2">
<?php
      }
?>


          <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">

<?php
      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>

          <tr>
            <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
            <td class="main" style="vertical-align:middle; padding-top:10px; padding-bottom:10px;"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
            <td><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
            <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
          </tr>

<?php
      }
?>

          </table></td>
        </tr>

          </td></tr></table></td>
          <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        </tr>
		
<?php
    }
?>

<?php
    $radio_buttons++;
  }
?>

        <tr>
          <td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      	</tr>
    </table></td>
  </tr>
</table>

  </div>
  
  <div class="subHeader">
  <h2><?php echo TABLE_HEADING_COMMENTS; ?></h2>
  </div>

  <div class="contentText">
<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
              <tr>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  				<td valign="top" width="100%"><table width="100%">
  					 <tr>
    <td class="main"><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>
                	 </tr>
                </table></td>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
            </table></td>
          </tr>
        </table>
  </div>
  
<!-- Must agree to terms - Start //-->

  <div class="subHeader">
  <h2><?php echo TITLE_CONDITION_AGREEMENT; ?></h2>
  </div>

<div class="contentText">
<table class="infoBox">
          <tr>
            <td><table class="infoBoxContents">
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
              <tr>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
  				<td valign="top" width="100%"><table width="100%">
  					 <tr>
<?php
      if ($order->content_type == 'virtual' or $order->content_type == 'mixed') {
?>
  					 <td class="main" width="80%" align="left"><?php echo TEXT_LICENSE_AGREEMENT; ?></td>		 
<?php
      } else {
?>
  					 <td class="main" width="80%" align="left"><?php echo TEXT_CONDITION_AGREEMENT; ?></td>
<?php
    }
?>
    				 <td width="20%" align="right"><?php echo tep_draw_checkbox_field('agree','true'); ?></td>

                	 </tr>
                </table></td>
                <td class="infoBoxMargin"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
               <tr>
        			<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '5'); ?></td>
      		   </tr>
            </table></td>
          </tr>
        </table>
  </div>
<!-- Must agree to terms - End //-->

<!--

  <div class="contentText">
    <div style="width: 60%; padding-top: 5px; margin-left: auto; margin-right: auto;">
      <div id="coProgressBar" style="height: 5px;"></div>
      <table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
          <td align="center" width="33%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
          <td align="center" width="33%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
          <td align="center" width="33%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
<?php
      } else {
?>
          <td align="center" width="50%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
          <td align="center" width="50%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
<?php
    }
?>
        </tr>
      </table>
    </div>
  </div>

<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
<script type="text/javascript">
$('#coProgressBar').progressbar({
  value: 66
});
</script>
<?php
      } else {
?>
<script type="text/javascript">
$('#coProgressBar').progressbar({
  value: 50
});
</script>
<?php
    }
?>

//-->
</div>

<!--  - Start //-->
</div> <!-- bodyContent //-->
</div>
</div>
<!--  - End //-->

  <div class="buttonSet">
    <span class="buttonAction" style="float: right;"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', null, 'primary'); ?></span>
<!--  - Start //-->
<?php
      if ($order->content_type == 'physical' or $order->content_type == 'mixed') {
?>
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); ?></span>
<?php
      } else {
?>
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL')); ?></span>

<?php
    }
?>
<!--  - End //-->
  </div>

</form>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Kind regards,

 

Dennis

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...