Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created February 27, 2018 18:50
Show Gist options
  • Select an option

  • Save hedqvist/7647282cd219db064f329284f35e0db9 to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/7647282cd219db064f329284f35e0db9 to your computer and use it in GitHub Desktop.
Set InvoiceDate based on OrderDate via functions.php
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Set InvoiceDate based on OrderDate via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_payment_method_invoicedate($invoice, $order_id) {
$order = new WC_Order($order_id);
$invoice['Invoice']['InvoiceDate'] = $order->get_date_created()->format("Y-m-d");
return $invoice;
}
add_filter('obj_fortnox_update_invoice_params', 'redlight_fortnox_payment_method_invoicedate', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment