Hi again,
OK I managed to get mine the way I wanted. Tell me if it's what you wanted to do, or if anyone else is interested in this.
Motivation: My CC charges me a flat monthly fee (+ percentage of course) for every https:// site I ask him to approve. Since I have several stores, I would have to, pay him extra for each one.
Note: All my domains are sub-domains of the main domain. i.e.
www.domain.tld, store1.domain.tld, store2.domain.tld, etc.
Solution: Added some lines of code to checkout process to see if the transaction is originating from the main site. If not, remember which sub-domain it came from -> switch to the main site -> process -> switch back to the sub-domain.
If anyone is interested, it's generic code provided you use the main domain/sub-domain approach. I wouldn't want to do it any other way, since it would be a security risk if it worked for just any domain.
Here's the doctored header_php file for checkout_process. Comments welcome!
<?php
Code:
// Added by Dov Zamir on 6/4/2009 - saves the original sub-domain and goes to the main site for processing
if (isset($_SESSION['been_here'])) {
$server_name=$_SERVER['SERVER_NAME'];
$len=(strlen($server_name));
$domain=substr($server_name,strpos($server_name,'.'),$len);
$origin='www'.$domain;
if ($server_name != $origin) {
zen_redirect('https://www'.$domain.'/index.php?main_page=checkout_process');
$_SESSION['been_here']=1;
}
}
// End of addition
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_PROCESS');
require(DIR_WS_MODULES . zen_get_module_directory('checkout_process.php'));
// load the after_process function from the payment modules
$payment_modules->after_process();
$_SESSION['cart']->reset(true);
// unregister session variables used during checkout
unset($_SESSION['sendto']);
unset($_SESSION['billto']);
unset($_SESSION['shipping']);
unset($_SESSION['payment']);
unset($_SESSION['comments']);
$order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM
// This should be before the zen_redirect:
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_PROCESS');
Code:
// Changed by Dov Zamir - 6/4/2009 - Return to original site after processing.
if (isset($_SESSION['been_here'])) {
unset($_SESSION['been_here']);
zen_redirect('https://'.$server_name.'/index.php?main_page=checkout_success');
}
else {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL')); }
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Bookmarks