Forums / Contribution-Writing Guidelines / Fast and Easy Checkout

Fast and Easy Checkout

Locked
Results 1 to 20 of 29
This thread is locked. New replies are disabled.
21 Sep 2007, 22:40
#1
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Fast and Easy Checkout

Here is the header file for checkout

I am having an issue where the shipping selection is not passed to the shipment confirmation page:

[PHP] $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_PAYMENT');

// if there is nothing in the customers cart, redirect them to the shopping cart page
if ($_SESSION['cart']->count_contents() <= 0) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}
// if the customer is not logged on, redirect them to the login page
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
} else {
// validate customer
if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
}
// avoid hack attempts during the checkout procedure by checking the internal cartID
if (isset($_SESSION['cart']->cartID) && $_SESSION['cartID']) {
if ($_SESSION['cart']->cartID != $_SESSION['cartID']) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
}
// get coupon code
if ($_SESSION['cc_id']) {
$discount_coupon_query = "SELECT coupon_code
FROM " . TABLE_COUPONS . "
WHERE coupon_id = :couponID";

$discount_coupon_query = $db->bindVars($discount_coupon_query, ':couponID', $_SESSION['cc_id'], 'integer');
$discount_coupon = $db->Execute($discount_coupon_query);
}
// if no billing destination address was selected, use the customers own address as default
if (!$_SESSION['billto']) {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected billing address
$check_address_query = "SELECT count(*) AS total FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";
$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['billto'], 'integer');
$check_address = $db->Execute($check_address_query);
if ($check_address->fields['total'] != '1') {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
$_SESSION['payment'] = '';
}
}
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();
// $_SESSION['comments'] = '';
$comments = $_SESSION['comments'];
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
// load all enabled payment modules
require(DIR_WS_CLASSES . 'payment.php');
$payment_modules = new payment;
$flagOnSubmit = sizeof($payment_modules->selection());
// Load the selected shipping module(needed to calculate tax correctly)
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping($_SESSION['shipping']);
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) {
$messageStack->add('checkout_payment', $error['error'], 'error');
}
$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2);
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_PAYMENT');
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');
require_once(DIR_WS_CLASSES . 'http_client.php');
// Validate Cart for checkout
$_SESSION['valid_to_checkout'] = true;
$_SESSION['cart']->get_products(true);
if ($_SESSION['valid_to_checkout'] == false) {
$messageStack->add('header', ERROR_CART_UPDATE, 'error');
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}
// Stock Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
}
// if no shipping destination address was selected, use the customers own address as default
if (!$_SESSION['sendto']) {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected shipping address
$check_address_query = "SELECT count(*) AS total
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";
$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer');
$check_address = $db->Execute($check_address_query);
if ($check_address->fields['total'] != '1') {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
$_SESSION['shipping'] = '';
}
}
$order = new order;
// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
$_SESSION['cartID'] = $_SESSION['cart']->cartID;
// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
$_SESSION['shipping'] = 'free_free';
$_SESSION['shipping']['title'] = 'free_free';
$_SESSION['sendto'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
// load all enabled shipping modules
$shipping_modules = new shipping;
if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
$pass = false;
switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if ($order->delivery['country_id'] == STORE_COUNTRY) {
$pass = true;
}
break;
case 'international':
if ($order->delivery['country_id'] != STORE_COUNTRY) {
$pass = true;
}
break;
case 'both':
$pass = true;
break;
}
$free_shipping = false;
if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
$free_shipping = true;
}
} else {
$free_shipping = false;
}
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
if (isset($_SESSION['comments'])) {
$comments = $_SESSION['comments'];
}

// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
$comments = $_SESSION['comments'];
if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
$_SESSION['shipping'] = $_POST['shipping'];
list($module, $method) = explode('_', $_SESSION['shipping']);
if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
if ($_SESSION['shipping'] == 'free_free')
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
}
} else {
$_SESSION['shipping'] = false;
}
}
} else {
$_SESSION['shipping'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
}
// get all available shipping quotes
$quotes = $shipping_modules->quote();
// Should address-edit button be offered?
$displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2);
// if shipping-edit button should be overridden, do so
$editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL');
if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
$theLink = $$_SESSION['payment']->alterShippingEditButton();
if ($theLink) {
$editShippingButtonLink = $theLink;
$displayAddressEdit = true;
}
}
$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2);
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SHIPPING');[/PHP]
22 Sep 2007, 20:59
#2
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

includes/modules/pages/checkout/header_php.php:

[php]<?php

require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;

require(DIR_WS_CLASSES . 'payment.php');
$payment_modules = new payment($payment);

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

require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping;

require_once(DIR_WS_CLASSES . 'http_client.php');

// if there is nothing in the customers cart, redirect them to the shopping cart page
if ($_SESSION['cart']->count_contents() <= 0) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}

// if the customer is not logged on, redirect them to the login page
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
} else {
// validate customer
if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
if (isset($_SESSION['cart']->cartID) && $_SESSION['cartID']) {
if ($_SESSION['cart']->cartID != $_SESSION['cartID']) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
}

// Validate Cart for checkout
$_SESSION['valid_to_checkout'] = true;
$_SESSION['cart']->get_products(true);
if ($_SESSION['valid_to_checkout'] == false) {
$messageStack->add('header', ERROR_CART_UPDATE, 'error');
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}

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

// if no billing destination address was selected, use the customers own address as default
if (!$_SESSION['billto']) {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected billing address
$check_address_query = "SELECT count(*) AS total FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";

$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['billto'], 'integer');
$check_address = $db->Execute($check_address_query);

if ($check_address->fields['total'] != '1') {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
$_SESSION['payment'] = '';
}
}

// if no shipping destination address was selected, use the customers own address as default
if (!$_SESSION['sendto']) {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected shipping address
$check_address_query = "SELECT count(*) AS total
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";

$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer');
$check_address = $db->Execute($check_address_query);

if ($check_address->fields['total'] != '1') {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
$_SESSION['shipping'] = '';
}
}

$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();

$order_total_modules = new order_total;
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();

// load all enabled shipping modules
if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
$pass = false;

switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if ($order->delivery['country_id'] == STORE_COUNTRY) {
$pass = true;
}
break;
case 'international':
if ($order->delivery['country_id'] != STORE_COUNTRY) {
$pass = true;
}
break;
case 'both':
$pass = true;
break;
}

$free_shipping = false;
if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
$free_shipping = true;
}
} else {
$free_shipping = false;
}

if (isset($_SESSION['comments'])) {
$comments = $_SESSION['comments'];
}

// process the selected shipping method
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
$comments = $_SESSION['comments'];

if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
$_SESSION['shipping'] = $_POST['shipping'];

list($module, $method) = explode('_', $_SESSION['shipping']);
if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
if ($_SESSION['shipping'] == 'free_free') {
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);

zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
}
}
} else {
$_SESSION['shipping'] = false;
}
}
} else {
$_SESSION['shipping'] = false;

zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
}
}

// get all available shipping quotes
$quotes = $shipping_modules->quote();

// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) $_SESSION['shipping'] = $shipping_modules->cheapest();


// Should address-edit button be offered?
$displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2);

// if shipping-edit button should be overridden, do so
$editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL');
if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
$theLink = $$_SESSION['payment']->alterShippingEditButton();
if ($theLink) {
$editShippingButtonLink = $theLink;
$displayAddressEdit = true;
}
}

$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) {
$messageStack->add('checkout_payment', $error['error'], 'error');
}

$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
?>[/php]

includes/templates/YOUR TEMPLATE/templates/tpl_checkout_default.php:

[PHP]<div class="centerColumn" id="checkout">

