Skip to content

Commit

Permalink
Release v5.1.1 (#380)
Browse files Browse the repository at this point in the history
* [ENGA3-1334]: Fix invalid product issue with variance item (#377)

* [ENGA3-1334]: Added WC_Product_Variation class when the item is a variant to fix the invalid prodcut issue. Atome logo is also added.

* Fixed formatting.

---------

Co-authored-by: Aashish <aashish@omise.co>

* [ENGA3-1334]: Remove free products from the Atome bill (#378)

* [ENGA3-1334]: Remove free products from Atome product list.

* [ENGA3-1134]: Updated the message for Atome on freebie products.

* [ENGA3-1134]: Check subtotal instead of price per item when comparing to zero.

---------

Co-authored-by: Aashish <aashish@omise.co>

* fixed not compatible with country based payments plugin (#379)

* Preparing release of v5.1.1

* Updated release date

---------

Co-authored-by: Aashish <aashish@omise.co>
Co-authored-by: (AJ) Zin Kyaw Kyaw <108650842+ajzkk@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 13, 2023
1 parent 791fb02 commit f231df0
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

### [v5.1.1 _(Jun 13, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.1.1)
- Remove free products from the Atome bill. (PR [#378](https://github.com/omise/omise-woocommerce/pull/378))
- Fix incompatible issue with country based payments plugin. (PR [#379](https://github.com/omise/omise-woocommerce/pull/379))

### [v5.1.0 _(May 15, 2023)_](https://github.com/omise/omise-woocommerce/releases/tag/v5.1.0)
- Added Atome payment method. (PR [#364](https://github.com/omise/omise-woocommerce/pull/364))
- Installment minimum amount from capability API. (PR [#365](https://github.com/omise/omise-woocommerce/pull/365))
Expand Down
Binary file added assets/images/atome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions assets/javascripts/omise-payment-form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,10 @@
}

function initializeSecureCardForm() {
if (Boolean(omise_params.secure_form_enabled)) {
const omiseCardElement = document.getElementById('omise-card');
if (omiseCardElement && Boolean(omise_params.secure_form_enabled)) {
showOmiseEmbeddedCardForm({
element: document.getElementById('omise-card'),
element: omiseCardElement,
publicKey: omise_params.key,
hideRememberCard: HIDE_REMEMBER_CARD,
locale: LOCALE,
Expand Down
50 changes: 39 additions & 11 deletions includes/gateway/class-omise-payment-atome.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ private function register_omise_atome_scripts() {
public function payment_fields()
{
parent::payment_fields();
$viewData = $this->validateMinRequiredAmount();
$viewData = $this->validateAtomeRequest();

Omise_Util::render_view('templates/payment/form-atome.php', $viewData);
}

private function validateMinRequiredAmount()
private function validateAtomeRequest()
{
$limits = [
'thb' => [
Expand All @@ -103,7 +103,14 @@ private function validateMinRequiredAmount()
];

$currency = strtolower(get_woocommerce_currency());
$cartTotal = WC()->cart->total;
$cart = WC()->cart;

if ($cart->subtotal === 0) {
return [
'status' => false,
'message' => 'Complimentary products cannot be billed.'
];
}

if (!isset($limits[$currency])) {
return [
Expand All @@ -114,7 +121,7 @@ private function validateMinRequiredAmount()

$limit = $limits[$currency];

if ($cartTotal < $limit['min']) {
if ($cart->total < $limit['min']) {
return [
'status' => false,
'message' => sprintf(
Expand All @@ -125,7 +132,7 @@ private function validateMinRequiredAmount()
];
}

if ($cartTotal > $limit['max']) {
if ($cart->total > $limit['max']) {
return [
'status' => false,
'message' => __(
Expand Down Expand Up @@ -191,23 +198,44 @@ private function getItems($order, $currency)

// Loop through ordered items
foreach ($items as $key => $item) {
$product_variation_id = $item['variation_id'];
// item don't have price. So we have to take subtotal and divide it by quantity to get the price
$pricePerItem = $item['subtotal'] / $item['qty'];

// Remove product from the list if the price is 0
if ((float)$item['subtotal'] === 0.00) {
continue;
}

// Check if product has variation.
$productId = $product_variation_id ? $item['variation_id'] : $item['product_id'];
$product = new WC_Product($productId);
$product = $item['variation_id'] ?
new WC_Product_Variation($item['variation_id'])
: new WC_Product($item['product_id']);

$sku = $product->get_sku();
// item don't have price. So we have to take subtotal and divide it by quantity to get the price
$pricePerItem = $item['subtotal'] / $item['qty'];

$products[$key] = [
'quantity' => $item['qty'],
'name' => $item['name'],
'amount' => Omise_Money::to_subunit($pricePerItem, $currency),
'sku' => empty($sku) ? $productId : $sku // if sku is not present then pass productId
'sku' => empty($sku) ? $product->get_id() : $sku // if sku is not present then pass productId
];
}

return $products;
}

/**
* Get icons
*
* @see WC_Payment_Gateway::get_icon()
*/
public function get_icon() {
$icon = Omise_Image::get_image([
'file' => 'atome.png',
'alternate_text' => 'Atome logo',
'width' => 20,
'height' => 20
]);
return apply_filters('woocommerce_gateway_icon', $icon, $this->id);
}
}
4 changes: 2 additions & 2 deletions omise-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Opn Payments
* Plugin URI: https://www.omise.co/woocommerce
* Description: Opn Payments is a WordPress plugin designed specifically for WooCommerce. The plugin adds support for Opn Payments Payment Gateway's payment methods to WooCommerce.
* Version: 5.1.0
* Version: 5.1.1
* Author: Opn Payments and contributors
* Author URI: https://github.com/omise/omise-woocommerce/graphs/contributors
* Text Domain: omise
Expand All @@ -22,7 +22,7 @@ class Omise
*
* @var string
*/
public $version = '5.1.0';
public $version = '5.1.1';

/**
* The Omise Instance.
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: Opn Payments
Tags: opn payments, payment, payment gateway, woocommerce plugin, omise, opn, installment, internet banking, alipay, paynow, truemoney wallet, woocommerce payment
Requires at least: 4.3.1
Tested up to: 6.0.2
Stable tag: 5.1.0
Stable tag: 5.1.1
License: MIT
License URI: https://opensource.org/licenses/MIT

Expand Down Expand Up @@ -34,6 +34,11 @@ From there:

== Changelog ==

= 5.1.1 =

- Remove free products from the Atome bill. (PR [#378](https://github.com/omise/omise-woocommerce/pull/378))
- Fix incompatible issue with country based payments plugin. (PR [#379](https://github.com/omise/omise-woocommerce/pull/379))

= 5.1.0 =

- Added Atome payment method. (PR [#364](https://github.com/omise/omise-woocommerce/pull/364))
Expand Down

0 comments on commit f231df0

Please sign in to comment.