Skip to content

Commit

Permalink
Version 1.5.1 (#36)
Browse files Browse the repository at this point in the history
* Adds phpcs.xml and phpcs to composer

* Update composer.lock

* PHPCS

* Set failed request order status correct even if plugin settings never have been saved

* PHPCS

* Use update_meta_data instead of update_meta

* Create deploy.yml

* Add .distignore + update deployment script to include build functionality

* Update .distignore

* PHPCS

* Version update (1.5.1)

---------

Co-authored-by: MichaelBengtsson <[email protected]>
  • Loading branch information
NiklasHogefjord and MichaelBengtsson authored Jun 11, 2024
1 parent 036d8af commit d4949d1
Show file tree
Hide file tree
Showing 10 changed files with 789 additions and 180 deletions.
32 changes: 32 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/.wordpress-org
/.git
/.github
/node_modules
/tests
/languages/*-backup-*
/.vscode
.editorconfig
.distignore
.gitignore
Dockerfile-cron
Dockerfile-wpdebug-php7
Dockerfile-wpdebug-php8
DOCKER_ENV
docker_tag
output.log
readme.md
README.md
gulpfile.js
package.json
package-lock.json
docker-compose.phpunit.yml
docker-compose.yml
Dockerfile
readme.dev.txt
README.md
phpcs.ruleset.xml
phpunit-docker.xml
phpunit.xml
phpcs.xml
renovate.json
wpcron.txt
29 changes: 29 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build and deploy to WordPress.org
on:
release:
types: [published]
jobs:
tag:
name: New tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main

# Install all composer dependencies for the plugin.
- name: Install Composer dependencies
uses: php-actions/composer@v6
with:
dev: no
php_version: 7.4

# Deploy the plugin to WordPress.org
- name: WordPress Plugin Deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
generate-zip: true
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: ledyer-order-management-for-woocommerce
58 changes: 31 additions & 27 deletions classes/class-ledyer-om-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace LedyerOm;


\defined( 'ABSPATH' ) || die();

class Ledyer_Order_Management_For_WooCommerce {
Expand All @@ -18,16 +17,17 @@ class Ledyer_Order_Management_For_WooCommerce {
public $parentSettings;
public $api;

const VERSION = '1.5.0';
const SLUG = 'ledyer-order-management-for-woocommerce';
const VERSION = '1.5.1';
const SLUG = 'ledyer-order-management-for-woocommerce';
const SETTINGS = 'ledyer_order_management_for_woocommerce_settings';

/**
* Summary of actions - called from class-ledyer-om-singleton.php
*
* @return void
*/
public function actions() {
add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] );
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );

// Add refunds support to Ledyer Payments and Ledyer Checkout gateways.
add_action( 'wc_ledyer_payments_supports', array( $this, 'add_gateway_support' ) );
Expand All @@ -36,60 +36,66 @@ public function actions() {
// Capture an order -> lom-capture.php
add_action(
'woocommerce_order_status_completed',
function ($order_id, $action = false) {
lom_capture_ledyer_order($order_id, $action, $this->api);
function ( $order_id, $action = false ) {
lom_capture_ledyer_order( $order_id, $action, $this->api );
}
);

// Listen to refund from Ledyer Checkout for Woocommerce, then call lom_refund_ledyer_order -> lom-refund.php
add_filter(
'wc_ledyer_checkout_process_refund',
function ($result, $order_id, $amount, $reason) {
return lom_refund_ledyer_order($order_id, $amount, $this->api);
function ( $result, $order_id, $amount, $reason ) {
return lom_refund_ledyer_order( $order_id, $amount, $this->api );
},
10, 4);
10,
4
);

// Listen to refund from Ledyer Payments for Woocommerce, then call lom_refund_ledyer_order -> lom-refund.php
add_filter(
'wc_ledyer_payments_process_refund',
function ($result, $order_id, $amount, $reason) {
return lom_refund_ledyer_order($order_id, $amount, $this->api);
function ( $result, $order_id, $amount, $reason ) {
return lom_refund_ledyer_order( $order_id, $amount, $this->api );
},
10, 4);
10,
4
);

// Cancel an order -> lom-cancel.php
add_action(
'woocommerce_order_status_cancelled',
function ($order_id, $action = false) {
lom_cancel_ledyer_order($order_id, $action, $this->api);
function ( $order_id, $action = false ) {
lom_cancel_ledyer_order( $order_id, $action, $this->api );
}
);

// Sync order items and totals
add_action(
'woocommerce_saved_order_items',
function ($order_id, $action = false) {
lom_edit_ledyer_order($order_id, $action, $this->api, "order");
function ( $order_id, $action = false ) {
lom_edit_ledyer_order( $order_id, $action, $this->api, 'order' );
}
);

// Sync customer details such as shipping and billing
add_action(
'woocommerce_process_shop_order_meta',
function ($order_id, $action = false) {
function ( $order_id, $action = false ) {

if (!is_admin()) {
if ( ! is_admin() ) {
return;
}
lom_edit_ledyer_order($order_id, $action, $this->api, "customer");
}, 55, 1 // Priority higher than 50, since that is the priority we use to save the fields after validation is done. We don't want to sync with Ledyer if local Woo validation of the fields fail.
lom_edit_ledyer_order( $order_id, $action, $this->api, 'customer' );
},
55,
1 // Priority higher than 50, since that is the priority we use to save the fields after validation is done. We don't want to sync with Ledyer if local Woo validation of the fields fail.
);
}

/**
* Adds plugin action link to Ledyer documentation for LOM.
*
* @param array $links Plugin action link before filtering.
* @param array $links Plugin action link before filtering.
*
* @return array Filtered links.
*/
Expand Down Expand Up @@ -122,11 +128,11 @@ public function on_plugins_loaded() {
$this->include_files();
$this->set_settings();

$this->credentials = Credentials::instance();
$this->parentSettings = ParentSettings::instance();
$this->api = new API();
$this->credentials = Credentials::instance();
$this->parentSettings = ParentSettings::instance();
$this->api = new API();

add_filter( 'plugin_action_links_' . plugin_basename( LOM_WC_MAIN_FILE ), array($this, 'plugin_action_links'));
add_filter( 'plugin_action_links_' . plugin_basename( LOM_WC_MAIN_FILE ), array( $this, 'plugin_action_links' ) );
}

/**
Expand Down Expand Up @@ -173,7 +179,5 @@ public function include_files() {
include_once LOM_WC_PLUGIN_PATH . '/classes/requests/order/class-ledyer-om-request-cancel-order.php';
include_once LOM_WC_PLUGIN_PATH . '/classes/requests/order/class-ledyer-om-request-edit-order.php';
include_once LOM_WC_PLUGIN_PATH . '/classes/requests/order/class-ledyer-om-request-edit-customer.php';


}
}
17 changes: 16 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@
"_note_": "using an older version of brick/money to support from PHP 7.1 and greater",
"require": {
"brick/money": "0.5.3"
}
},
"require-dev": {
"php-stubs/wordpress-stubs": "*",
"php-stubs/woocommerce-stubs": "dev-master",
"wp-coding-standards/wpcs": "^3.1"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"install-codestandards": [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
]
}
}
Loading

0 comments on commit d4949d1

Please sign in to comment.