|
|
|
|
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
|
class Siti_Stock_Supplier_Exports {
|
|
|
|
|
|
|
|
|
|
const CRON_HOOK = 'siti_stock_plugin_supplier_export';
|
|
|
|
|
const SUPPLIER_META_KEY = '_wpbc_supplier';
|
|
|
|
|
const SUPPLIER_META_KEY = '_wpci_supplier';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Siti_Stock_Settings
|
|
|
|
|
@@ -258,7 +258,7 @@ class Siti_Stock_Supplier_Exports {
|
|
|
|
|
$body_lines[] = $csv;
|
|
|
|
|
|
|
|
|
|
$headers = array( 'Content-Type: text/plain; charset=UTF-8' );
|
|
|
|
|
$sent = wp_mail( $admin_email, $subject, implode( "\n", $body_lines ), $headers );
|
|
|
|
|
$sent = wp_mail( $admin_email, $subject, implode( "\r\n", $body_lines ), $headers );
|
|
|
|
|
|
|
|
|
|
if ( ! $sent ) {
|
|
|
|
|
return new WP_Error( 'siti_stock_mail_failed', __( 'E-mail verzenden is mislukt.', 'siti-stock-plugin' ) );
|
|
|
|
|
@@ -307,16 +307,18 @@ class Siti_Stock_Supplier_Exports {
|
|
|
|
|
private function collect_rows_for_supplier( $supplier ) {
|
|
|
|
|
$key = $this->normalize_supplier_key( $supplier );
|
|
|
|
|
|
|
|
|
|
$after_timestamp = current_time( 'timestamp' ) - DAY_IN_SECONDS;
|
|
|
|
|
$date_filter = array(
|
|
|
|
|
'after' => gmdate( 'Y-m-d H:i:s', $after_timestamp ),
|
|
|
|
|
);
|
|
|
|
|
$site_timezone = function_exists( 'wp_timezone' ) ? wp_timezone() : new DateTimeZone( wp_timezone_string() );
|
|
|
|
|
$after_date = new DateTimeImmutable( 'now', $site_timezone );
|
|
|
|
|
$after_date = $after_date->sub( new DateInterval( 'P1D' ) );
|
|
|
|
|
$after_utc = $after_date->setTimezone( new DateTimeZone( 'UTC' ) );
|
|
|
|
|
|
|
|
|
|
if ( class_exists( 'WC_DateTime' ) ) {
|
|
|
|
|
$after_object = new WC_DateTime( '@' . $after_timestamp );
|
|
|
|
|
$after_object->setTimezone( new DateTimeZone( 'UTC' ) );
|
|
|
|
|
$date_filter = array( 'after' => $after_object );
|
|
|
|
|
}
|
|
|
|
|
$date_query = array(
|
|
|
|
|
array(
|
|
|
|
|
'column' => 'date_created_gmt',
|
|
|
|
|
'after' => $after_utc->format( 'Y-m-d H:i:s' ),
|
|
|
|
|
'inclusive' => true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$query = new WC_Order_Query(
|
|
|
|
|
array(
|
|
|
|
|
@@ -324,7 +326,7 @@ class Siti_Stock_Supplier_Exports {
|
|
|
|
|
'limit' => -1,
|
|
|
|
|
'type' => 'shop_order',
|
|
|
|
|
'return' => 'objects',
|
|
|
|
|
'date_created' => $date_filter,
|
|
|
|
|
'date_query' => $date_query,
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -437,7 +439,7 @@ class Siti_Stock_Supplier_Exports {
|
|
|
|
|
$lines[] = sprintf( '%s;%d', $sku, $quantity );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return implode( "\n", $lines );
|
|
|
|
|
return implode( "\r\n", $lines );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|