Skip to content

Commit

Permalink
Merge pull request #11 from alexminza/v1.1.7
Browse files Browse the repository at this point in the history
v1.1.7
  • Loading branch information
alexminza authored May 6, 2020
2 parents bdd1846 + 61c6e48 commit c5b7624
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 30 deletions.
Binary file modified languages/wc-moldovaagroindbank-ro_RO.mo
Binary file not shown.
23 changes: 18 additions & 5 deletions languages/wc-moldovaagroindbank-ro_RO.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# This file is distributed under the same license as the WooCommerce Moldova Agroindbank Payment Gateway package.
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.6\n"
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.7\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wc-"
"moldovaagroindbank\n"
"POT-Creation-Date: 2020-04-12 12:17+0300\n"
"PO-Revision-Date: 2020-04-12 12:19+0300\n"
"POT-Creation-Date: 2020-05-03 09:23+0300\n"
"PO-Revision-Date: 2020-05-03 09:25+0300\n"
"Last-Translator: Alexander Minza <alex@alexminza.com>\n"
"Language-Team: \n"
"Language: ro\n"
Expand Down Expand Up @@ -356,14 +356,27 @@ msgstr "Închiderea zilei economice prin %1$s a fost efectuată cu succes: %2$s"
msgid "Close business day via %1$s failed: %2$s"
msgstr "Închiderea zilei economice prin %1$s a eșuat: %2$s"

#: wc-moldovaagroindbank.php:1241
#: wc-moldovaagroindbank.php:1247
msgid "Settings"
msgstr "Setări"

#: wc-moldovaagroindbank.php:1258
#: wc-moldovaagroindbank.php:1264
msgid "Complete %1$s transaction"
msgstr "Finalizează tranzacția prin %1$s"

#: wc-moldovaagroindbank.php:1295
msgid "Scheduled action %1$s is already registered."
msgstr "Acțiunea programată %1$s este deja înregistrată."

#: wc-moldovaagroindbank.php:1314
msgid "Registered scheduled action %1$s in timezone %2$s with ID %3$s."
msgstr ""
"Acțiunea programată %1$s a fost înregistrată în fusul orar %2$s cu ID %3$s."

#: wc-moldovaagroindbank.php:1321
msgid "Unregistered scheduled action %1$s."
msgstr "Acțiunea programată %1$s a fost anulată."

#. Description of the plugin/theme
msgid "WooCommerce Payment Gateway for Moldova Agroindbank"
msgstr "Gateway de plată WooCommerce pentru Moldova Agroindbank"
Binary file modified languages/wc-moldovaagroindbank-ru_RU.mo
Binary file not shown.
24 changes: 19 additions & 5 deletions languages/wc-moldovaagroindbank-ru_RU.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# This file is distributed under the same license as the WooCommerce Moldova Agroindbank Payment Gateway package.
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.6\n"
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.7\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wc-"
"moldovaagroindbank\n"
"POT-Creation-Date: 2020-04-12 12:17+0300\n"
"PO-Revision-Date: 2020-04-12 12:19+0300\n"
"POT-Creation-Date: 2020-05-03 09:23+0300\n"
"PO-Revision-Date: 2020-05-03 09:24+0300\n"
"Last-Translator: Alexander Minza <alex@alexminza.com>\n"
"Language-Team: \n"
"Language: ru\n"
Expand Down Expand Up @@ -361,14 +361,28 @@ msgstr "Завершение бизнес-дня через %1$s прошло у
msgid "Close business day via %1$s failed: %2$s"
msgstr "Ошибка завершения бизнес-дня через %1$s: %2$s"

#: wc-moldovaagroindbank.php:1241
#: wc-moldovaagroindbank.php:1247
msgid "Settings"
msgstr "Настройки"

#: wc-moldovaagroindbank.php:1258
#: wc-moldovaagroindbank.php:1264
msgid "Complete %1$s transaction"
msgstr "Провести платеж через %1$s"

#: wc-moldovaagroindbank.php:1295
msgid "Scheduled action %1$s is already registered."
msgstr "Запланированное действие %1$s уже зарегистрировано."

#: wc-moldovaagroindbank.php:1314
msgid "Registered scheduled action %1$s in timezone %2$s with ID %3$s."
msgstr ""
"Зарегистрировано запланированное действие %1$s в часовом поясе %2$s с ID "
"%3$s."

#: wc-moldovaagroindbank.php:1321
msgid "Unregistered scheduled action %1$s."
msgstr "Запланированное действие %1$s отменено."

#. Description of the plugin/theme
msgid "WooCommerce Payment Gateway for Moldova Agroindbank"
msgstr "Платежный шлюз WooCommerce для Moldova Agroindbank"
20 changes: 16 additions & 4 deletions languages/wc-moldovaagroindbank.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.6\n"
"Project-Id-Version: WooCommerce Moldova Agroindbank Payment Gateway 1.1.7\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wc-moldovaagroindbank\n"
"POT-Creation-Date: 2020-04-12 12:17+0300\n"
"POT-Creation-Date: 2020-05-03 09:23+0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -314,14 +314,26 @@ msgstr ""
msgid "Close business day via %1$s failed: %2$s"
msgstr ""

#: wc-moldovaagroindbank.php:1241
#: wc-moldovaagroindbank.php:1247
msgid "Settings"
msgstr ""

#: wc-moldovaagroindbank.php:1258
#: wc-moldovaagroindbank.php:1264
msgid "Complete %1$s transaction"
msgstr ""

#: wc-moldovaagroindbank.php:1295
msgid "Scheduled action %1$s is already registered."
msgstr ""

#: wc-moldovaagroindbank.php:1314
msgid "Registered scheduled action %1$s in timezone %2$s with ID %3$s."
msgstr ""