<?php echo zen_draw_form('checkout_payment', zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', ($flagOnSubmit ? 'onsubmit="return check_form();"' : '')); ?>

<h1 id="checkoutPaymentHeading"><?php echo HEADING_TITLE_PAYMENT; ?></h1>

<?php
$selection = $order_total_modules->credit_selection();
if (sizeof($selection)>0) {
for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
if ($_GET['credit_class_error_code'] == $selection[$i]['id']) {
?>
<div class="messageStackError"><?php echo zen_output_string_protected($_GET['credit_class_error']); ?></div>

<?php
}
for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
<fieldset>
<legend><?php echo $selection[$i]['module']; ?></legend>
<?php echo $selection[$i]['redeem_instructions']; ?>
<div class="gvBal larger"><?php echo $selection[$i]['checkbox']; ?></div>
<label class="inputLabel"<?php echo ($selection[$i]['fields'][$j]['tag']) ? ' for="'.$selection[$i]['fields'][$j]['tag'].'"': ''; ?>><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
<?php echo $selection[$i]['fields'][$j]['field']; ?>
</fieldset>
<?php
}
}
?>

<?php
}
?>

<br>
<?php
if (DISPLAY_PRIVACY_CONDITIONS == 'true') {
?>
<fieldset>
<legend><?php echo TABLE_HEADING_PRIVACY_CONDITIONS; ?></legend>
<div class="information"><?php echo TEXT_PRIVACY_CONDITIONS_DESCRIPTION;?></div>
<?php echo zen_draw_checkbox_field('privacy_conditions', '1', false, 'id="privacy"');?>
<label clas="checkboxLabel" for="privacy"><?php echo TEXT_PRIVACY_CONDITIONS_CONFIRM;?></label>
</fieldset>
<?php
}
?>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
if (!$payment_modules->in_special_checkout()) {
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<!--<br class="clearBoth" />-->
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
}
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
if (!$payment_modules->in_special_checkout()) {
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<fieldset>
<legend><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></legend>

<?php
if (SHOW_ACCEPTED_CREDIT_CARDS != '0') {
?>

<?php
if (SHOW_ACCEPTED_CREDIT_CARDS == '1') {
echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled();
}
if (SHOW_ACCEPTED_CREDIT_CARDS == '2') {
echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled('IMAGE_');
}
?>
<br class="clearBoth" />
<?php } ?>

<?php
$selection = $payment_modules->selection();

if (sizeof($selection) > 1) {
?>
<p class="important"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p>
<?php
} elseif (sizeof($selection) == 0) {
?>
<p class="important"><?php echo TEXT_NO_PAYMENT_OPTIONS_AVAILABLE; ?></p>

<?php
}
?>

<?php
$radio_buttons = 0;
for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
<?php
if (sizeof($selection) > 1) {
if (empty($selection[$i]['noradio'])) {
?>
<?php echo zen_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $_SESSION['payment'] ? true : false), 'id="pmt-'.$selection[$i]['id'].'"'); ?>
<?php } ?>
<?php
} else {

?>
<?php echo zen_draw_hidden_field('payment', $selection[$i]['id']); ?>
<?php
}
?>
<label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>

<?php
if (defined('MODULE_ORDER_TOTAL_COD_STATUS') && MODULE_ORDER_TOTAL_COD_STATUS == 'true' and $selection[$i]['id'] == 'cod') {
?>
<div class="alert"><?php echo TEXT_INFO_COD_FEES; ?></div>
<?php
} else {
// echo 'WRONG ' . $selection[$i]['id'];
?>
<?php
}
?>
<br class="clearBoth" />

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

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

<div class="ccinfo">
<?php
for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
?>
<label <?php echo (isset($selection[$i]['fields'][$j]['tag']) ? 'for="'.$selection[$i]['fields'][$j]['tag'] . '" ' : ''); ?>class="inputLabelPayment"><?php echo $selection[$i]['fields'][$j]['title']; ?></label><?php echo $selection[$i]['fields'][$j]['field']; ?>
<br class="clearBoth" />
<?php
}
?>
</div>
<br class="clearBoth" />
<?php
}
$radio_buttons++;
?>
<br class="clearBoth" />
<?php
}
?>

