Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 1.7.12 #356

Merged
merged 12 commits into from
Dec 18, 2024
Merged
6 changes: 5 additions & 1 deletion Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: billwerk+, visa, mastercard, dankort, mobilepay
Requires at least: 4.0
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.7.11
Stable tag: 1.7.12
License: GPL
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Expand All @@ -18,6 +18,10 @@ The Billwerk+ Pay plugin extends WooCommerce allowing you to take payments on yo
See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html

== Changelog ==
v 1.7.12
- [Fix] - Redundant call to reduce stock removed.
- [Improvement] - Add Billwerk order status in order grid.

v 1.7.11
- [Fix] - VAT added as compound rate got computed twice.
- [Fix] - Shows no Payment logos when none are selected in settings.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce.",
"type": "wordpress-plugin",
"license": "GPL",
"version": "1.7.11",
"version": "1.7.12",
"autoload": {
"psr-4": {
"Reepay\\Checkout\\": "includes/",
Expand Down
9 changes: 3 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const gulp = require('gulp'),
rename = require('gulp-rename'),
gulpif = require('gulp-if'),
sass = require('gulp-sass')(require('sass')),
sourcemaps = require('gulp-sourcemaps'),
cssmin = require('gulp-clean-css'),
uglify = require('gulp-uglify-es').default,
argv = require('yargs').argv,
fs = require('fs-extra')
fs = require('fs-extra'),
postcss = require('gulp-postcss');

const config = {
sourceMaps: !argv.production // --production
Expand All @@ -18,7 +18,7 @@ gulp.task(
'css:build',
async function () {
return gulp.src('./assets/css/*.scss')
.pipe(gulpif(config.sourceMaps, sourcemaps.init()))
.pipe(gulpif(config.sourceMaps, postcss([], { map: { inline: false } })))
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./assets/dist/css'))
.pipe(cssmin())
Expand All @@ -29,7 +29,6 @@ gulp.task(
}
)
)
.pipe(gulpif(config.sourceMaps, sourcemaps.write('.')))
.pipe(gulp.dest('./assets/dist/css'))

}
Expand All @@ -47,7 +46,6 @@ gulp.task(
async function () {
return gulp.src(['./assets/js/*.js'])
.pipe(gulp.dest('./assets/dist/js'))
.pipe(gulpif(config.sourceMaps, sourcemaps.init()))
.pipe(uglify())
.pipe(
rename(
Expand All @@ -56,7 +54,6 @@ gulp.task(
}
)
)
.pipe(gulpif(config.sourceMaps, sourcemaps.write('.')))
.pipe(gulp.dest('./assets/dist/js'))
}
)
Expand Down
1 change: 1 addition & 0 deletions includes/Admin/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct() {
new Ajax();
new MetaBoxes\Order();
new MetaBoxes\User();
new OrderTable();

add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
}
Expand Down
121 changes: 121 additions & 0 deletions includes/Admin/OrderTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* Order Table admin
*
* @package Reepay\Checkout\Admin
*/

namespace Reepay\Checkout\Admin;

use Automattic\WooCommerce\Utilities\OrderUtil;

defined( 'ABSPATH' ) || exit();

/**
* Class OrderTable
*
* @package Reepay\Checkout\Admin
*/
class OrderTable {

/**
* Constructor.
*/
public function __construct() {
add_filter( 'reepay_checkout_form_fields', array( $this, 'form_fields' ), 11, 2 );
$gateway_settings = get_option( 'woocommerce_reepay_checkout_settings' );
if ( isset( $gateway_settings['order_table_billwerk_status'] ) && 'yes' === $gateway_settings['order_table_billwerk_status'] ) {
if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
add_action(
'manage_woocommerce_page_wc-orders_custom_column',
array( $this, 'shop_order_columns' ),
11,
2
);
add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this, 'admin_order_edit_columns' ), 20 );
} else {
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'shop_order_columns' ), 11, 2 );
add_filter( 'manage_edit-shop_order_columns', array( $this, 'admin_order_edit_columns' ), 20 );
}
}
}

/**
* Add Settings
*
* @param array $form_fields default form fields.
*
* @return array
*/
public function form_fields( array $form_fields ): array {
$form_fields['order_table_billwerk_status'] = array(
'title' => __( 'Order Column: Billwerk Status', 'reepay-checkout-gateway' ),
'type' => 'checkbox',
'label' => __( 'Enable Column', 'reepay-checkout-gateway' ),
'description' => __( 'The "Billwerk Status" column displays the status of Billwerk in the orders table.', 'reepay-checkout-gateway' ),
'default' => 'no',
);

return $form_fields;
}

/**
* Change the columns shown in admin.
*
* @param array $existing_columns WC column.
*
* @return array
*/
public function admin_order_edit_columns( $existing_columns ) {
$columns = array_slice( $existing_columns, 0, count( $existing_columns ) - 1, true ) +
array(
'billwerk_status' => __( 'Billwerk status', 'reepay-checkout-gateway' ),
)
+ array_slice( $existing_columns, count( $existing_columns ) - 1, count( $existing_columns ), true );

return $columns;
}

/**
* Show billwerk status in column
*
* @param string $column_id column id.
* @param WC_Order|null $order order object. For compatibility with WooCommerce HPOS orders table.
*
* @return void
*/
public function shop_order_columns( $column_id, $order = null ) {
if ( ! in_array( $column_id, array( 'billwerk_status' ), true ) ) {
return;
}

if ( 'billwerk_status' === $column_id ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}

$order = wc_get_order( $order );
$gateway = rp_get_payment_method( $order );

if ( empty( $gateway ) ) {
return;
}

$order_data = reepay()->api( $gateway )->get_invoice_data( $order );

if ( is_wp_error( $order_data ) ) {
return;
}

if ( $order_data['refunded_amount'] > 0 &&
( $order_data['authorized_amount'] === $order_data['refunded_amount']
|| $order_data['settled_amount'] === $order_data['refunded_amount']
)
) {
$order_data['state'] = 'refunded';
}

echo ucfirst( $order_data['state'] );
}
}
}
4 changes: 0 additions & 4 deletions includes/OrderFlow/OrderStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ public static function set_authorized_status( WC_Order $order, string $note = ''
return false;
}

if ( empty( $order->get_meta( '_order_stock_reduced' ) ) ) {
wc_reduce_stock_levels( $order->get_id() );
}

self::update_order_status(
$order,
$authorized_status,
Expand Down
3 changes: 0 additions & 3 deletions includes/OrderFlow/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,6 @@ public function process( array $data ) {
return;
}

$order->set_transaction_id( $data['transaction'] );
$order->save();

if ( $order->has_status( 'cancelled' ) ) {
$this->log(
sprintf(
Expand Down
Loading
Loading