Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions catalog/checkout_confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

// load the selected shipping module
require(DIR_WS_CLASSES . 'shipping.php');

$shipping_modules = new shipping($shipping);

require(DIR_WS_CLASSES . 'order_total.php');
Expand Down
1 change: 1 addition & 0 deletions catalog/checkout_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@

// load the after_process function from the payment modules
$payment_modules->after_process();
$shipping_modules->after_process();

$_SESSION['cart']->reset(true);

Expand Down
17 changes: 14 additions & 3 deletions catalog/checkout_shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,21 @@
if (isset($quote['error'])) {
unset($_SESSION['shipping']);
} else {
if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
$methods = $quote[0]['methods'];
$selectedMethod = null;

// find selected method
foreach ($methods as $key => $methodObj) {
if ($methodObj['id'] == $method) {
$selectedMethod = $methodObj;
break;
}
}
if ( (isset($selectedMethod['title'])) && (isset($selectedMethod['cost'])) ) {
$shipping = array('id' => $shipping,
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);
'title' => (($free_shipping == true) ? $selectedMethod['title'] : $quote[0]['module'] . ' (' . $selectedMethod['title'] . ')'),
'cost' => $selectedMethod['cost'],
'info' => $selectedMethod['info']);

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
Expand Down
20 changes: 20 additions & 0 deletions catalog/includes/classes/shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function shipping($module = '') {

if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
$include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
$this->selected_module = $module;
} else {
foreach ($this->modules as $value) {
$class = substr($value, 0, strrpos($value, '.'));
Expand Down Expand Up @@ -84,6 +85,25 @@ function quote($method = '', $module = '') {
return $quotes_array;
}

function after_process()
{
global $order;

if(empty($this->selected_module)) {
// TODO: handle error here
return;
}

// obtain selected module name and method id
$id_arr = explode('_', $this->selected_module['id']);
$module = $GLOBALS[$id_arr[0]];

// check is for backwards compatibility
if (!empty($module) && method_exists($module, 'after_process')) {
$module->after_process();
}
}

function cheapest() {
if (is_array($this->modules)) {
$rates = array();
Expand Down