From d670dce214b54ce63f831ae303fd547d81ac9b1f Mon Sep 17 00:00:00 2001 From: Guilherme Pressutto Date: Mon, 9 Oct 2017 16:04:45 -0300 Subject: [PATCH] Showing instalments on local currency --- .../class-wc-ebanx-credit-card-br-gateway.php | 1 + .../class-wc-ebanx-credit-card-co-gateway.php | 1 + .../gateways/class-wc-ebanx-credit-card-gateway.php | 2 ++ .../class-wc-ebanx-credit-card-mx-gateway.php | 1 + .../services/class-wc-ebanx-one-click.php | 4 +++- woocommerce-gateway-ebanx/templates/instalments.php | 12 ++++++++++-- 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php index 774774f8..28e96717 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-br-gateway.php @@ -12,6 +12,7 @@ public function __construct() { $this->id = 'ebanx-credit-card-br'; $this->method_title = __('EBANX - Credit Card Brazil', 'woocommerce-gateway-ebanx'); + $this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_BRL; $this->title = 'Cartão de Crédito'; $this->description = 'Pague com cartão de crédito.'; diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php index f85cdf4d..62b37fa3 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-co-gateway.php @@ -13,6 +13,7 @@ public function __construct() { $this->id = 'ebanx-credit-card-co'; $this->method_title = __('EBANX - Credit Card Colombia', 'woocommerce-gateway-ebanx'); + $this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_COP; $this->title = 'Tarjeta de Crédito'; $this->description = 'Pay with credit card.'; diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php index 7eaeed03..0977e719 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-gateway.php @@ -493,6 +493,8 @@ public function payment_fields() { 'currency' => $currency, 'country' => $country, 'instalments_terms' => $instalments_terms, + 'currency' => $this->currency_code, + 'currency_rate' => round(floatval($this->get_local_currency_rate_for_site($this->currency_code)), 2), 'cards' => (array) $cards, 'cart_total' => $cart_total, 'place_order_enabled' => $save_card, diff --git a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php index 11bde1f0..8ffb12d5 100644 --- a/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php +++ b/woocommerce-gateway-ebanx/gateways/class-wc-ebanx-credit-card-mx-gateway.php @@ -13,6 +13,7 @@ public function __construct() { $this->id = 'ebanx-credit-card-mx'; $this->method_title = __('EBANX - Credit Card Mexico', 'woocommerce-gateway-ebanx'); + $this->currency_code = WC_EBANX_Constants::CURRENCY_CODE_MXN; $this->title = 'Tarjeta de Crédito'; $this->description = 'Pay with credit card.'; diff --git a/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php b/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php index 96cf6762..17642f72 100644 --- a/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php +++ b/woocommerce-gateway-ebanx/services/class-wc-ebanx-one-click.php @@ -329,12 +329,15 @@ public function print_button() { $instalments_terms = $this->gateway->get_payment_terms($cart_total, $max_instalments, $tax); $currency = WC_EBANX_Constants::$LOCAL_CURRENCIES[$country]; + $ebanx = new WC_EBANX_Gateway(); $args = apply_filters( 'ebanx_template_args', array( 'cards' => $this->cards, 'cart_total' => $cart_total, 'product_id' => $product->id, 'installment_taxes' => $this->instalment_rates, + 'currency' => $currency, + 'currency_rate' => round(floatval($ebanx->get_local_currency_rate_for_site($currency)), 2), 'label' => __( 'Pay with one click', 'woocommerce-gateway-ebanx' ), 'instalments' => $messages['instalments'], 'instalments_terms' => $instalments_terms, @@ -342,7 +345,6 @@ public function print_button() { 'action' => self::CREATE_ORDER_ACTION, 'permalink' => get_permalink($product->id), 'country' => $country, - 'currency' => $currency, 'should_show_button' => $this->should_show_button(), ) ); diff --git a/woocommerce-gateway-ebanx/templates/instalments.php b/woocommerce-gateway-ebanx/templates/instalments.php index 7a5863f5..9defbade 100644 --- a/woocommerce-gateway-ebanx/templates/instalments.php +++ b/woocommerce-gateway-ebanx/templates/instalments.php @@ -1,5 +1,13 @@ - 1 ) : ?> + 1 ) : ?>