Skip to content

Commit

Permalink
Merge pull request #1388 from angelleye/PFW-477
Browse files Browse the repository at this point in the history
Express Checkout - Smart Button Options : PFW-477
  • Loading branch information
kcppdevelopers committed Nov 5, 2019
2 parents 87be0e7 + c510b23 commit ff38391
Show file tree
Hide file tree
Showing 7 changed files with 439 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ public function __construct() {
$this->disallowed_funding_methods = array_merge($this->disallowed_card_types, $this->disallowed_funding_methods);
}
$this->button_size = !empty($this->setting['button_size']) ? $this->setting['button_size'] : 'small';
$this->button_height = !empty($this->setting['button_height']) ? $this->setting['button_height'] : '';
$this->button_color = !empty($this->setting['button_color']) ? $this->setting['button_color'] : 'gold';
$this->button_shape = !empty($this->setting['button_shape']) ? $this->setting['button_shape'] : 'pill';
$this->button_label = !empty($this->setting['button_label']) ? $this->setting['button_label'] : 'checkout';
$this->button_tagline = !empty($this->setting['button_tagline']) ? $this->setting['button_tagline'] : 'false';
$this->button_layout = !empty($this->setting['button_layout']) ? $this->setting['button_layout'] : 'horizontal';
$this->button_fundingicons = !empty($this->setting['button_fundingicons']) ? $this->setting['button_fundingicons'] : 'false';
$this->button_fundingicons = !empty($this->setting['button_fundingicons']) ? $this->setting['button_fundingicons'] : 'true';
// Product Page
$this->single_product_configure_settings_value = !empty($this->setting['single_product_configure_settings']) ? $this->setting['single_product_configure_settings'] : 'no';
$this->single_product_configure_settings = 'yes' === $this->single_product_configure_settings_value;
if($this->single_product_configure_settings) {
$this->single_product_button_layout = !empty($this->setting['single_product_button_layout']) ? $this->setting['single_product_button_layout'] : 'horizontal';
$this->single_product_button_size = !empty($this->setting['single_product_button_size']) ? $this->setting['single_product_button_size'] : 'small';
$this->single_product_button_height = !empty($this->setting['single_product_button_height']) ? $this->setting['single_product_button_height'] : '';
$this->single_product_disallowed_funding_methods = !empty($this->setting['single_product_disallowed_funding_methods']) ? $this->setting['single_product_disallowed_funding_methods'] : array();
if (!in_array('card', $this->single_product_disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
Expand All @@ -97,6 +99,7 @@ public function __construct() {
if($this->cart_configure_settings) {
$this->cart_button_layout = !empty($this->setting['cart_button_layout']) ? $this->setting['cart_button_layout'] : 'horizontal';
$this->cart_button_size = !empty($this->setting['cart_button_size']) ? $this->setting['cart_button_size'] : 'small';
$this->cart_button_height = !empty($this->setting['cart_button_height']) ? $this->setting['cart_button_height'] : '';
$this->cart_disallowed_funding_methods = !empty($this->setting['cart_disallowed_funding_methods']) ? $this->setting['cart_disallowed_funding_methods'] : array();
if (!in_array('card', $this->cart_disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
Expand All @@ -109,6 +112,7 @@ public function __construct() {
if($this->mini_cart_configure_settings) {
$this->mini_cart_button_layout = !empty($this->setting['mini_cart_button_layout']) ? $this->setting['mini_cart_button_layout'] : 'horizontal';
$this->mini_cart_button_size = !empty($this->setting['mini_cart_button_size']) ? $this->setting['mini_cart_button_size'] : 'small';
$this->mini_cart_button_height = !empty($this->setting['mini_cart_button_height']) ? $this->setting['mini_cart_button_height'] : '';
$this->mini_cart_disallowed_funding_methods = !empty($this->setting['mini_cart_disallowed_funding_methods']) ? $this->setting['mini_cart_disallowed_funding_methods'] : array();
if (!in_array('card', $this->mini_cart_disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
Expand All @@ -121,6 +125,7 @@ public function __construct() {
if($this->checkout_page_configure_settings) {
$this->checkout_page_button_layout = !empty($this->setting['checkout_page_button_layout']) ? $this->setting['checkout_page_button_layout'] : 'horizontal';
$this->checkout_page_button_size = !empty($this->setting['checkout_page_button_size']) ? $this->setting['checkout_page_button_size'] : 'small';
$this->checkout_page_button_height = !empty($this->setting['checkout_page_button_height']) ? $this->setting['checkout_page_button_height'] : '';
$this->checkout_page_disallowed_funding_methods = !empty($this->setting['checkout_page_disallowed_funding_methods']) ? $this->setting['checkout_page_disallowed_funding_methods'] : array();
if (!in_array('card', $this->checkout_page_disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
Expand All @@ -133,6 +138,7 @@ public function __construct() {
if($this->wsc_cart_configure_settings) {
$this->wsc_cart_button_layout = !empty($this->setting['wsc_cart_button_layout']) ? $this->setting['wsc_cart_button_layout'] : 'horizontal';
$this->wsc_cart_button_size = !empty($this->setting['wsc_cart_button_size']) ? $this->setting['wsc_cart_button_size'] : 'small';
$this->wsc_cart_button_height = !empty($this->setting['wsc_cart_button_height']) ? $this->setting['wsc_cart_button_height'] : '';
$this->wsc_cart_disallowed_funding_methods = !empty($this->setting['wsc_cart_disallowed_funding_methods']) ? $this->setting['wsc_cart_disallowed_funding_methods'] : array();
if (!in_array('card', $this->mini_cart_disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
Expand Down Expand Up @@ -598,50 +604,55 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) {
if(is_product() && $this->single_product_configure_settings) {
$this->button_layout = $this->single_product_button_layout;
$this->button_size = $this->single_product_button_size;
$this->button_height = $this->single_product_button_height;
$this->disallowed_funding_methods = $this->single_product_disallowed_funding_methods;
$smart_cancel_page = wc_get_cart_url();
} elseif(is_cart() && $this->cart_configure_settings) {
$this->button_layout = $this->cart_button_layout;
$this->button_size = $this->cart_button_size;
$this->button_height = $this->cart_button_height;
$this->disallowed_funding_methods = $this->cart_disallowed_funding_methods;
$smart_cancel_page = wc_get_cart_url();
} elseif (is_checkout() && $this->checkout_page_configure_settings) {
$this->button_layout = $this->checkout_page_button_layout;
$this->button_size = $this->checkout_page_button_size;
$this->button_height = $this->checkout_page_button_height;
$this->disallowed_funding_methods = $this->checkout_page_disallowed_funding_methods;
$smart_cancel_page = wc_get_checkout_url();
}
if($this->mini_cart_configure_settings == false) {
$this->mini_cart_button_layout = $this->button_layout;
$this->mini_cart_button_size = $this->button_size;
$this->mini_cart_button_height = $this->button_height;
$this->mini_cart_disallowed_funding_methods = $this->disallowed_funding_methods;
$smart_cancel_page = wc_get_cart_url();
}
$this->mini_cart_allowed_funding_methods = $this->allowed_funding_methods;
if($this->wsc_cart_configure_settings == false) {
$this->wsc_cart_button_layout = $this->button_layout;
$this->wsc_cart_button_size = $this->button_size;
$this->wsc_cart_button_height = $this->button_height;
$this->wsc_cart_disallowed_funding_methods = $this->disallowed_funding_methods;
}
$this->wsc_cart_allowed_funding_methods = $this->allowed_funding_methods;
if ($this->button_layout == 'vertical') {
$this->button_label = '';
$this->button_tagline = '';
$this->button_fundingicons = '';
if ($this->button_size == 'small') {
$this->button_size = 'medium';
}
if ($this->button_label == 'credit') {
$this->button_label = 'checkout';
}
}
if ($this->mini_cart_button_layout == 'vertical') {
$this->button_label = '';
$this->button_tagline = '';
$this->button_fundingicons = '';
if ($this->mini_cart_button_size == 'small') {
$this->mini_cart_button_size = 'medium';
}
}
if ($this->wsc_cart_button_layout == 'vertical') {
$this->button_label = '';
$this->button_tagline = '';
$this->button_fundingicons = '';
if ($this->mini_cart_button_size == 'small') {
Expand Down Expand Up @@ -692,7 +703,9 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) {
'cart_button_possition' => $this->button_position,
'is_display_on_checkout' => ($this->show_on_checkout == 'top' || $this->show_on_checkout == 'both' ) ? 'yes' : 'no',
'button_size' => $this->button_size,
'button_height' => $this->button_height,
'mini_cart_button_size' => $this->mini_cart_button_size,
'mini_cart_button_height' => $this->mini_cart_button_height,
'button_color' => $this->button_color,
'button_shape' => $this->button_shape,
'button_label' => $this->button_label,
Expand All @@ -701,6 +714,7 @@ public function ec_enqueue_scripts_product_page($is_mini_cart = false) {
'mini_cart_button_layout' => $this->mini_cart_button_layout,
'wsc_cart_button_layout' => $this->wsc_cart_button_layout,
'wsc_cart_button_size' => $this->wsc_cart_button_size,
'wsc_cart_button_height' => $this->wsc_cart_button_height,
'button_fundingicons' => $this->button_fundingicons,
'cancel_page' => add_query_arg('pp_action', 'cancel_order', WC()->api_request_url('WC_Gateway_PayPal_Express_AngellEYE')),
'smart_cancel_page' => $smart_cancel_page,
Expand Down
18 changes: 13 additions & 5 deletions assets/js/angelleye-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jQuery(document).ready(function ($) {
}
jQuery("#woocommerce_paypal_express_enable_in_context_checkout_flow").change(function () {
if (jQuery(this).is(':checked')) {
jQuery('.in_context_checkout_part_other').show();
jQuery('.in_context_checkout_part_other').next('p').show();
jQuery('.in_context_checkout_part_other').parents('table').show();
jQuery('.display_smart_button_previews').show();
jQuery('.angelleye_button_settings_selector').show();
jQuery('#woocommerce_paypal_express_show_paypal_credit').closest('tr').hide();
Expand All @@ -55,10 +58,9 @@ jQuery(document).ready(function ($) {
jQuery('#woocommerce_paypal_express_checkout_with_pp_button_type').closest('tr').show();
jQuery('.angelleye_smart_button_setting_left').hide();
jQuery('woocommerce_paypal_express_enable_google_analytics_click').closest('tr').show();
jQuery('.in_context_checkout_part').hide();
jQuery('.in_context_checkout_part').next('p').hide();
jQuery('.in_context_checkout_part').parents('table').hide();

jQuery('.in_context_checkout_part_other').parents('table').hide();
jQuery('.in_context_checkout_part_other').hide();
jQuery('.in_context_checkout_part_other').next('p').hide();
}
}).change();
$("#woocommerce_paypal_express_customer_service_number").attr("maxlength", "16");
Expand Down Expand Up @@ -385,6 +387,7 @@ jQuery(document).ready(function ($) {
var payer_id = jQuery('#woocommerce_paypal_express_api_username').val();
}
var angelleye_size = jQuery("#woocommerce_paypal_express_button_size").val();
var angelleye_height = jQuery("#woocommerce_paypal_express_button_height").val();
var angelleye_color = jQuery("#woocommerce_paypal_express_button_color").val();
var angelleye_shape = jQuery("#woocommerce_paypal_express_button_shape").val();
var angelleye_label = jQuery("#woocommerce_paypal_express_button_label").val();
Expand All @@ -401,12 +404,14 @@ jQuery(document).ready(function ($) {
angelleye_woocommerce_paypal_express_disallowed_funding_methods = [];
}
if (angelleye_layout === 'vertical') {
angelleye_label = '';
angelleye_tagline = '';
angelleye_fundingicons = '';
if (angelleye_size === 'small') {
angelleye_size = 'medium';
}
if (angelleye_label === 'credit') {
angelleye_label = 'checkout';
}
}
if (angelleye_label === 'credit') {
angelleye_color = 'darkblue';
Expand All @@ -428,6 +433,9 @@ jQuery(document).ready(function ($) {
if (angelleye_layout === 'horizontal' && (jQuery.inArray('card', disallowed_funding_methods) > -1 === false) && angelleye_label !== 'credit' && angelleye_fundingicons === "true") {
style_object['fundingicons'] = ( angelleye_fundingicons === "true" ) ? true : false;
}
if( angelleye_height !== '' ) {
style_object['height'] = parseInt(angelleye_height);
}
angelleye_woocommerce_paypal_express_allowed_funding_methods = jQuery.grep(angelleye_woocommerce_paypal_express_allowed_funding_methods, function (value) {
return jQuery.inArray(value, angelleye_woocommerce_paypal_express_disallowed_funding_methods) < 0;
});
Expand Down
15 changes: 15 additions & 0 deletions assets/js/angelleye-in-context-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jQuery(function ($) {
if (angelleye_in_content_param.button_layout === 'horizontal' && is_funding_icon_should_show_in_content() === true && angelleye_in_content_param.button_label !== 'credit' && angelleye_in_content_param.button_fundingicons === "true") {
angelleye_cart_style_object['fundingicons'] = (angelleye_in_content_param.button_fundingicons === "true") ? true : false;
}
if( typeof angelleye_in_content_param.button_height !== "undefined" && angelleye_in_content_param.button_height !== '' ) {
angelleye_cart_style_object['height'] = parseInt(angelleye_in_content_param.button_height);
}
$('.angelleye_button_single').empty();
paypal.Button.render({
env: angelleye_in_content_param.environment,
Expand Down Expand Up @@ -158,6 +161,9 @@ jQuery(function ($) {
layout: angelleye_in_content_param.button_layout,
tagline: (angelleye_in_content_param.button_tagline === "true") ? true : false
};
if( typeof angelleye_in_content_param.button_height !== "undefined" && angelleye_in_content_param.button_height !== '' ) {
angelleye_cart_style_object['height'] = parseInt(angelleye_in_content_param.button_height);
}
angelleye_button_selector.forEach(function (selector) {
$(selector).html("");
disallowed_funding_methods_var = $.grep(disallowed_funding_methods_var, function (value) {
Expand Down Expand Up @@ -252,6 +258,9 @@ jQuery(function ($) {
layout: angelleye_in_content_param.mini_cart_button_layout,
tagline: (angelleye_in_content_param.button_tagline === "true") ? true : false
};
if( typeof angelleye_in_content_param.mini_cart_button_height !== "undefined" && angelleye_in_content_param.mini_cart_button_height !== '' ) {
angelleye_cart_style_object['height'] = parseInt(angelleye_in_content_param.mini_cart_button_height);
}
angelleye_button_selector.forEach(function (selector) {
$(selector).html("");
disallowed_funding_methods_var = $.grep(disallowed_funding_methods_var, function (value) {
Expand Down Expand Up @@ -341,6 +350,9 @@ jQuery(function ($) {
layout: angelleye_in_content_param.wsc_cart_button_layout,
tagline: (angelleye_in_content_param.button_tagline === "true") ? true : false
};
if( typeof angelleye_in_content_param.wsc_cart_button_height !== "undefined" && angelleye_in_content_param.wsc_cart_button_height !== '' ) {
angelleye_cart_style_object['height'] = parseInt(angelleye_in_content_param.wsc_cart_button_height);
}
angelleye_button_selector.forEach(function (selector) {
$(selector).html("");
disallowed_funding_methods_var = $.grep(disallowed_funding_methods_var, function (value) {
Expand Down Expand Up @@ -430,6 +442,9 @@ jQuery(function ($) {
layout: angelleye_in_content_param.button_layout,
tagline: (angelleye_in_content_param.button_tagline === "true") ? true : false
};
if( typeof angelleye_in_content_param.button_height !== "undefined" && angelleye_in_content_param.button_height !== '' ) {
angelleye_cart_style_object['height'] = parseInt(angelleye_in_content_param.button_height);
}
angelleye_button_selector.forEach(function (selector) {
$(selector).html("");
disallowed_funding_methods_var = $.grep(disallowed_funding_methods_var, function (value) {
Expand Down
Loading

0 comments on commit ff38391

Please sign in to comment.