Skip to content

Commit

Permalink
WOOCS compatibilitz
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed May 17, 2022
1 parent 285e416 commit 49fd7fb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
root = true

[*]
indent_style = tab
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
Expand Down
5 changes: 5 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Requires at least WooCommerce 2.6, compatible with WooCommerce 3.2+ (recommended
- [Multi Currency for WooCommerce](https://wordpress.org/plugins/woo-multi-currency/) & PRO
- [WooCommerce Multi-Currency](https://woocommerce.com/products/multi-currency/) when the store currency is USD
- [YayCurrency PRO](https://yaycommerce.com/yaycurrency-woocommerce-multi-currency-switcher/)
- [WOOCS](https://wordpress.org/plugins/woocommerce-currency-switcher/)

= Limitations =
- It seems that Mercadopago gateway is not handling WC_Fee correctly. Get in touch with Mercadopago support (and I'm happy to help them fix the issue)
Expand Down Expand Up @@ -104,6 +105,10 @@ Either post it on [GitHub](https://github.com/vyskoczilova/woocommerce-payforpay

== Changelog ==

= 2.1.7 (2022-05-17) =

* Update: Add support for WOOCS converter.

= 2.1.6 (2022-05-13) =

* Fix: Don't deactivate the plugin even when the WooCommerce is not active (keep a notice only).
Expand Down
45 changes: 45 additions & 0 deletions inc/class-pay4pay-woocs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Handle integration with WooCommerce Multi-Currency
*
* @see https://woocommerce.com/products/multi-currency/
* @package Pay4Pay
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'Pay4Pay_WOOCS' ) ) :

/**
* * Pay4Pay_WOOCS Class
*/
class Pay4Pay_WOOCS {

/**
* Hook actions and filters
*/
public static function init() {
add_filter( 'woocommerce_pay4pay_charges_fixed', array( __CLASS__, 'get_converted_price' ) );
add_filter( 'woocommerce_pay4pay_charges_minimum', array( __CLASS__, 'get_converted_price' ) );
add_filter( 'woocommerce_pay4pay_charges_maximum', array( __CLASS__, 'get_converted_price' ) );
}

/**
* Return the gateway fee by the exchange rate.
*
* @param float $fee The gateway fee.
*/
public static function get_converted_price( $fee ) {
global $WOOCS;
return $WOOCS->woocs_exchange_value($fee);
}
}

// Check if integration exists.
if (class_exists('WOOCS')) {
Pay4Pay_WOOCS::init();
}

endif;
3 changes: 2 additions & 1 deletion woocommerce-payforpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Pay for Payment for WooCommerce
Plugin URI: https://kybernaut.cz/pluginy/woocommerce-pay-for-payment/
Description: Setup individual charges for each payment method in WooCommerce.
Version: 2.1.6
Version: 2.1.7rc1
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
License: GPL-2.0+
Expand Down Expand Up @@ -36,6 +36,7 @@ function pay4payment_plugin_init() {
include_once plugin_dir_path( __FILE__ ) . '/inc/class-pay4pay-woocommerce-multicurrency.php';
include_once plugin_dir_path( __FILE__ ) . '/inc/class-pay4pay-woo-multi-currency.php';
include_once plugin_dir_path( __FILE__ ) . '/inc/class-pay4pay-wcml.php';
include_once plugin_dir_path( __FILE__ ) . '/inc/class-pay4pay-woocs.php';

if ( is_admin() )
require_once plugin_dir_path( __FILE__ ) . '/inc/class-pay4pay-admin.php';
Expand Down

0 comments on commit 49fd7fb

Please sign in to comment.