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

Erro de repagamento #1

Open
zhiru opened this issue Dec 10, 2023 · 1 comment
Open

Erro de repagamento #1

zhiru opened this issue Dec 10, 2023 · 1 comment

Comments

@zhiru
Copy link

zhiru commented Dec 10, 2023

Essa função está errada a parte de calculo para quando vai fazer novamente o pagamento aparece só uma opção, com esses ajustes todas as opções aparecem.

Arquivo:

https://github.com/efipay/Plugin-Wordpress-Efi/blob/master/includes/class-gerencianet-oficial.php

function show_hide_payment_methods( $available_gateways ) {

		if ( ! is_checkout() ) {
			return;
		}

		$boletoSettings = maybe_unserialize( get_option( 'woocommerce_' . GERENCIANET_BOLETO_ID . '_settings' ) );
		$cardSettings = maybe_unserialize( get_option( 'woocommerce_' . GERENCIANET_CARTAO_ID . '_settings' ) );

		$boletoEnabled = $boletoSettings['billet_banking'];
		$cardEnabled = $cardSettings['credit_card'];

		$current_shipping_method = WC()->session->get( 'chosen_shipping_methods' );
		$shippingCost = 0;
		foreach ( WC()->cart->get_shipping_packages() as $package_id => $package ) {
			if ( WC()->session->__isset( 'shipping_for_package_' . $package_id ) ) {
				foreach ( WC()->session->get( 'shipping_for_package_' . $package_id )['rates'] as $shipping_rate_id => $shipping_rate ) {
					if ( $shipping_rate->get_id() == $current_shipping_method[0] ) {
						$shippingCost = intval( $shipping_rate->get_cost() );
					}
				}
			}
		}

		global $wp;
		$cartWoo = WC()->cart;
		$subtotal = 0;
		$subtotal = $cartWoo->subtotal;

		if ( isset( $wp->query_vars['order-pay'] ) && absint( $wp->query_vars['order-pay'] ) > 0 ) {
			$order_id = absint( $wp->query_vars['order-pay'] ); // The order ID
			$order = wc_get_order( $order_id ); // Get the WC_Order Object instance
			$subtotal = $order->get_subtotal();
		}

		if ( ( $subtotal + $shippingCost ) < 5 ) {
			wc_clear_notices();
			if ( $boletoEnabled == 'yes' && $cardEnabled == 'yes' ) {
				wc_add_notice( 'O pagamento via Boleto ou Cartão de Crédito só está disponível em pedidos acima de R$5,00', 'notice' );
				unset( $available_gateways[ GERENCIANET_BOLETO_ID ] );
				unset( $available_gateways[ GERENCIANET_CARTAO_ID ] );
			} elseif ( $boletoEnabled == 'yes' ) {
				wc_add_notice( 'O pagamento via Boleto só está disponível em pedidos acima de R$5,00', 'notice' );
				unset( $available_gateways[ GERENCIANET_BOLETO_ID ] );
			} elseif ( $cardEnabled == 'yes' ) {
				wc_add_notice( 'O pagamento via Cartão de Crédito só está disponível em pedidos acima de R$5,00', 'notice' );
				unset( $available_gateways[ GERENCIANET_CARTAO_ID ] );
			}
		}

		return $available_gateways;
	}
@zhiru
Copy link
Author

zhiru commented Dec 15, 2023

mais um erro: class-wc-gerencianet-cartao.php

linha 167

<input id="gn_payment_total" name="gn_payment_total" type="hidden" value="<?php echo WC()->cart->total; ?>">

no repagametno da problema usar assim!

global $wp;
			$cartWoo = WC()->cart;
			$total = 0;
			$total = $cartWoo->total;
			
			if ( isset($wp->query_vars['order-pay']) && absint($wp->query_vars['order-pay']) > 0 ) {
				$order_id = absint($wp->query_vars['order-pay']); // The order ID
				$order    = wc_get_order( $order_id ); // Get the WC_Order Object instance
				$total = $order->get_Total();
			}


<input id="gn_payment_total" name="gn_payment_total" type="hidden" value="<?php echo $total; ?>">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant