diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml
index ca7702e..33fbbe2 100644
--- a/view/frontend/layout/catalog_product_view.xml
+++ b/view/frontend/layout/catalog_product_view.xml
@@ -10,14 +10,11 @@
-
+
-
-
-
\ No newline at end of file
diff --git a/view/frontend/layout/catalog_product_view_type_bundle.xml b/view/frontend/layout/catalog_product_view_type_bundle.xml
index 7f7dff8..275cc8e 100644
--- a/view/frontend/layout/catalog_product_view_type_bundle.xml
+++ b/view/frontend/layout/catalog_product_view_type_bundle.xml
@@ -9,6 +9,6 @@
-->
-
+
\ No newline at end of file
diff --git a/view/frontend/templates/afterpay/cart.phtml b/view/frontend/templates/afterpay/cart.phtml
index 1785126..86e6dfa 100644
--- a/view/frontend/templates/afterpay/cart.phtml
+++ b/view/frontend/templates/afterpay/cart.phtml
@@ -5,20 +5,43 @@
* @author Afterpay
* @copyright 2016-2020 Afterpay https://www.afterpay.com
*/
-?>
-canShow()) : ?>
-
- getCartPageText();
- echo $assets_cart_page['snippet1'];
- ?>
- getInstallmentsTotalHtml();?>
-
-
+if($block->isPaymentMethodActive() && $block->isDisplayOnCartPage() && $block->canUseCurrency() ){
+ $afterpay_eligible = "true";
+ if (($block->canShow() === false)) {
+ $afterpay_eligible = "false";
+ }
+
+ $min_limit=$block->getMinOrderLimit();
+ $max_limit=$block->getMaxOrderLimit();
+ $show_lower_limit="true";
+ if((float)$min_limit<1){
+ $show_lower_limit="false";
+ }
+ ?>
+ getCurrentCurrency();
+ $data_locale = $block->getCurrentLocale();
+ $data_amount = $block->getFinalAmount();
+ $enable_cbt = $this->helper('Afterpay\Afterpay\Helper\Data')->getConfig('payment/afterpaypayovertime/enable_cbt');
+ $data_enable_cbt = ! empty($enable_cbt) ? "true" : "false";
+?>
+
+=$min_limit && $data_amount<=$max_limit && $afterpay_eligible!="false" ){?>
-
+
diff --git a/view/frontend/templates/afterpay/product.phtml b/view/frontend/templates/afterpay/product.phtml
index 0998c9b..207568e 100644
--- a/view/frontend/templates/afterpay/product.phtml
+++ b/view/frontend/templates/afterpay/product.phtml
@@ -5,27 +5,37 @@
* @author Afterpay
* @copyright 2016-2020 Afterpay https://www.afterpay.com
*/
-?>
-getTypeOfProduct();
-$display="";
-//Check currency and if Afterpay is enabled
-if($block->canShow() && $product_type!="grouped") :
-if(!$block->isProductEligible()){
- $display="display:none";
+$product_type = $block->getTypeOfProduct();
+
+if($block->isPaymentMethodActive() && $block->isDisplayOnProductPage() && $product_type != "grouped" && $block->canUseCurrency()){
+ $afterpay_eligible = "true";
+ if (($block->canShow() === false)) {
+ $afterpay_eligible = "false";
+ }
+ $min_limit=$block->getMinOrderLimit();
+ $show_lower_limit="true";
+ if((float)$min_limit<1){
+ $show_lower_limit="false";
+ }
+ ?>
+
+ getCurrentCurrency();
+ $data_locale = $block->getCurrentLocale();
+ $data_amount = $block->getFinalAmount();
+ $enable_cbt = $this->helper('Afterpay\Afterpay\Helper\Data')->getConfig('payment/afterpaypayovertime/enable_cbt');
+ $data_enable_cbt = ! empty($enable_cbt) ? "true" : "false";
+ ?>
+
+
-
- getInstalmentText();
- echo $assets_product_page['snippet1'];
- ?>
- getInstallmentsAmount(); ?>
-
-
-
-
diff --git a/view/frontend/web/js/view/cart/afterpay-cart.js b/view/frontend/web/js/view/cart/afterpay-cart.js
index c67da82..194ad57 100644
--- a/view/frontend/web/js/view/cart/afterpay-cart.js
+++ b/view/frontend/web/js/view/cart/afterpay-cart.js
@@ -12,10 +12,8 @@ require(
$(".cart-totals").bind("DOMSubtreeModified", function() {
var totals = quote.getTotals()();
- var instalment_price = parseFloat(Math.round(totals['base_grand_total'] / 4 * 100) / 100);
- var format = {decimalSymbol: '.',pattern:'$%s'};
- var formatted_instalment_price = priceUtils.formatPrice(instalment_price,format);
- $('.payment-method-note.afterpay-checkout-note .afterpay_instalment_price').text(formatted_instalment_price);
+ $('afterpay-placement').attr('data-amount',totals['base_grand_total']);
+
});
}
);
\ No newline at end of file
diff --git a/view/frontend/web/js/view/product/afterpay-products.js b/view/frontend/web/js/view/product/afterpay-products.js
index aa0056c..bc0275c 100644
--- a/view/frontend/web/js/view/product/afterpay-products.js
+++ b/view/frontend/web/js/view/product/afterpay-products.js
@@ -8,18 +8,12 @@ require(
"Magento_Catalog/js/price-utils"
],
function ( $, priceUtils, quote ) {
-
- var afterpay_instalment_element = $('.afterpay-installments.afterpay-installments-amount');
-
- var max_limit = afterpay_instalment_element.attr('maxLimit');
- var min_limit = afterpay_instalment_element.attr('minLimit');
- var product_type = afterpay_instalment_element.attr('product_type');
$(document).ready(function($) {
- setInstalment(afterpay_instalment_element, max_limit, min_limit);
-
+ setFinalAmount();
+
$('body').on('click change', $('form#product_addtocart_form'), function (e) {
- setInstalment(afterpay_instalment_element, max_limit, min_limit);
+ setFinalAmount();
});
$('body').on('input', $('form#product_addtocart_form select'), function (e) {
setTimeout(function() {
@@ -28,14 +22,9 @@ require(
});
});
- function setInstalment(afterpay_instalment_element, max_limit, min_limit)
- {
- //var price_raw = $('span.price-final_price > span.price-wrapper > span.price:first');
- //Above line only extracts the value from first price element product page. This might cause problem in some cases
- if(product_type=="bundle" && $("[data-price-type=minPrice]:first").text()!=""){
- var price_raw = $("[data-price-type=minPrice]:first").text();
- }
- else if($("[data-price-type=finalPrice]:first").text()!=""){
+ function setFinalAmount(){
+
+ if($("[data-price-type=finalPrice]:first").text()!=""){
var price_raw = $("[data-price-type=finalPrice]:first").text();
}
else{
@@ -43,31 +32,20 @@ require(
}
var price = price_raw.match(/[\d\.]+/g);
-
+
+ var product_variant_price=parseFloat($('span.price-final_price > span[data-price-type="finalPrice"]').attr('data-price-amount'));
if(price != null){
if (price[1]) {
product_variant_price = price[0]+price[1];
} else {
product_variant_price = price[0];
}
- var instalment_price = parseFloat(Math.round(product_variant_price / 4 * 100) / 100);
-
- //pass the price format object - fix for the group product format
-
- var format = {decimalSymbol: '.',pattern:'$%s'};
- var formatted_instalment_price = priceUtils.formatPrice(instalment_price,format);
-
- $('.afterpay-installments.afterpay-installments-amount .afterpay_instalment_price').text(formatted_instalment_price);
-
- if (parseFloat(product_variant_price) >= parseFloat(min_limit) && parseFloat(product_variant_price) <= parseFloat(max_limit)) {
- afterpay_instalment_element.show();
- } else {
- afterpay_instalment_element.hide();
- }
- }
- else{
- afterpay_instalment_element.hide();
}
+
+ $('afterpay-placement').attr('data-amount',product_variant_price);
+
}
+
}
-);
\ No newline at end of file
+);
+