Skip to content

Commit

Permalink
Merge pull request #1324 from angelleye/PFW-430
Browse files Browse the repository at this point in the history
PayPal Smart button not display on Checkout page : PFW-430
  • Loading branch information
kcppdevelopers committed Jul 10, 2019
2 parents 60911e0 + b64602d commit e625566
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ public function angelleye_is_in_context_enable() {
}
}
if (is_checkout()) {
if ($this->show_on_checkout == 'top' || $this->show_on_checkout == 'both') {
if ($this->show_on_checkout == 'top' || $this->show_on_checkout == 'both' || ( $this->show_on_checkout == 'regular' && $this->checkout_page_disable_smart_button == false)) {
return true;
}
}
Expand Down
35 changes: 24 additions & 11 deletions assets/js/angelleye-in-context-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,33 +540,46 @@ jQuery(function ($) {
} );

if(angelleye_in_content_param.checkout_page_disable_smart_button === "no") {
$( 'form.checkout' ).on( 'click', 'input[name="payment_method"]', function() {
var isPPEC = $( this ).is( '#payment_method_paypal_express' );
if (isPPEC && $('input[name="wc-paypal_express-payment-token"]').length && $('input[name="wc-paypal_express-payment-token"]:checked').val() === 'new') {
console.log('546');
$(document.body).on('updated_checkout wc-credit-card-form-init update_checkout', function (event) {
angelleye_manage_smart_button();
});
function angelleye_manage_smart_button() {
var is_checked = $('#payment_method_paypal_express').is(':checked');
if($('input[name="wc-paypal_express-payment-token"]:checked').length > 0) {
if (is_checked && $('input[name="wc-paypal_express-payment-token"]').length && $('input[name="wc-paypal_express-payment-token"]:checked').val() === 'new') {
$( '#place_order' ).hide();
$( '.angelleye_smart_button_checkout_bottom' ).show();
} else if(isPPEC && $('input[name="wc-paypal_express-payment-token"]').length && $('input[name="wc-paypal_express-payment-token"]:checked').val() !== 'new') {
console.log('550');
} else if(is_checked && $('input[name="wc-paypal_express-payment-token"]').length && $('input[name="wc-paypal_express-payment-token"]:checked').val() !== 'new') {
$( '#place_order' ).show();
$( '.angelleye_smart_button_checkout_bottom' ).hide();
} else if(is_checked) {
$( '.angelleye_smart_button_checkout_bottom' ).show();
$( '#place_order' ).hide();
} else {
console.log('554');
$( '.angelleye_smart_button_checkout_bottom' ).hide();
$( '#place_order' ).show();
}
} else {
if(is_checked) {
$( '.angelleye_smart_button_checkout_bottom' ).show();
$( '#place_order' ).hide();
} else {
$( '.angelleye_smart_button_checkout_bottom' ).hide();
$( '#place_order' ).show();
}
}
}
$( 'form.checkout' ).on( 'click', 'input[name="payment_method"]', function() {
angelleye_manage_smart_button();
} );
$( 'form.checkout' ).on( 'click', 'input[name="wc-paypal_express-payment-token"]', function() {
console.log($(this).val());
if ($(this).val() === 'new') {
console.log('561');
$( '#place_order' ).hide();
$( '.angelleye_smart_button_checkout_bottom' ).show();
} else if($(this).val() !== 'new') {
console.log('565');
$( '#place_order' ).show();
$( '.angelleye_smart_button_checkout_bottom' ).hide();
}
});
}
}
});
Loading

0 comments on commit e625566

Please sign in to comment.