</fieldset>
<?php // ** BEGIN PAYPAL EXPRESS CHECKOUT **
} else {
?><input type="hidden" name="payment" value="<?php echo $_SESSION['payment']; ?>" /><?php
}
// ** END PAYPAL EXPRESS CHECKOUT ** ?>
<!-- EOF PAYMENT -->
<br class="clearBoth" />
<!--BOF SHIPPING-->
<h1 id="checkoutShippingHeading"><?php echo HEADING_TITLE_SHIPPING; ?></h1>
<fieldset id="checkoutShipping">
<legend><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></legend>
<?php if ($messageStack->size('checkout_shipping') > 0) echo $messageStack->output('checkout_shipping'); ?>

<div id="checkoutShipto" class="floatingBox back">
<?php if ($displayAddressEdit) { ?>
<div class="buttonRow forward"><?php echo '<a href="' . $editShippingButtonLink . '">' . zen_image_button(BUTTON_IMAGE_CHANGE_ADDRESS, BUTTON_CHANGE_ADDRESS_ALT) . '</a>'; ?></div>
<?php } ?>
<address class=""><?php echo zen_address_label($_SESSION['customer_id'], $_SESSION['sendto'], true, ' ', '<br />'); ?></address>
</div>
<div class="floatingBox important forward"><?php echo TEXT_CHOOSE_SHIPPING_DESTINATION; ?></div>
</fieldset>

<fieldset id="checkoutShippingMethods">
<legend><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></legend>
<?php
if (zen_count_shipping_modules() > 0) {
?>

<?php
if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {
?>

<div id="checkoutShippingContentChoose" class="important"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></div>

<?php
} elseif ($free_shipping == false) {
?>
<div id="checkoutShippingContentChoose" class="important"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></div>

<?php
}
?>
<?php
if ($free_shipping == true) {
?>
<div id="freeShip" class="important" ><?php echo FREE_SHIPPING_TITLE; ?> <?php echo $quotes[$i]['icon']; ?></div>
<div id="defaultSelected"><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . zen_draw_hidden_field('shipping', 'free_free'); ?></div>

<?php
} else {
$radio_buttons = 0;
for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
?>
<fieldset>
<legend><?php echo $quotes[$i]['module']; ?> <?php if (isset($quotes[$i]['icon']) && zen_not_null($quotes[$i]['icon'])) { echo $quotes[$i]['icon']; } ?></legend>

<?php
if (isset($quotes[$i]['error'])) {
?>
<div><?php echo $quotes[$i]['error']; ?></div>
<?php
} else {
for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
// set the radio button to be checked if it is the method chosen
$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $_SESSION['shipping']['id']) ? true : false);

if ( ($checked == true) || ($n == 1 && $n2 == 1) ) {
//echo ' <div id="defaultSelected" class="moduleRowSelected">' . "\n";
//} else {
//echo ' <div class="moduleRow">' . "\n";
}
?>
<?php
if ( ($n > 1) || ($n2 > 1) ) {
?>
<div class="important forward"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?></div>
<?php
} else {
?>
<div class="important forward"><?php echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . zen_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></div>
<?php
}
?>

<?php echo zen_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'id="ship-'.$quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id'].'"'); ?>
<label for="ship-<?php echo $quotes[$i]['id'] . '-' . $quotes[$i]['methods'][$j]['id']; ?>" class="checkboxLabel" ><?php echo $quotes[$i]['methods'][$j]['title']; ?></label>
<!--</div>-->
<br class="clearBoth" />
<?php
$radio_buttons++;
}
}
?>

</fieldset>
<?php
}
}
?>

<?php
} else {
?>
<h2 id="checkoutShippingHeadingMethod"><?php echo TITLE_NO_SHIPPING_AVAILABLE; ?></h2>
<div id="checkoutShippingContentChoose" class="important"><?php echo TEXT_NO_SHIPPING_AVAILABLE; ?></div>
<?php
}
?>
</fieldset>
<!--EOF SHIPPING-->

<div class="buttonRow forward"><?php echo zen_draw_hidden_field('action', 'submit') . zen_image_submit(BUTTON_IMAGE_CONTINUE, BUTTON_CONTINUE_ALT); ?></div>
<div class="buttonRow back"><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '<br />' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></div>

</form>
</div>[/PHP]

The issue is that the shipping method selected during the shortened checkout process is not passed to checkout_confirmation. Payments are passed correctly.

http://www.numinix.com/1pagecheckout/ ignore the layout of the checkout page, it will be completed once I know all variables are being passed including showing the cart contents at the top.
23 Sep 2007, 06:23
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Fast and Easy Checkout

Your page will have to post back to itself in order to process the shipping selection.
23 Sep 2007, 21:33
#4
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

DrByte,

that works, but then doesn't go to the next page...

any more pointers are appreciated :cool:
23 Sep 2007, 22:01
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Fast and Easy Checkout

Just as each of the existing checkout pages does, you should do also. Once the data is validated, redirect to the next page.
23 Sep 2007, 22:20
#6
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

It appears to be this line in checkout_confirmation/header_php.php:

[PHP]
if ($messageStack->size('checkout_payment') > 0) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
[/PHP]

I chaged this to 'checkout'

Could you confirm what this does?
23 Sep 2007, 22:38
#7
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Just to clarify, this is what had to be done to the start and ends of the form to pass the required information:

[PHP]<?php echo zen_draw_form('checkout', zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'post', ($flagOnSubmit ? 'onsubmit="return check_form();"' : '')) . zen_draw_hidden_field('action' , 'process'); ?>
[/PHP]

[PHP]<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_CONTINUE_CHECKOUT, BUTTON_CONTINUE_ALT, 'onclick="submitFunction('.zen_user_has_gv_account($_SESSION['customer_id']).','.$order->info['total'].')"'); ?></div>[/PHP]

Was the change I made to checkout_confirmation's header appropriate (from last post)?
24 Sep 2007, 00:12
#8
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Turns out it's not completely working.

Now, the payment information is not passed.

If I post to checkout_confirmation the payment information is included, but the shipping information is not.

If I post to self, the payment information isn't included, but the shipping information is.

So, I need to post to self and then to checkout_confirmation? I've spent too much time on this lol...
24 Sep 2007, 03:58
#9
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Got around the double actions by giving $_SESSION['payment'] = $_POST['payment']

Comments do not pass though using this...
24 Sep 2007, 04:20
#10
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Script is completed, for now. Now I am going to give the option of removing the checkout_confirmation page....
24 Sep 2007, 06:16
#11
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

First, I need to update the page on a shipping selection without redirecting to another page. I've started another thread specific to this using JavaScript:

http://www.zen-cart.com/forum/showthread.php?t=76152
25 Sep 2007, 20:34
#12
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

My latest code to bypass the checkout_confirmation page has the following errors:

[B]Warning: reset() [function.reset]: Passed variable is not an array or object in /home/public_html/1pagecheckout/includes/modules/order_total/ot_group_pricing.php on line 77
[/B]


[B]Warning: Variable passed to each() is not an array or object in /home/public_html/1pagecheckout/includes/modules/order_total/ot_group_pricing.php on line 78[/B]

[B]Warning: reset() [function.reset]: Passed variable is not an array or object in /home/public_html/1pagecheckout/includes/modules/order_total/ot_group_pricing.php on line 77[/B]

[B]Warning: Variable passed to each() is not an array or object in /home/public_html/1pagecheckout/includes/modules/order_total/ot_group_pricing.php on line 78[/B]

[B]Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/1pagecheckout/includes/modules/order_total/ot_group_pricing.php:77) in /home/public_html/1pagecheckout/includes/functions/functions_general.php on line 44[/B]


Here is the code from the header_php.php file:

[php]<?php
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_PAYMENT');
require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();

require(DIR_WS_CLASSES . 'order.php');
$order = new order;
require(DIR_WS_CLASSES . 'payment.php');
$payment_modules = new payment($payment);
$flagOnSubmit = sizeof($payment_modules->selection());
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping;

require_once(DIR_WS_CLASSES . 'http_client.php');

// if there is nothing in the customers cart, redirect them to the shopping cart page
if ($_SESSION['cart']->count_contents() <= 0) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}

