Zen Cart Logo
Forums / Basic Configuration / define_checkout_success

define_checkout_success

Locked

Views: 713

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
19 Nov 2010, 9:31 PM
#1
inestine avatar

inestine

New Zenner

Join Date:
Aug 2010
Posts:
51
Plugin Contributions:
0

define_checkout_success

I have two different products that I need to send customers to two different checkout_success pages. Is there a way for me to build an intermediary page (before "define_checkout_success") that will check the product_id and do one of two things depending on the result?

example:
I have two products:
1 is a digital magazine (digital meaning online version) that requires a username and password.
1 is a print magazine that requires nothing (we simply ship the magazine to them).

If the customer purchases the digital version, they should go to define_checkout_success_digital.php which I have already created. That page sends their username and password to our third party fulfillment company and returns a login page for the customer to login.

If it's a print product they should redirect to define_checkout_success_print. In which case I simply have some text that displays shipping times and what not.

If they purchase both they should still go to define_checkout_success_digital.

I'm sooo stuck.
Any ideas would be greatly appreciated.

Matt

btw - here is the code I tried. it's obviously not working:

<?PHP
 error_reporting(E_ALL);
  // ini_set('display_errors','On'); 
require 'db.inc.php';
$db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or
    die ('Unable to connect. Check your connection parameters.');

// Retrieve all the data from the "zen_cart.pm_customers" table
$result = mysql_query("SELECT * FROM zen_cart.pm_customers WHERE customers_id=" . $_SESSION['customer_id']) or
	die(mysql_error());  

// store the record of the "zen_cart.pm_customers" table into $row
$row = mysql_fetch_array($result);

$result = mysql_query("SELECT * FROM zen_cart.pm_products WHERE products_id=" . $row['products_id']) or
		die(mysql_error());  

if ($row['products_id'] == "4")
{
	//go to define_checkout_success_digital
	header ("location: "/digital/includes/languages/english/html_includes/classic/define_checkout_success_digital.php"");
}
else
{
	//else go to define_checkout_success_print
	header ("location: "/digital/includes/languages/english/html_includes/classic/define_checkout_success_print.php"");
}
?>
20 Nov 2010, 8:50 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: define_checkout_success

Instead of having two "checkout_success" pages, why not use the existing checkout_success and just customize the content based on what the customer has purchased?

Create a new file /includes/modules/pages/checkout_success/header_php_type.php:

  define('PRODUCT_ID_DIGITAL', '1'); // ... whatever the digital product's id is
  $products_type_query = "SELECT products_id
                     FROM " . TABLE_ORDERS_PRODUCTS . "
                     WHERE orders_id = :ordersID";
   
  $products_type_query = $db->bindVars($products_type_query, ':ordersID', $orders_id, 'integer');
  $products_type = $db->Execute($products_type_query);

  $product_type_digital = false;
  while (!$products_type->EOF) {
     if ($products_type->fields['products_id'] == PRODUCT_ID_DIGITAL) {
       $product_type_digital = true;
     }
     $products_type->MoveNext();
  }

Then, modify /includes/templates/YOURTEMPLATE/templates/tpl_checkout_success_default.php to check the $product_type_digital flag and format the page based on whether there is/isn't a digital product in the order.