Jump to content

vieworder / ship date


jka

Recommended Posts

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. 

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...