Skip to content

Commit

Permalink
🐛 FIX: Unsupported operand types (Mercadopago)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed May 28, 2020
1 parent 621bb63 commit 2ce36d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Previous versions have been created by [Jörn Lund](https://github.com/mcguffin)

Unreleased updates
------------------
* Fix Mercadopago compatibility issue

Plugin API
----------
Expand Down
18 changes: 9 additions & 9 deletions inc/class-pay4pay-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ private function __construct() {
// payment gateways table
add_filter( 'woocommerce_payment_gateways_setting_columns', array( $this, 'add_extra_fee_column' ) );
add_action( 'woocommerce_payment_gateways_setting_column_pay4pay_extra', array( $this, 'extra_fee_column_content' ) );

// add save actions for every single method - related to: https://github.com/woocommerce/woocommerce/pull/23091
if ( version_compare( WC_VERSION, '3.7', '>=' )) {
if ( version_compare( WC_VERSION, '3.7', '>=' )) {
add_action( 'wp_loaded', array( $this, 'save_actions_for_every_method' ) );
}

Expand Down Expand Up @@ -230,26 +230,26 @@ public function add_payment_options( ) {

foreach ( WC()->payment_gateways()->payment_gateways() as $gateway_id => $gateway ) {
$form_fields['pay4pay_item_title']['default'] = $gateway->title;
$gateway->form_fields += $form_fields;
if ( version_compare( WC_VERSION, '3.7', '<' )) {
$gateway->form_fields = array_merge($gateway->form_fields, $form_fields); // Fix Mercadopago integration
if ( version_compare( WC_VERSION, '3.7', '<' )) {
add_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id, array( $this,'update_payment_options' ), 20 );
}
}
}

public function update_payment_options() {
global $current_section;

$class_id = $current_section;
$prefix = 'woocommerce_' . $class_id;
$postfix = '_settings';

// Default WooCommerce gateways use this option name format
$opt_name = $prefix . $postfix;

// Try to get the WooCommerce Gateway settings with default format
$options = get_option( $opt_name );

// Try to get the WooComm erce Gateway settings with fallback format
if ( $options === false ) {
$opt_name = $class_id . $postfix;
Expand All @@ -262,7 +262,7 @@ public function update_payment_options() {
add_action( 'admin_notices', array( $this, 'update_error_notice') );
return;
}

$tax_class_sanitize = ( isset( $_POST[$prefix . '_pay4pay_tax_class'] )? $_POST[$prefix . '_pay4pay_tax_class'] : '' );

$item_title = sanitize_text_field( $_POST[$prefix . '_pay4pay_item_title'] );
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-payforpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: WooCommerce Pay for Payment
Plugin URI: https://kybernaut.cz/pluginy/woocommerce-pay-for-payment/
Description: Setup individual charges for each payment method in WooCommerce.
Version: 2.0.15
Version: 2.0.15.1
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
License: GPL-2.0+
Expand Down

0 comments on commit 2ce36d1

Please sign in to comment.