// if the customer is not logged on, redirect them to the login page
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
} else {
// validate customer
if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
if (isset($_SESSION['cart']->cartID) && $_SESSION['cartID']) {
if ($_SESSION['cart']->cartID != $_SESSION['cartID']) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
}

// Validate Cart for checkout
$_SESSION['valid_to_checkout'] = true;
$_SESSION['cart']->get_products(true);
if ($_SESSION['valid_to_checkout'] == false) {
$messageStack->add('header', ERROR_CART_UPDATE, 'error');
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}
// Stock Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
}
// if no billing destination address was selected, use the customers own address as default
if (!$_SESSION['billto']) {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected billing address
$check_address_query = "SELECT count(*) AS total FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";
$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['billto'], 'integer');
$check_address = $db->Execute($check_address_query);
if ($check_address->fields['total'] != '1') {
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
$_SESSION['payment'] = '';
}
}

// if no shipping destination address was selected, use the customers own address as default
if (!$_SESSION['sendto']) {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
} else {
// verify the selected shipping address
$check_address_query = "SELECT count(*) AS total
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :customersID
AND address_book_id = :addressBookID";
$check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
$check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer');
$check_address = $db->Execute($check_address_query);
if ($check_address->fields['total'] != '1') {
$_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
$_SESSION['shipping'] = '';
}
}

$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();

// load all enabled shipping modules
if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
$pass = false;
switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if ($order->delivery['country_id'] == STORE_COUNTRY) {
$pass = true;
}
break;
case 'international':
if ($order->delivery['country_id'] != STORE_COUNTRY) {
$pass = true;
}
break;
case 'both':
$pass = true;
break;
}
$free_shipping = false;
if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
$free_shipping = true;
}
} else {
$free_shipping = false;
}

// get all available shipping quotes
$quotes = $shipping_modules->quote();
// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) $_SESSION['shipping'] = $shipping_modules->cheapest();
// Should address-edit button be offered?
$displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2);
// if shipping-edit button should be overridden, do so
$editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL');
if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
$theLink = $$_SESSION['payment']->alterShippingEditButton();
if ($theLink) {
$editShippingButtonLink = $theLink;
$displayAddressEdit = true;
}
}
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) {
$messageStack->add('checkout_payment', $error['error'], 'error');
}


// Load the selected shipping module(needed to calculate tax correctly)
$shipping_modules = new shipping($_SESSION['shipping']);

$comments = $_SESSION['comments']; // process comments

if (isset($_POST['payment'])) $_SESSION['payment'] = $_POST['payment'];
if (isset($_POST['comments'])) $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);

switch ($_GET['action']) {
case 'process':
$form_action_url = zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL');
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
$comments = $_SESSION['comments'];

if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
$_SESSION['shipping'] = $_POST['shipping']; // process shipping
list($module, $method) = explode('_', $_SESSION['shipping']);
if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
if ($_SESSION['shipping'] == 'free_free') {
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
}
}
} else {
$_SESSION['shipping'] = false;
}
}
} else {
$_SESSION['shipping'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
}
break;
case 'update':
$form_action_url = zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL');
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
$comments = $_SESSION['comments'];

if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
$_SESSION['shipping'] = $_POST['shipping']; // process shipping
list($module, $method) = explode('_', $_SESSION['shipping']);
if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
if ($_SESSION['shipping'] == 'free_free') {
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);

zen_redirect(zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL'));
}
}
} else {
$_SESSION['shipping'] = false;
}
}
} else {
$_SESSION['shipping'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL'));
}
break;
case 'submit':
if (isset($$_SESSION['payment']->form_action_url)) {
$form_action_url = $$_SESSION['payment']->form_action_url;
} else {
$form_action_url = zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
}
// process comments
if (zen_not_null($_POST['comments'])) {
$_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
}
$comments = $_SESSION['comments'];
// process shipping
if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
$_SESSION['shipping'] = $_POST['shipping']; // process shipping
list($module, $method) = explode('_', $_SESSION['shipping']);
if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
if ($_SESSION['shipping'] == 'free_free') {
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);
if (isset($$_SESSION['payment']->form_action_url)) {
zen_redirect($$_SESSION['payment']->form_action_url);
} else {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'));
}
}
}
} else {
$_SESSION['shipping'] = false;
}
}
} else {
$_SESSION['shipping'] = false;
if (isset($$_SESSION['payment']->form_action_url)) {
zen_redirect($$_SESSION['payment']->form_action_url);
} else {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'));
}
}
break;
case 'null':
$form_action_url = zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL');
break;
default:
$form_action_url = zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL');
zen_redirect(zen_href_link(FILENAME_CHECKOUT, 'action=null', 'SSL'));
break;
}

$breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT, '', 'SSL'));

$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SHIPPING');
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_PAYMENT');

if (FEC_ONE_PAGE == 'true') {
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION');
// update customers_referral with $_SESSION['gv_id']
if ($_SESSION['cc_id']) {
$discount_coupon_query = "SELECT coupon_code
FROM " . TABLE_COUPONS . "
WHERE coupon_id = :couponID";

$discount_coupon_query = $db->bindVars($discount_coupon_query, ':couponID', $_SESSION['cc_id'], 'integer');
$discount_coupon = $db->Execute($discount_coupon_query);
$customers_referral_query = "SELECT customers_referral
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";
$customers_referral_query = $db->bindVars($customers_referral_query, ':customersID', $_SESSION['customer_id'], 'integer');
$customers_referral = $db->Execute($customers_referral_query);
// only use discount coupon if set by coupon
if ($customers_referral->fields['customers_referral'] == '' and CUSTOMERS_REFERRAL_STATUS == 1) {
$sql = "UPDATE " . TABLE_CUSTOMERS . "
SET customers_referral = :customersReferral
WHERE customers_id = :customersID";
$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$sql = $db->bindVars($sql, ':customersReferral', $discount_coupon->fields['coupon_code'], 'string');
$db->Execute($sql);
} else {
// do not update referral was added before
}
}
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION');
}
?>[/php]
26 Sep 2007, 01:12
#13
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Script is ready for bug testing:

http://www.numinix.com/1pagecheckout/

The script is called Fast and Easy Checkout for Zen Cart and includes either a 2 step process (shipping/payment + confirmation), or the option to have a one page checkout without the confirmation page.

The script updates the order_total on the same page using a refresh function so that confirmation is not needed. It also auto refreshes if you enter a discount coupon. The script also will not validate if you forget to choose a payment method or select the terms and conditions checkbox and an error message is printed at the top of the form.

I've tested it in IE7 and FF without errors.
26 Sep 2007, 01:19
#14
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Fast and Easy Checkout

Does it touch any core code numinix?
26 Sep 2007, 01:23
#15
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

It only overwrites one file, filenames.php and it just defines FILENAME_CHECKOUT_SHIPPING and FILENAME_CHECKOUT_PAYMENT as 'checkout'

I'm going to see if there is a way to override the filenames.php page. I'd also like to be able to do some conditional statements in this page so that the module can be turned on or off as a whole by putting the definitions back to normal.

At the moment, I haven't tried or figured a way to do this...
26 Sep 2007, 01:25
#16
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Fast and Easy Checkout

One of the possible ways, is to define it in table configuration, the constants will be available throughout the site.
26 Sep 2007, 01:31
#17
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Yes, but then when I placed that conditional statement in filenames.php I think I received an error. I'm going to try it again now and post back.
26 Sep 2007, 01:35
#18
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

I remember the issue, filenames.php doesn't have require('includes/application_top.php');
26 Sep 2007, 02:18
#19
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Fast and Easy Checkout

I see what you mean, not really anything serious though. We can try to define it at the init_loaders but I think it's not necessary, just 2 small changes in filesname.php. I hope DrByte can suggest something tho.

Good job by the way. I'll check this out at the end of this week and let you know if it works out okie. Which payment method did you check with this by the way? I'm currently using Paypal, Linkpoint, check/money order.
26 Sep 2007, 04:28
#20
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Posts:
1,562
Plugin Contributions:
47

Re: Fast and Easy Checkout

Only with PayPal, it uses the same process to redirect to the payment processors so I doubt there will be any issues.