Jump to content

vieworder / ship date


jka
 Share

Recommended Posts

This is what I have in content.receipt.php in my foundation based skin on 6.1.8:

{if $DELIVERY}
<hr>
<h4>{$LANG.common.delivery}</h4>
{if !empty($DELIVERY.date)}
<div class="row">
  <div class="small-6 medium-3 columns">{$LANG.orders.shipping_date}:</div>
  <div class="small-6 medium-9 columns">{$DELIVERY.date}</div>
</div>
{/if}
{if !empty($DELIVERY.url)}
<div class="row">
  <div class="small-6 medium-3 columns">{$LANG.orders.shipping_tracking}:</div>
  <div class="small-6 medium-9 columns"><a href="{$DELIVERY.url}" target="_blank">{$DELIVERY.method}{if !empty($DELIVERY.product)} ({$DELIVERY.product}){/if}</a></div>
</div>
{elseif !empty($DELIVERY.tracking)}
<div class="row">
  <div class="small-6 medium-3 columns">{$LANG.catalogue.delivery_method}:</div>
  <div class="small-6 medium-9 columns">{$DELIVERY.method}{if !empty($DELIVERY.product)} ({$DELIVERY.product}){/if}</div>
</div>
<div class="row">
  <div class="small-6 medium-3 columns">{$LANG.orders.shipping_tracking}:</div>
{* MODIFIED TO ACTUALLY LINK TO TRACKING CODE ON USPS *}
  <div class="small-6 medium-9 columns"><a href="https://tools.usps.com/go/TrackConfirmAction?tLabels={$DELIVERY.tracking}"  target="_blank">{$DELIVERY.tracking}</a></div>
</div>
{/if}
{/if}
<hr>
<h3>{$LANG.basket.order_summary}</h3>

 

Link to comment
Share on other sites

So, I did some checking. Everything is in the content.receipt.php.

Its checking for "if $Delivery" I have the Dispatch Date populated etc. However nothing shows up. What is the condition for $Delivery?? 

How is this flag set or how is this condition checked? 

 

Thanks.

Link to comment
Share on other sites

In the file /classes/cubecart.class.php, in the private function _orders(), near line 2325 (CC618), there is a test to determine if the order has a 'ship_method'. If so, the "ship_date" is made available to the template via the DELIVERY array.

If not, then DELIVERY is set to false (line 2360).

There is no code that benefits a 'ghost' (unregistered) customer.

So, please determine if this order has a shipping 'method' (the name of a shipping module), regardless of there being a shipping 'product' (First Class, Ground, etc).

 

Link to comment
Share on other sites

Hello bsmither, I knew you would come to the rescue. I use the following shipping modules and the combination work perfectly for us ...

Noodleman's Link Products To Specific Shipping Services

Noodlemans UPS Advanced Shipping Plugin

UPS Delivery

Free Shipping

The orders have a ship method or we also offer free shipping.

Here is a screenshot of the Delivery Tab under the order. The Shipping Method and Shipping Product were actually populated by the system when the order was placed. I added the Shipping Date. However they dont display in the Order details.

 

Screen Shot 2017-07-08 at 10.05.01 PM.png

Link to comment
Share on other sites

Please allow me to get something clear: is this data you are wanting to appear on the customer's Receipt screen, or the admin's Order Overview, General tab?

If for the customer, remind us what skin you are using.

At the bottom of the content.receipt.php template, add
{debug}
and save the change. (You may need to switch off CubeCart's caching for this test.)

Ask for a receipt page. CubeCart will return a page with some popup javascript attached. Let the popup happen. You can remove the {debug} now.

In the popup, scroll to the $DELIVERY variable and examine the value.

 

I would ask that you use an external database utility, such as phpMyAdmin, to examine the table CubeCart_order_summary. Find the target order number and look in the 'ship_method' column. Is there anything strange here? I am asking to eliminate any possibility that a plugin is managing this data, and has not been coded to show the dispatch date on the customer's Receipt page.

Link to comment
Share on other sites

Hello bsmither,

Did all of the above. (including checking db, looks good there). Here is the result from the DEBUG

$DELIVERY                                        

Origin: "Smarty object" 

Value

false

 

I checked and the Delivery Method, etc, date exists in the order. 

Edited by jka
Link to comment
Share on other sites

Somewhere in admin, Store Settings, you are able to specify the format of your dispatch date. What is that format?

We will need to add some diagnostic code to the file cubecart.class.php to find out why DELIVERY is being assigned false.

Link to comment
Share on other sites

Here is the date format attached 

Screen Shot 2017-07-08 at 11.54.12 PM.png

Here is a code snippet ... the question is that it is looking for /modules/shipping/'.$method.'/' shipping.class.php

 

// 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']) && empty($delivery['url']) && empty($delivery['tracking'])) {
                            $delivery = false;
                        }
                    } else {
                        $delivery = false;
                    }
                    $GLOBALS['smarty']->assign('DELIVERY', $delivery);

Link to comment
Share on other sites

BSmither,

One last point. I had a look at the order table using the phpadmin. 

The Ship_Method is very inconsistent for different orders (understandably). For UPS Expedited its says UPS_Delivery, whereas for UPS Ground its says UPS Delivery. In some cases, it also says NULL. 

However the sample order that i am trying to see has all the data properly in the table.

Link to comment
Share on other sites

