I have an invoice or order phtml files where the date is defined like this
$this->formatDate($_order->getCreatedAtStoreDate(), 'long'))
I would also like to add another field that would take this order date and add 5 days to it. So the pseudo code could look like this
$this->formatDate($_order->getCreatedAtStoreDate() . "+ 5 days", 'long'))
How should I achieve this?
You could hook into the sales_order_save_before event and set in the observer your custom date in your new field which was created using a mygento setup routine.
Instrutions for working with events can be found on magentocommerce: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
Also for how to create a setup script to extend the standard model fields: http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources
Actually figured it myself. My pseudo code is almost the right code
$this->formatDate($_order->getCreatedAtStoreDate() . "+5 day", 'long'))
Related
i dont understand a sence of SendInvitationsMode.SendToNone.
Msdn.microsoft.com shows, how appointment could be created with this
option:
https://msdn.microsoft.com/en-us/library/office/dd633661(v=exchg.80).aspx
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
appointment.save();
, i expect, that outlook shows me in my calender this appointment only on the date: 2016-12-12.
But outlook shows me some different days. Obviously start- and end-date will be ignored, when i'am not set this option, when i save appointment: SendInvitationsMode.SendToNone.
"SendToNone" means for me, that this appointment will not be send to something else.
SendToNone means if you have a Meeting that when you create the meeting appointment meeting invitations will not be sent when you call save.
But when i am not using this option and set only start- and end-date to the same date (for example 2016-12-12) and save like this:
What are you trying to achieve though? are you trying to create an All Day appointment ? https://msdn.microsoft.com/en-us/library/office/dn756538(v=exchg.150).aspx the thing to be careful of here is matching the timezone if you have users in different timezone.
I have started using the Dhtmlx Scheduler a few days ago, i went to the docs to see how to create a simple connection and load some data but i keep getting this: { "data":[]} has the response of my .php file. My code is:
<?php
include('connector-php/codebase/scheduler_connector.php');
$pdo=mysqli_connect("localhost","root","pass","hotel");
$scheduler = new JSONSchedulerConnector($pdo);
$scheduler->render_table("TipoQuarto","idTipoQuarto","Nome,Preco");
echo scheduler;
?>
For now i´m just working on the .php file to see if the connector can find my data, and i know there is data there. My database has several tables, so i´m selecting the TipoQuarto, then the id of the field(idTipoQuarto) and then the fields i need, but it´s not displaying anything. Can anyone help me?
Regards.
For MySQLi server side code will look like next
require("connector/scheduler_connector.php");
require("connector/db_mysqli.php");
$mysqli =mysqli_connect("localhost","root","pass","hotel");
$scheduler = new JSONSchedulerConnector($mysqli, "MySQLi");
$scheduler->render_table("TipoQuarto","idTipoQuarto","Nome,Preco");
you need to include db_mysqli.php
second parameter of constructor must be "MySQLi"
Also, in render table, third paremeter mast include start date, end date and text fields. You are providing only two of them.
I am developing a news application where users introduce news and the creation date gets stored and the news appears with a "new!" icon next to it. I would like to automatically erase the "new" icon when the news becomes old (let's say 1 week).
How can I automatically implement this feature? I would like to update a field of a table (new for instance) based on "it is 1 week later than when the news was introduced by the user".
Do I need a "timer" for every new register created? Do I need some sort of cron job to check wether a news is outdated or not?
How would you do it?
Thanks!
Not sure how your app works as you didn't provide any code, but you can do it easly in your view:
if(time() - strtotime($postDate) <= 60*60*24*7) //$postDate is the date stored in your table
{
echo "<div>new!</div>"
}
if you want to do that with a db field, look at how crons work :
https://en.wikipedia.org/wiki/Cron
You could try something like the following:
$news_time = strtotime($row['creation_date']); // your database record creation date
$a_week_ago = strtotime('-1 week');
if( $news_time > a_week_ago ) {
// Your 'new' HTML here
}
I need some help about Custom permalinks for custom post types.
I have created a custom post type called "evento" and 3 custom fields for storing date, month and year of the events.
I would like to have a permalinks structure like this:
/eventos/2012/07/30
... where the standard structure would be:
/?post_type=evento&ano=2012&mes=07&dia=30
How to make this magic happen in WordPress? I do not know much about .Htaccess =(
Thanks in advance!!!
This should do what you want:
RewriteRule ^eventos/([0-9]+)/([0-9]+)/([0-9]+)$ /?post_type=evento&ano=$1&mes=$2&dia=$3 [L]
I tested it using http://htaccess.madewithlove.be/
Good luck.
Problem solved!!!! =)
add_action('init', 'evento_add_rewrite_rules');
function evento_add_rewrite_rules( $wp_rewrite ){
// Add day archive (and pagination)
add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]&paged=$matches[4]','top');
add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]','top');
// Add month archive (and pagination)
add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&paged=$matches[3]','top');
add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]','top');
// Add year archive (and pagination)
add_rewrite_rule("eventos/([0-9]{4})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&paged=$matches[2]','top');
add_rewrite_rule("eventos/([0-9]{4})/?",'index.php?post_type=evento&ano=$matches[1]','top');
}
Thanks!
How to manage timezone in magento at the time of product creation, in frontend i am filtering products by time,but problem is that client wants to show products creation time depend on user's timezone ? for example i am adding a product in admin area it shows 12.21pm but at the same time customer viewing this product from other country it should displays current time according to user's time zone, how can we do that?
please help me to get out of this.
Thanks in advance.
Be more specific about how you are generating the date and how you wish it to be displayed...
Here is a general approach:
In your template code place a span with a class around your time values. These time strings can be formatted with lots of options including the timezone in your php code.
Place javascript where appropriate: either in the header (onload function), in the footer or inline with your view.phtml.
In your javascript use the Prototype library to iterate over the time spans, e.g.:
$$('yourdateclass').each(function() {
//
});
On each of those elements convert the time with Date.parse() to a date object. Then use getTimezoneOffset to account for the visitors location, add/subtract accordingly and then update the element inner html to your preferred way of showing the time/date.
It worked for me.
$session = Mage::getSingleton('customer/session');
$time_zone = $session->getCustomer()->getTimezone();
$timeoffset = Mage::getModel('core/date')->calculateOffset($time_zone);
$timeoffset = $timeoffset - Mage::getModel('core/date')->getGmtOffset($time_zone);