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

[PT-560] Added filters for buyer_fee_cents and order_data #120

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: mondu-ai, arthurmmoreira, tikohov20
Tags: mondu, woocommerce, e-commerce, ecommerce, store, sales, sell, woo, woo commerce, shop, cart, shopping cart, sell online, checkout, payment, payments, bnpl, b2b
Requires at least: 5.9.0
Tested up to: 6.5.3
Stable tag: 3.0.1
Stable tag: 3.0.2
Requires PHP: 7.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down
16 changes: 16 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
== Changelog ==

= 3.0.2 =

* Added filters for buyer_fee_cents and whole order_data

= 3.0.1 =

* Reworked Credit Note flow

= 3.0.0 =

* Improve plugin code standards

= 2.2.0 =

* Compatibility for high performance order storage and cart checkout blocks

= 2.1.7 =

* Bugfixes and improvements
Expand Down
4 changes: 2 additions & 2 deletions mondu-buy-now-pay-later.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Mondu Buy Now Pay Later
* Plugin URI: https://github.com/mondu-ai/bnpl-checkout-woocommerce/releases
* Description: Mondu provides B2B E-commerce and B2B marketplaces with an online payment solution to buy now and pay later.
* Version: 3.0.1
* Version: 3.0.2
* Author: Mondu
* Author URI: https://mondu.ai
*
Expand All @@ -27,7 +27,7 @@
die( 'Direct access not allowed' );
}

define( 'MONDU_PLUGIN_VERSION', '3.0.1' );
define( 'MONDU_PLUGIN_VERSION', '3.0.2' );
define( 'MONDU_PLUGIN_FILE', __FILE__ );
define( 'MONDU_PLUGIN_PATH', __DIR__ );
define( 'MONDU_PLUGIN_BASENAME', plugin_basename(MONDU_PLUGIN_FILE) );
Expand Down
13 changes: 12 additions & 1 deletion src/Mondu/Mondu/Support/OrderData.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,21 @@ public static function order_data_from_wc_order( WC_Order $order ) {
$billing_zip_code = $order->get_billing_postcode();
$billing_country_code = $order->get_billing_country();

/**
* @since 3.0.2
*
* Can be used to include any additional costs that are not included by default.
*/
$buyer_fee_cents = apply_filters('mondu_buyer_fee_cents', 0, $order);

$order_data = [
'payment_method' => array_flip( Plugin::PAYMENT_METHODS )[ $order->get_payment_method() ],
'currency' => get_woocommerce_currency(),
'external_reference_id' => (string) $order->get_order_number(),
'gross_amount_cents' => round( (float) $order->get_total() * 100),
'net_price_cents' => round( (float) $order->get_subtotal() * 100),
'tax_cents' => round( (float) $order->get_total_tax() * 100),
'buyer_fee_cents' => $buyer_fee_cents,
'buyer' => [
'first_name' => isset($billing_first_name) && Helper::not_null_or_empty($billing_first_name) ? $billing_first_name : null,
'last_name' => isset($billing_last_name) && Helper::not_null_or_empty($billing_last_name) ? $billing_last_name : null,
Expand All @@ -169,7 +177,10 @@ public static function order_data_from_wc_order( WC_Order $order ) {
'lines' => self::get_lines_from_order( $order ),
];

return $order_data;
/**
* @since 3.0.2
*/
return apply_filters('mondu_order_data', $order_data, $order);
}

/**
Expand Down
Loading