From 6f7494665551e8abb49dbe88527980091bda7a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20J=C3=BAnior?= Date: Wed, 9 May 2018 00:46:14 -0300 Subject: [PATCH 1/3] Added total price to installments --- assets/js/frontend/transparent-checkout.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/assets/js/frontend/transparent-checkout.js b/assets/js/frontend/transparent-checkout.js index 99b494e..14454ce 100644 --- a/assets/js/frontend/transparent-checkout.js +++ b/assets/js/frontend/transparent-checkout.js @@ -22,8 +22,13 @@ * * @return {string} */ - function pagSeguroGetPriceText( price ) { - return 'R$ ' + parseFloat( price, 10 ).toFixed( 2 ).replace( '.', ',' ).toString(); + function pagSeguroGetPriceText( installment ) { + var installmentParsed = 'R$ ' + parseFloat( installment.installmentAmount, 10 ).toFixed( 2 ).replace( '.', ',' ).toString(); + var totalParsed = 'R$ ' + parseFloat( installment.totalAmount, 10 ).toFixed( 2 ).replace( '.', ',' ).toString(); + var interestFree = ( true === installment.interestFree ) ? ' ' + wc_pagseguro_params.interest_free : ''; + var interestText = interestFree ? interestFree : ' (' + totalParsed + ')'; + + return installment.quantity + 'x ' + installmentParsed + interestText; } /** @@ -34,9 +39,7 @@ * @return {string} */ function pagSeguroGetInstallmentOption( installment ) { - var interestFree = ( true === installment.interestFree ) ? ' ' + wc_pagseguro_params.interest_free : ''; - - return ''; + return ''; } /** From 17ea46291e0f20da7f0c3cedb4945c720bd1b000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20J=C3=BAnior?= Date: Wed, 9 May 2018 00:52:47 -0300 Subject: [PATCH 2/3] Updated version to 2.12.6 --- readme.txt | 10 +++++++--- woocommerce-pagseguro.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index a0d8b96..e84a6cd 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://claudiosanches.com/doacoes/ Tags: woocommerce, pagseguro, payment Requires at least: 4.0 Tested up to: 4.7 -Stable tag: 2.12.5 +Stable tag: 2.12.6 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -255,6 +255,10 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra == Changelog == += 2.12.6 - 2018/05/09 = + +* Adicionado valor total ao parcelamento no checkout transparente para tornar mais prático para o cliente a visualização do juros. + = 2.12.5 - 2017/05/11 = * Corrigido valor total das parcelas do cartão de crédito no checkout transparente, o valor tinha parado de ser atualizado no WooCommerce 3.0. @@ -313,6 +317,6 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra == Upgrade Notice == -= 2.12.5 = += 2.12.6 = -* Corrigido valor total das parcelas do cartão de crédito no checkout transparente, o valor tinha parado de ser atualizado no WooCommerce 3.0. +* Adicionado valor total ao parcelamento no checkout transparente para tornar mais prático para o cliente a visualização do juros. diff --git a/woocommerce-pagseguro.php b/woocommerce-pagseguro.php index ba3a861..0d28ff5 100644 --- a/woocommerce-pagseguro.php +++ b/woocommerce-pagseguro.php @@ -5,7 +5,7 @@ * Description: Includes PagSeguro as a payment gateway to WooCommerce. * Author: Claudio Sanches * Author URI: https://claudiosanches.com - * Version: 2.12.5 + * Version: 2.12.6 * License: GPLv2 or later * Text Domain: woocommerce-pagseguro * Domain Path: /languages @@ -43,7 +43,7 @@ class WC_PagSeguro { * * @var string */ - const VERSION = '2.12.5'; + const VERSION = '2.12.6'; /** * Instance of this class. From 5df1fc19fba152436188a16f47e0314254b91ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20J=C3=BAnior?= Date: Wed, 9 May 2018 01:03:33 -0300 Subject: [PATCH 3/3] Added missing README and minified file from previews commits --- README.md | 10 +++++++--- assets/js/frontend/transparent-checkout.min.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 649bdcd..629994f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** woocommerce, pagseguro, payment **Requires at least:** 4.0 **Tested up to:** 4.7 -**Stable tag:** 2.12.5 +**Stable tag:** 2.12.6 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -267,6 +267,10 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra ## Changelog ## +### 2.12.6 - 2018/05/09 ### + +* Adicionado valor total ao parcelamento no checkout transparente para tornar mais prático para o cliente a visualização do juros. + ### 2.12.5 - 2017/05/11 ### * Corrigido valor total das parcelas do cartão de crédito no checkout transparente, o valor tinha parado de ser atualizado no WooCommerce 3.0. @@ -325,6 +329,6 @@ Por favor, caso você tenha algum problema com o funcionamento do plugin, [abra ## Upgrade Notice ## -### 2.12.5 ### +### 2.12.6 ### -* Corrigido valor total das parcelas do cartão de crédito no checkout transparente, o valor tinha parado de ser atualizado no WooCommerce 3.0. +* Adicionado valor total ao parcelamento no checkout transparente para tornar mais prático para o cliente a visualização do juros. diff --git a/assets/js/frontend/transparent-checkout.min.js b/assets/js/frontend/transparent-checkout.min.js index a711a99..10e8a98 100644 --- a/assets/js/frontend/transparent-checkout.min.js +++ b/assets/js/frontend/transparent-checkout.min.js @@ -1 +1 @@ -!function(a){"use strict";a(function(){function b(b){a("#pagseguro-credit-card-form").attr("data-credit-card-brand",b)}function c(a){return"R$ "+parseFloat(a,10).toFixed(2).replace(".",",").toString()}function d(a){var b=!0===a.interestFree?" "+wc_pagseguro_params.interest_free:"";return'"}function e(b){var c=a("#pagseguro-credit-card-form");a(".woocommerce-error",c).remove(),c.prepend('
'+b+"
")}function f(){var b=a("#pagseguro-payment-methods");1===a("input[type=radio]",b).length&&b.hide()}function g(b){a(".pagseguro-method-form").hide(),a("#pagseguro-payment-methods li").removeClass("active"),a("#pagseguro-"+b+"-form").show(),a("#pagseguro-payment-method-"+b).parent("label").parent("li").addClass("active")}function h(){f(),a("#pagseguro-payment-form").show(),g(a("#pagseguro-payment-methods input[type=radio]:checked").val()),a("#pagseguro-card-holder-cpf").mask("000.000.000-00"),a("#pagseguro-card-holder-birth-date").mask("00/00/0000");var b=function(a){return 11===a.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(a,c,d,e){d.mask(b.apply({},arguments),e)}};a("#pagseguro-card-holder-phone").mask(b,c),a("#pagseguro-bank-transfer-form input[type=radio]:checked").parent("label").parent("li").addClass("active")}function i(){if(j)return j=!1,!0;if(!a("#payment_method_pagseguro").is(":checked"))return!0;if("credit-card"!==a("body li.payment_method_pagseguro input[name=pagseguro_payment_method]:checked").val())return a("form.checkout, form#order_review").append(a('').val(PagSeguroDirectPayment.getSenderHash())),!0;var b=a("form.checkout, form#order_review"),c=a("#pagseguro-credit-card-form",b),d=!1,f="",g=c.attr("data-credit-card-brand"),h=a("#pagseguro-card-number",b).val().replace(/[^\d]/g,""),i=a("#pagseguro-card-cvc",b).val(),k=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(0,2),l=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(2),m=a("#pagseguro-card-installments",b),n=new Date;return f+="
    ",void 0!==g&&"error"!==g||(f+="
  • "+wc_pagseguro_params.invalid_card+"
  • ",d=!0),2===k.length&&4===l.length||(f+="
  • "+wc_pagseguro_params.invalid_expiry+"
  • ",d=!0),2===k.length&&4===l.length&&(k>12||l<=n.getFullYear()-1||l>=n.getFullYear()+20||k"+wc_pagseguro_params.expired_date+"",d=!0),"0"===m.val()&&(f+="
  • "+wc_pagseguro_params.empty_installments+"
  • ",d=!0),f+="
",d?e(f):PagSeguroDirectPayment.createCardToken({brand:g,cardNumber:h,cvv:i,expirationMonth:k,expirationYear:l,success:function(c){a("input[name=pagseguro_credit_card_hash], input[name=pagseguro_credit_card_hash], input[name=pagseguro_installment_value]",b).remove(),b.append(a('').val(c.card.token)),b.append(a('').val(PagSeguroDirectPayment.getSenderHash())),b.append(a('').val(a("option:selected",m).attr("data-installment-value"))),j=!0,b.submit()},error:function(){e(wc_pagseguro_params.general_error)}}),!1}var j=!1;wc_pagseguro_params.session_id?(PagSeguroDirectPayment.setSessionId(wc_pagseguro_params.session_id),"1"===wc_checkout_params.is_checkout?a("body").on("updated_checkout",function(){h()}):h(),a("body").on("click","#pagseguro-bank-transfer-form input[type=radio]",function(){a("#pagseguro-bank-transfer-form li").removeClass("active"),a(this).parent("label").parent("li").addClass("active")}),a("body").on("click","#pagseguro-payment-methods input[type=radio]",function(){g(a(this).val())}),a("body").on("focusout","#pagseguro-card-number",function(){var c=a(this).val().replace(/[^\d]/g,"").substr(0,6),d=a("body #pagseguro-card-installments");6===c.length&&(d.empty(),d.attr("disabled","disabled"),PagSeguroDirectPayment.getBrand({cardBin:c,success:function(c){a("body").trigger("pagseguro_credit_card_brand",c.brand.name),b(c.brand.name)},error:function(){a("body").trigger("pagseguro_credit_card_brand","error"),b("error")}}))}),a("body").on("updated_checkout",function(){var b=a("body #pagseguro-card-number");0--'),a.each(b.installments[c],function(a,b){f.append(d(b))})):e(wc_pagseguro_params.invalid_card)},error:function(){e(wc_pagseguro_params.invalid_card)}}):e(wc_pagseguro_params.invalid_card)}),a("form.checkout").on("checkout_place_order_pagseguro",function(){return i()}),a("form#order_review").submit(function(){return i()})):a("body").on("updated_checkout",function(){a("#pagseguro-payment-form").remove()})})}(jQuery); \ No newline at end of file +!function(a){"use strict";a(function(){function b(b){a("#pagseguro-credit-card-form").attr("data-credit-card-brand",b)}function c(a){var b="R$ "+parseFloat(a.installmentAmount,10).toFixed(2).replace(".",",").toString(),c="R$ "+parseFloat(a.totalAmount,10).toFixed(2).replace(".",",").toString(),d=!0===a.interestFree?" "+wc_pagseguro_params.interest_free:"",e=d||" ("+c+")";return a.quantity+"x "+b+e}function d(a){return'"}function e(b){var c=a("#pagseguro-credit-card-form");a(".woocommerce-error",c).remove(),c.prepend('
'+b+"
")}function f(){var b=a("#pagseguro-payment-methods");1===a("input[type=radio]",b).length&&b.hide()}function g(b){a(".pagseguro-method-form").hide(),a("#pagseguro-payment-methods li").removeClass("active"),a("#pagseguro-"+b+"-form").show(),a("#pagseguro-payment-method-"+b).parent("label").parent("li").addClass("active")}function h(){f(),a("#pagseguro-payment-form").show(),g(a("#pagseguro-payment-methods input[type=radio]:checked").val()),a("#pagseguro-card-holder-cpf").mask("000.000.000-00"),a("#pagseguro-card-holder-birth-date").mask("00/00/0000");var b=function(a){return 11===a.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},c={onKeyPress:function(a,c,d,e){d.mask(b.apply({},arguments),e)}};a("#pagseguro-card-holder-phone").mask(b,c),a("#pagseguro-bank-transfer-form input[type=radio]:checked").parent("label").parent("li").addClass("active")}function i(){if(j)return j=!1,!0;if(!a("#payment_method_pagseguro").is(":checked"))return!0;if("credit-card"!==a("body li.payment_method_pagseguro input[name=pagseguro_payment_method]:checked").val())return a("form.checkout, form#order_review").append(a('').val(PagSeguroDirectPayment.getSenderHash())),!0;var b=a("form.checkout, form#order_review"),c=a("#pagseguro-credit-card-form",b),d=!1,f="",g=c.attr("data-credit-card-brand"),h=a("#pagseguro-card-number",b).val().replace(/[^\d]/g,""),i=a("#pagseguro-card-cvc",b).val(),k=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(0,2),l=a("#pagseguro-card-expiry",b).val().replace(/[^\d]/g,"").substr(2),m=a("#pagseguro-card-installments",b),n=new Date;return f+="
    ",void 0!==g&&"error"!==g||(f+="
  • "+wc_pagseguro_params.invalid_card+"
  • ",d=!0),2===k.length&&4===l.length||(f+="
  • "+wc_pagseguro_params.invalid_expiry+"
  • ",d=!0),2===k.length&&4===l.length&&(k>12||l<=n.getFullYear()-1||l>=n.getFullYear()+20||k"+wc_pagseguro_params.expired_date+"",d=!0),"0"===m.val()&&(f+="
  • "+wc_pagseguro_params.empty_installments+"
  • ",d=!0),f+="
",d?e(f):PagSeguroDirectPayment.createCardToken({brand:g,cardNumber:h,cvv:i,expirationMonth:k,expirationYear:l,success:function(c){a("input[name=pagseguro_credit_card_hash], input[name=pagseguro_credit_card_hash], input[name=pagseguro_installment_value]",b).remove(),b.append(a('').val(c.card.token)),b.append(a('').val(PagSeguroDirectPayment.getSenderHash())),b.append(a('').val(a("option:selected",m).attr("data-installment-value"))),j=!0,b.submit()},error:function(){e(wc_pagseguro_params.general_error)}}),!1}var j=!1;wc_pagseguro_params.session_id?(PagSeguroDirectPayment.setSessionId(wc_pagseguro_params.session_id),"1"===wc_checkout_params.is_checkout?a("body").on("updated_checkout",function(){h()}):h(),a("body").on("click","#pagseguro-bank-transfer-form input[type=radio]",function(){a("#pagseguro-bank-transfer-form li").removeClass("active"),a(this).parent("label").parent("li").addClass("active")}),a("body").on("click","#pagseguro-payment-methods input[type=radio]",function(){g(a(this).val())}),a("body").on("focusout","#pagseguro-card-number",function(){var c=a(this).val().replace(/[^\d]/g,"").substr(0,6),d=a("body #pagseguro-card-installments");6===c.length&&(d.empty(),d.attr("disabled","disabled"),PagSeguroDirectPayment.getBrand({cardBin:c,success:function(c){a("body").trigger("pagseguro_credit_card_brand",c.brand.name),b(c.brand.name)},error:function(){a("body").trigger("pagseguro_credit_card_brand","error"),b("error")}}))}),a("body").on("updated_checkout",function(){var b=a("body #pagseguro-card-number");0--'),a.each(b.installments[c],function(a,b){f.append(d(b))})):e(wc_pagseguro_params.invalid_card)},error:function(){e(wc_pagseguro_params.invalid_card)}}):e(wc_pagseguro_params.invalid_card)}),a("form.checkout").on("checkout_place_order_pagseguro",function(){return i()}),a("form#order_review").submit(function(){return i()})):a("body").on("updated_checkout",function(){a("#pagseguro-payment-form").remove()})})}(jQuery); \ No newline at end of file