You say there is a 'ship_method' for this order in the database. And that there is a 'ship_date' (probably looks like 2017-07-06).

Even if there is no shipping class at /modules/shipping/UPS_Delivery/shipping.class.php, the code should fall to the } else { just after unset($ship_class).

So, that leaves the first test that will result in a DELIVERY being false: the 'date' is empty AND the 'url' is empty AND the 'tracking' is empty.

The 'url' and the 'tracking' could be empty, that just leaves the result of the formatDispatchDate() function as suspect.

Link to comment
Share on other sites

We will assume that 'url' and 'tracking' are empty. (You didn't say.) So, make these edits in cubecart.class.php:

Line numbers are for CC615 - should be nearby for you:

Find near 2350:

// Courier Tracking URLs
if (!empty($order['ship_method'])) {
  // Load the module

Change to:

// Courier Tracking URLs
if (!empty($order['ship_method'])) { $GLOBALS['debug']->debugMessage('The ship_method exists at line '.__LINE__);
  // Load the module

Find near line 2379:

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

Change to:

                'date'  => (!empty($order['ship_date']) && $order['ship_date']!=='0000-00-00') ? formatDispatchDate($order['ship_date']) : ''
              );
            } $GLOBALS['debug']->debugMessage('The delivery date is at line '.__LINE__.' '.$delivery['date'].'.');
            if(empty($delivery['date']) && empty($delivery['url']) && empty($delivery['tracking'])) {
              $delivery = false;
            }
          } else { $GLOBALS['debug']->debugMessage('The ship_method was not found at line '.__LINE__);
            $delivery = false;

Then, in /includes/functions.inc.php;

Find near line 409:

function formatDispatchDate($date, $format = '%b %d %Y') {

On the blank line after that, add:

$GLOBALS['debug']->debugMessage('The date argument is at '.__LINE__.': '.$date);

Then find:

return strftime($format, $seconds);

On the blank line ABOVE that, add:

$GLOBALS['debug']->debugMessage('The format to use is at '.__LINE__.': '.$format);
$GLOBALS['debug']->debugMessage('Returning from '.__FUNCTION__.' at '.__LINE__.' with: '.strftime($format, $seconds));

In admin, enable debugging and enter your IP address in the adjacent field (www.whatismyip.com).

When you get the target order's details page (storefront, customer's orders list), at the bottom of the page will be a Debug Messages section.

Link to comment
Share on other sites

Hello BSmither,

Here is the Debug results ...

Debug Messages:
[0] The ship_method exists at line 2347
[1] The delivery date is at line 2392 .

It looks like the Debug messages from functions.inc.php didnt show up

 

Link to comment
Share on other sites

OK, line 2392 has a space after the line number, so we know that the value for $delivery['date'] is blank. That means either $order['ship_date'] is, in fact blank, or formatDispatchDate() is faulty.

But there were no debug messages from formatDispatchDate() (unless edits to that file were not completed), so that means $order['ship_date'] is suspect.

 

Link to comment
Share on other sites

Back in cubecart.class.php:

Near line 2304, find:

$template = 'templates/content.receipt.php';
$order = $orders[0];

On a new blank line after, add:

$GLOBALS['debug']->debugMessage('The order data at line '.__LINE__.' is: '.print_r($order,true));

 

Link to comment
Share on other sites

Will do that now. By the way I added a DEBUG to display ship_date. Here goes after that ...

Debug Messages:
[0] The ship_method exists at line 2347
[1] 2017-07-06
[2] The delivery date is at line 2394 .

Link to comment
Share on other sites

Completed that Edit for Order line ...

Here is the result

[0] The order data at line 2299 is: Array ( [id] => 172 .....bunch of details then ...

[ship_product] => UPS Ground [ship_date] => 2017-07-06 [ship_tracking] =>

3 minutes ago, bsmither said:

What line is the [1] entry coming from?

I added ... $GLOBALS['debug']->debugMessage($order['ship_date']);

Edited by jka
Link to comment
Share on other sites

Keep adding that line at key points in the code.

Find near line 2344:

foreach ($GLOBALS['hooks']->load('class.cubecart.order_summary') as $hook) include $hook;

Add the $GLOBALS['debug'] statement above and after that line.

Add the debug statement just above each:

$delivery = array(

 

The output of the debug statement may be better viewed if you use this:

$GLOBALS['debug']->debugMessage('<pre>The order data at line '.__LINE__.' is: '.print_r($order,true).'</pre>');

This adds <pre> and </pre> to the HTML which keeps line formatting.

Link to comment
Share on other sites

So the formatDispatchDate works ... I just added another debug line right after the date ..

[1] The ship_method exists at line 2350
[2] 2017-07-10
[3] The date argument is at 410: 2017-07-10
[4] The format to use is at 419: %b %d %Y
[5] Returning from formatDispatchDate at 420 with: Jul 10 2017
[6] Jul 10 2017
[7] The delivery date is at line 2399 .

 
After poking around a bit, the $delivery array is not getting populated.
Link to comment
Share on other sites

So, these latest experiments now have calls to formatDispatchDate() being made.

The line after having the call to formatDispatchDate() is a closing parenthesis and a semi-colon.

Put the debug statement after the semi-colon and have it print the variable $delivery. This is just after $delivery is supposedly created with it's various keys and values.

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.

 Share

×
×
  • Create New...