#: wc-moldovaagroindbank.php:1321
msgid "Unregistered scheduled action %1$s."
msgstr ""

#. Description of the plugin/theme
msgid "WooCommerce Payment Gateway for Moldova Agroindbank"
msgstr ""
13 changes: 11 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Moldova Agroindbank currently supports transactions in MDL (Moldovan Leu), EUR (
* **Charge** submits all transactions for settlement.
* **Authorization** simply authorizes the order total for capture later. Use the *Complete transaction* order action to settle the previously authorized transaction.

= How can I manually run the Close day action? =

On the *WooCommerce > Status > Scheduled Actions* page filter the actions list by *Pending* status and search for *maib_close_day*. Click the **Run** link next to the action title to execute the *Close day* action immediately.

= How can I contribute to the plugin? =

If you're a developer and you have some ideas to improve the plugin or to solve a bug, feel free to raise an issue or submit a pull request in the [Github repository for the plugin](https://github.com/alexminza/wc-moldovaagroindbank).
Expand All @@ -77,6 +81,10 @@ You can also contribute to the plugin by translating it. Simply visit [translate

== Changelog ==

= 1.1.7 =
Improved Close day scheduled action registration.
For this feature to work properly at least WooCommerce 4 with [Action Scheduler 3](https://woocommerce.wordpress.com/2020/01/08/action-scheduler-3-0/) are required - see [bug fixes from PR #333](https://github.com/woocommerce/action-scheduler/pull/333) for details.

= 1.1.6 =
Added support for EUR and USD currencies

Expand Down Expand Up @@ -112,8 +120,9 @@ Initial release

== Upgrade Notice ==

= 1.1.6 =
Added support for EUR and USD currencies
= 1.1.7 =
Improved Close day scheduled action registration.
See Changelog for details.

= 1.1 =
Simplified payment gateway setup.
Expand Down
44 changes: 30 additions & 14 deletions wc-moldovaagroindbank.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Moldova Agroindbank Payment Gateway
* Description: WooCommerce Payment Gateway for Moldova Agroindbank
* Plugin URI: https://github.com/alexminza/wc-moldovaagroindbank
* Version: 1.1.6
* Version: 1.1.7
* Author: Alexander Minza
* Author URI: https://profiles.wordpress.org/alexminza
* Developer: Alexander Minza
Expand Down Expand Up @@ -1226,6 +1226,12 @@ protected function log($message, $level = WC_Log_Levels::DEBUG) {
$this->logger->log($level, $message, $this->log_context);
}

static function static_log($message, $level = WC_Log_Levels::DEBUG) {
$logger = wc_get_logger();
$log_context = array('source' => WC_MoldovaAgroindbank::MOD_ID);
$logger->log($level, $message, $log_context);
}

static function print_var($var) {
//https://docs.woocommerce.com/wc-apidocs/function-wc_print_r.html
return wc_print_r($var, true);
Expand Down Expand Up @@ -1275,16 +1281,6 @@ static function action_reverse_transaction($order) {
}

static function action_close_day() {
/*$closeday_start = 23;
$closeday_end = 1;
$current_hour = intval(current_time('H'));
if($current_hour >= $closeday_start || $current_hour <= $closeday_end) {
//close_day();
} else {
sprintf(__('Close day allowed between %1$s and %2$s', self::MOD_TEXT_DOMAIN), $closeday_start, $closeday_end);
$result = '';
}*/

$plugin = new self();
$result = $plugin->close_day();

Expand All @@ -1295,15 +1291,35 @@ static function action_close_day() {
}

public static function register_scheduled_actions() {
if(false !== as_next_scheduled_action(self::MOD_CLOSEDAY_ACTION)) {
$message = sprintf(__('Scheduled action %1$s is already registered.', self::MOD_TEXT_DOMAIN), self::MOD_CLOSEDAY_ACTION);
self::static_log($message, WC_Log_Levels::WARNING);

self::unregister_scheduled_actions();
}

$timezoneId = wc_timezone_string();
$timestamp = as_get_datetime_object('midnight tomorrow', $timezoneId);
$timestamp = as_get_datetime_object('tomorrow - 1 minute', $timezoneId);
$timestamp->setTimezone(new DateTimeZone('UTC'));

$action_id = as_schedule_recurring_action($timestamp, DAY_IN_SECONDS, WC_MoldovaAgroindbank::MOD_CLOSEDAY_ACTION, array(), WC_MoldovaAgroindbank::MOD_ID);
#region CRON
$cronSchedule = $timestamp->format('i H * * *'); #'59 23 * * *'
$action_id = as_schedule_cron_action(null, $cronSchedule, self::MOD_CLOSEDAY_ACTION, array(), self::MOD_ID);
#endregion

#region INTERVAL
#$action_id = as_schedule_recurring_action($timestamp, DAY_IN_SECONDS, self::MOD_CLOSEDAY_ACTION, array(), self::MOD_ID);
#entregion

$message = sprintf(__('Registered scheduled action %1$s in timezone %2$s with ID %3$s.', self::MOD_TEXT_DOMAIN), self::MOD_CLOSEDAY_ACTION, $timezoneId, $action_id);
self::static_log($message, WC_Log_Levels::INFO);
}

public static function unregister_scheduled_actions() {
as_unschedule_all_actions(WC_MoldovaAgroindbank::MOD_CLOSEDAY_ACTION);
as_unschedule_all_actions(self::MOD_CLOSEDAY_ACTION);

$message = sprintf(__('Unregistered scheduled action %1$s.', self::MOD_TEXT_DOMAIN), self::MOD_CLOSEDAY_ACTION);
self::static_log($message, WC_Log_Levels::INFO);
}

static function find_scheduled_action($status = null) {
Expand Down

0 comments on commit c5b7624

Please sign in to comment.