protected function restoreOrderAction () { echo isc_json_encode($this->restoreOrderActionHandler(Interspire_Request::post('orderId', 0))); exit; }
private function SaveUpdatedCheckoutSettings() { // Firstly we will delete *all* existing module variables for shippers. This way, if one // was previously configured and unchecked then its old variables wont be saved and it // wont be marked as configured even when it's not $GLOBALS['ISC_CLASS_DB']->DeleteQuery('module_vars', "WHERE modulename like 'checkout_%'"); if (!isset($_POST['checkoutproviders'])) { $_POST['checkoutproviders'] = array(); } // If they've selected to use the built in provider, override any other selections // coming in from the request if(GetConfig('EnableBuiltInGateway') && $_POST['builtInGateway'] == 1) { $_POST['checkoutproviders'] = array( 'checkout_'.GetConfig('BuiltInGateway') ); $_POST['checkout_'.GetConfig('BuiltInGateway')] = $_POST['builtin']; } $enabledStack = array(); $messages = array(); // Can the selected payment modules be enabled? foreach ($_POST['checkoutproviders'] as $provider) { GetModuleById('checkout', $module, $provider); if (is_object($module)) { // Is this checkout provider supported on this server? if($module->IsSupported() == false) { $errors = $module->GetErrors(); foreach($errors as $error) { FlashMessage($error, MSG_ERROR); } continue; } // Otherwise, this checkout provider is fine, so add it to the stack of enabled $enabledStack[] = $provider; } } // A list of the checkout modules we've just enabled $justEnabled = array_diff($enabledStack, explode(',', GetConfig('CheckoutMethods'))); $checkoutproviders = implode(",", $enabledStack); $GLOBALS['ISC_NEW_CFG']['CheckoutMethods'] = $checkoutproviders; // Save the order settings they specified too if ($_POST['updateinventory'] == 1) { $GLOBALS['ISC_NEW_CFG']['UpdateInventoryLevels'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['UpdateInventoryLevels'] = 0; } $GLOBALS['ISC_NEW_CFG']['UpdateInventoryOnOrderEdit'] = (int)Interspire_Request::post('UpdateInventoryOnOrderEdit', 0); $GLOBALS['ISC_NEW_CFG']['UpdateInventoryOnOrderDelete'] = (int)Interspire_Request::post('UpdateInventoryOnOrderDelete', 0); $GLOBALS['ISC_NEW_CFG']['DigitalOrderHandlingFee'] = 0; if(isset($_POST['EnableDigitalOrderHandlingFee'])) { $GLOBALS['ISC_NEW_CFG']['DigitalOrderHandlingFee'] = $_POST['DigitalOrderHandlingFee']; } // Save any selected notification statuses $GLOBALS['ISC_NEW_CFG']['OrderStatusNotifications'] = ''; if (isset($_POST['orderstatusemails']) && is_array($_POST['orderstatusemails'])) { $GLOBALS['ISC_NEW_CFG']['OrderStatusNotifications'] = implode(",", array_map("intval", $_POST['orderstatusemails'])); } if($_POST['CheckoutType'] == 'single') { $GLOBALS['ISC_NEW_CFG']['CheckoutType'] = 'single'; } else { $GLOBALS['ISC_NEW_CFG']['CheckoutType'] = 'multipage'; } if(isset($_POST['EnableOrderComments'])) { $GLOBALS['ISC_NEW_CFG']['EnableOrderComments'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['EnableOrderComments'] = 0; } if(isset($_POST['EnableOrderTermsAndConditions']) && isset($_POST['OrderTermsAndConditionsType'])) { if($_POST['OrderTermsAndConditionsType'] == 'link') { if(trim($_POST['OrderTermsAndConditionsLink']) == '' || trim($_POST['OrderTermsAndConditionsLink']) == "http://") { FlashMessage(GetLang('EnterTermsAndConditionsLink'), MSG_ERROR); } else { $GLOBALS['ISC_NEW_CFG']['OrderTermsAndConditionsLink'] = $_POST['OrderTermsAndConditionsLink']; } } else { if(trim($_POST['OrderTermsAndConditionsTextarea']) == '') { FlashMessage(GetLang('EnterTermsAndConditions'), MSG_ERROR); } else { $GLOBALS['ISC_NEW_CFG']['OrderTermsAndConditions'] = $_POST['OrderTermsAndConditionsTextarea']; } } $GLOBALS['ISC_NEW_CFG']['OrderTermsAndConditionsType'] = $_POST['OrderTermsAndConditionsType']; $GLOBALS['ISC_NEW_CFG']['EnableOrderTermsAndConditions'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['EnableOrderTermsAndConditions'] = 0; $GLOBALS['ISC_NEW_CFG']['OrderTermsAndConditions'] = ""; } if(isset($_POST['MultipleShippingAddresses'])) { $GLOBALS['ISC_NEW_CFG']['MultipleShippingAddresses'] = 1; } else { $GLOBALS['ISC_NEW_CFG']['MultipleShippingAddresses'] = 0; } $GLOBALS['ISC_NEW_CFG']['GuestCheckoutEnabled'] = 0; $GLOBALS['ISC_NEW_CFG']['GuestCheckoutCreateAccounts'] = 0; if(isset($_POST['GuestCheckoutEnabled'])) { $GLOBALS['ISC_NEW_CFG']['GuestCheckoutEnabled'] = 1; if(isset($_POST['GuestCheckoutCreateAccounts'])) { $GLOBALS['ISC_NEW_CFG']['GuestCheckoutCreateAccounts'] = 1; } } $settings = GetClass('ISC_ADMIN_SETTINGS'); $messages = array(); if ($settings->CommitSettings($messages)) { // Save the module settings to the module_vars table // First, delete all existing entries foreach($messages as $message => $status) { FlashMessage($message, $status); } // Delete existing module configuration $GLOBALS['ISC_CLASS_DB']->DeleteQuery('module_vars', "WHERE modulename LIKE 'checkout\_%'"); // Now get all checkout variables (they are in an array from $_POST) foreach($enabledStack as $module_id) { $vars = array(); if(isset($_POST[$module_id])) { $vars = $_POST[$module_id]; } GetModuleById('checkout', $module, $module_id); if (!$module->SaveModuleSettings($vars)) { $errors = $module->GetErrors(); foreach($errors as $error) { FlashMessage($error, MSG_ERROR); } } } // Rebuild the cache of the checkout module variables $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateCheckoutModuleVars(); if ($GLOBALS['ISC_CLASS_DB']->Error() == "") { // Log this action $GLOBALS['ISC_CLASS_LOG']->LogAdminAction(); // Just configured tax $redirectUrl = 'index.php?ToDo=viewCheckoutSettings'; $message = GetLang('CheckoutSettingsSavedSuccessfully'); // If we haven't enabled anything new, we've just saved settings. So mark as complete if(!in_array('paymentMethods', GetConfig('GettingStartedCompleted')) && empty($justEnabled)) { GetClass('ISC_ADMIN_ENGINE')->MarkGettingStartedComplete('paymentMethods'); $redirectUrl = 'index.php'; $message = GetLang('CheckoutSettingsSavedNoConfigure'); } FlashMessage($message, MSG_SUCCESS, $redirectUrl); } else { FlashMessage(GetLang('CheckoutSettingsNotSaved'), MSG_ERROR, 'index.php?ToDo=viewCheckoutSettings'); } } else { FlashMessage(GetLang('CheckoutSettingsNotSaved'), MSG_ERROR, 'index.php?ToDo=viewCheckoutSettings'); } }