Skip to content

Commit

Permalink
fix another warning and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
baka-san committed Feb 14, 2024
1 parent 5ef15e0 commit b8291a1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
5 changes: 2 additions & 3 deletions class-wc-gateway-komoju.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class WC_Gateway_Komoju extends WC_Payment_Gateway
/** @var WC_Logger Logger instance */
public static $log;

// Fixing deprecated properties
protected $debug;
protected $invoice_prefix;
protected $secretKey;
protected $webhookSecretToken;
protected $komoju_api;
protected $instructions; // Fixing deprecated property
protected $useOnHold; // Fixing deprecated property
protected $instructions;
protected $useOnHold;

/**
* Constructor for the gateway.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This will download the docker images and WordPress plugins. Once the initial set

**Note:** It _has_ to be `127.0.0.1`, not `localhost`

If you've made changes to your Docker configuration, you can do a fresh build:
If you've made changes to your files, you can rebuild using build. If you've made changes to your Docker configuration, you can do a fresh build with --no-cache option.

```
docker-compose build (--no-cache)
Expand Down
45 changes: 24 additions & 21 deletions includes/class-wc-gateway-komoju-single-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,30 @@ public function __construct($payment_method)
$this->has_fields = $this->should_use_inline_fields($slug);
$this->method_title = __('Komoju', 'komoju-woocommerce') . ' - ' . $this->default_title();

// if ($slug == 'credit_card') {
// // Show dynamic icon with supported brands.
// $brands = isset($payment_method['subtypes']) ? $payment_method['subtypes'] : [];

// $sort_order = [
// 'visa' => 0,
// 'master' => 1,
// 'jcb' => 2,
// 'american_express' => 3,
// 'diners_club' => 4,
// 'discover' => 5,
// ];

// // Sort by the order defined above.
// usort($brands, function ($a, $b) use ($sort_order) {
// return $sort_order[$a] - $sort_order[$b];
// });

// $brands = implode(',', $brands);
// $this->icon .= "?brands=$brands";
// }
if ($slug == 'credit_card') {
// Show dynamic icon with supported brands.
$brands = isset($payment_method['subtypes']) ? $payment_method['subtypes'] : [];
$sort_order = [
'visa' => 0,
'master' => 1,
'jcb' => 2,
'american_express' => 3,
'diners_club' => 4,
'discover' => 5,
];

// Sort by the order defined above.
usort($brands, function ($a, $b) use ($sort_order) {
// Get the sort order for $a and $b, providing a default value if the key doesn't exist
$sort_a = isset($sort_order[$a]) ? $sort_order[$a] : count($sort_order);
$sort_b = isset($sort_order[$b]) ? $sort_order[$b] : count($sort_order);

return $sort_a - $sort_b;
});

$brands = implode(',', $brands);
$this->icon .= "?brands=$brands";
}

// TODO: It would be nice if KOMOJU told us in the payment method object whether or
// not it supports refunds. For now, we'll just wing it.
Expand Down
1 change: 0 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function woocommerce_add_komoju_gateway($methods)
$methods[] = new WC_Gateway_Komoju_Single_Slug($payment_method);
}
}

return $methods;
}

Expand Down

0 comments on commit b8291a1

Please sign in to comment.