jka Posted July 9, 2017 Author Share Posted July 9, 2017 Hello BSmither, Thanks for pointing me in the right direction. It was due to the IF condition, it was not setting the $delivery. I added another condition and I can now see Ship Date in the Order Page. It does not however display Shipping Method yet. Thats next. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 9, 2017 Share Posted July 9, 2017 What if condition? Quote Link to comment Share on other sites More sharing options...
jka Posted July 9, 2017 Author Share Posted July 9, 2017 Here is the code insert .... that works .. // Courier Tracking URLs if (!empty($order['ship_method'])) { // Load the module $method = str_replace(' ', '_', $order['ship_method']); $ship_class = CC_ROOT_DIR.'/modules/shipping/'.$method.'/'.'shipping.class.php'; if (file_exists($ship_class)) { include $ship_class; if (class_exists($method) && method_exists((string)$method, 'tracking')) { $shipping = new $method(false); $url = $shipping->tracking($order['ship_tracking']); $url = (empty($url) && filter_var($order['ship_tracking'], FILTER_VALIDATE_URL)) ? $order['ship_tracking'] : $url; $delivery = array( 'url' => $url, 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => (!empty($order['ship_date']) && $order['ship_date']!=='0000-00-00') ? formatDispatchDate($order['ship_date']) : '' ); } unset($ship_class); } else { $delivery = array( 'url' => filter_var($order['ship_tracking'], FILTER_VALIDATE_URL) ? $order['ship_tracking'] : '', 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => (!empty($order['ship_date']) && $order['ship_date']!=='0000-00-00') ? formatDispatchDate($order['ship_date']) : '' ); } if (empty($delivery['date'])) $delivery = array( 'method' => $order['ship_method'], 'product' => $order['ship_product'], 'tracking' => $order['ship_tracking'], 'date' => (!empty($order['ship_date']) && $order['ship_date']!=='0000-00-00') ? formatDispatchDate($order['ship_date']) : '' ); if (empty($delivery['date']) && empty($delivery['url']) && empty($delivery['tracking'])) $delivery = false; } else { $delivery = false; } $GLOBALS['smarty']->assign('DELIVERY', $delivery); Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 9, 2017 Share Posted July 9, 2017 The way I see this is that if the file $ship_class does not exist, then create $delivery with an admin-supplied 'url'. If $ship_class does exist, then only if a tracking() method exists in the shipping class, will $delivery get created. So, there is a path where $delivery may not get created - the $ship_class exists but does not have a tracking() method. However, earlier, your experiments showed that formatDispatchDate() was getting called. That only happens when $delivery is getting created - whether $ship_class exists or not. That is, unless your added code is where formatDispatchDate() was getting called. Quote Link to comment Share on other sites More sharing options...
jka Posted July 9, 2017 Author Share Posted July 9, 2017 BSmither, You are correct. I added a Debug line to get formatDispatchDate() to make sure the function was working while we were experimenting. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.