Dirty Butter Posted August 20, 2014 Share Posted August 20, 2014 I've installed 5.2.13 on our plushcatalog store, but I found when checking some emails that the order date in the email for a test order shows as 1408134298 - not written as a calendar date. I expected it to be 08/15/2014. I used {$DATA.order_date} in the email template. I haven't checked the customer emails in a long time, so this may not have anything to do with this upgrade. Your help is appreciated. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 20, 2014 Share Posted August 20, 2014 There is code that will convert the "unix timestamp" to a readable value. (order.class.php, near line 543, getOrderDetails()). The function formatTime() (in functions.inc.php, near line 333) checks the configuration settings for a time format. That format is set in admin, Store Settings, Advanced tab, for Time Format may be something like %Y-%m-%d %H:%M We need to make sure there aren't any plugins/snippets with hooks which may be interfering with getOrderDetails(). Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 20, 2014 Author Share Posted August 20, 2014 I do have %m/%d/%Y %l:%M%p on the Advanced screen. Here's what I have on order.class.php // Format data $order_summary['order_date'] = formatTime($order_summary['order_date'],false,true); $order_summary['ship_date'] = ((int)(str_replace('-', '', $order_summary['ship_date'])) > 0) ? formatDispatchDate($order_summary['ship_date']) : ""; $order_summary['gateway'] = str_replace('_',' ',$order_summary['gateway']); And functions.inc.php * Format time * * @param string $timestamp * @param bool $format * @param bool $dynamic * * @return string/false */ function formatTime($timestamp, $format = false, $static = false) { if (empty($timestamp)) { return false; } ## Convert a timestamp to something legible if (!$format) { $format = $GLOBALS['config']->get('config', 'time_format'); } $sign = substr($GLOBALS['config']->get('config', 'time_offset'), 0, 1); $value = substr($GLOBALS['config']->get('config', 'time_offset'), 1); if ($sign == '+') { $seconds = $timestamp+$value; } else if ($sign == '-') { $seconds = $timestamp-$value; } else { $seconds = $timestamp; } $fuzzy = true; if(!$date_today = strftime('%D', time())) { $fuzzy = false; } $date = strftime('%D', $seconds); $time = strftime('%H:%M', $seconds); if ($fuzzy && !$static && $date_today == $date) { ## Today return $GLOBALS['language']->common['today'].", ".$time; } elseif ($fuzzy && !$static && strftime("%D", strtotime('yesterday')) == $date) { ## Yesterday return $GLOBALS['language']->common['yesterday'].", ".$time; } else { return strftime($format, $seconds); } } Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 20, 2014 Share Posted August 20, 2014 All of that is good. Can you check on any hooks that may be in play? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 20, 2014 Author Share Posted August 20, 2014 I don't know how to check for Hooks that might be in play. The Hooks listed in Admin are Custom Contact Us, Fusion, Homepage Sales Items, Mailchimp, PayPal Pro, Sale Items with Images, and Sequential Order Numbers. None of those "sound" like they would have any date effects to me. There's only one Code Snippet, and it's to block registrations for typical spammer choices. I just tried an old test order on estates (still on 5.2.12) and the date is a unix timestamp in the email for that one, too. So this problem is not a 5.2.13 issue after all. The only reason I even thought to test customer emails was because there were some changes to Cancelled in this upgrade. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 22, 2014 Author Share Posted August 22, 2014 I do see that the database structure of _order_summary has order_date as int(10) and ship_date is date. Should they both be date? Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 22, 2014 Share Posted August 22, 2014 No. 'order_date' should be INT as it holds a unix timestamp. I cannot determine the reasoning for why 'ship_date' is DATE instead of INT. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 22, 2014 Share Posted August 22, 2014 "I don't know how to check for Hooks that might be in play." You will need to look at the database directly to easily determine if there is a hook or snippet that may be interfering with getOrderDetails(). In the table, Cubecart_hooks, we need to see if any hook has as a 'trigger' the value "class.order.get_order_details" (or any trigger that starts with "class.order"). Also look in CubeCart_code_snippet if any snippet has as a 'hook_trigger' a value that starts with "class.order". Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 None of the hooks nor the snippet have any class.order triggers. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 "I used {$DATA.order_date} in the email template." For the email template Cart: Order Confirmed, has, in part: Your order {$DATA.cart_order_id} has been received which was placed on {$DATA.order_date}. This is working fine for me (CC5212). The way you said you used {$DATA.order_date} in an email template, leads me to believe {$DATA.order_date} wasn't there before. Which template are you specifically having the timestamp show instead of the date? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 I used the Order Failed email and reworked it to be an Unpaid Order email, so I could get one last chance of getting a customer to complete an order they had left pending. I also have that language in an E-check Payment email that was created by a developer. Both show {$DATA.order_date} in the Macros, and both show the timestamp in emails. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 "I used the Order Failed email" There is no email template named Order Failed. There is an order status of ORDER_FAILED that uses the Cart: Fraud Review template. There is an order status of ORDER_CANCELLED that uses the Cart: Order Cancelled template. CubeCart will get the raw order details from the database. However, CubeCart also gets the order's details via getOrderDetails(), tweaks a few of the items, and assigns them to a class-wide variable ($_email_details), which it does before deciding how to process the change in the order status. Cubecart must then assign that variable to the various "sections" (for lack of a better word, such as $DATA and $BILLING) and does this in assignOrderDetails(). However, In CC5212 (and presumably in CC5213), in the Cart class, assignOrderDetails() is only called within the blocks of code for when an order goes to Pending, Processing, or Complete, but not when the order goes to Declined, Failed, or Cancelled (also, sending the Digital Download email). Instead, these statuses use the raw order details data. There are several places in the Cart class that need edits so that all status emails gets the most appropriate set of data. "I also have that language in an E-check Payment email." We may need to visit that code to make sure it is using the Cart class functions correctly. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 It was Fraud Review - sorry. There are several places in the Cart class that need edits so that all status emails gets the most appropriate set of data. I had noticed that some of the lines have $this->assignOrderDetails(null,true); and others don't have (null,true) Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 In the file /classes/order.class.php, near lines 305-317: Was: case self::ORDER_DECLINED: // Nothing to do, but leave the option here for hooks & such break; case self::ORDER_FAILED: // Email the customer to explain their order failed fraud review $content = $mailer->loadContent('cart.payment_fraud', $order_summary['lang'], $this->_order_summary); break; case self::ORDER_CANCELLED: // Cancelled $content = $mailer->loadContent('cart.order_cancelled', $order_summary['lang'], $this->_order_summary); break; Now: case self::ORDER_DECLINED: // Nothing to do, but leave the option here for hooks & such break; case self::ORDER_FAILED: // Email the customer to explain their order failed fraud review if( ($content = $mailer->loadContent('cart.payment_fraud', $order_summary['lang'])) !== false ) $this->assignOrderDetails(); break; case self::ORDER_CANCELLED: // Cancelled if( ($content = $mailer->loadContent('cart.order_cancelled', $order_summary['lang'])) !== false ) $this->assignOrderDetails(); break; Also, near line 647: Was: if ($this->_email_enabled && ($contents = $mailer->loadContent('cart.digital_download', $this->_order_summary['lang'], $this->_order_summary))) { Now: if ($this->_email_enabled && ($contents = $mailer->loadContent('cart.digital_download', $this->_order_summary['lang']))) { $this->assignOrderDetails(); Let's see how this works. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 I'm doing something wrong, as the page will not load with these changes. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 Which page? Any page? Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 I made a small edit to the code in post #14. I enclosed part of the expression in parentheses. Although, I didn't get any blank pages prior to that edit. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 I tried it again with your code, but the Order Summary page still crashes. I've commented out yours and left mine. case self::ORDER_FAILED: // Email the customer to explain their order failed fraud review $content = $mailer->loadContent('cart.payment_fraud', $order_summary['lang'], $this->_order_summary); //( ($content = $mailer->loadContent('cart.payment_fraud', $order_summary['lang'])) !== false ) $this->assignOrderDetails(); break; Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 23, 2014 Share Posted August 23, 2014 If what you commented is all of the edited statement, compare that with the beginning of the edited statement here: if( ($content Where's the if? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 23, 2014 Author Share Posted August 23, 2014 Well, I've gone cross-eyed trying to get it to work. I did leave off the "if" that time, and then I left out a parenthesis. UGH Anyway, with your most appreciated help I now have the Unpaid Order and the modded E-check order emails working correctly. 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.