Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to hide individual credit card logo icons in Smart Buttons, P… #1159

Merged
merged 4 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function __construct($version) {
$this->testmode = 'yes' === $this->testmode_value;
$this->billing_address_value = !empty($this->setting['billing_address']) ? $this->setting['billing_address'] : 'no';
$this->disallowed_funding_methods = !empty($this->setting['disallowed_funding_methods']) ? $this->setting['disallowed_funding_methods'] : array();
if(!in_array('card', $this->disallowed_funding_methods)) {
$this->disallowed_card_types = !empty($this->setting['disallowed_card_types']) ? $this->setting['disallowed_card_types'] : array();
$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_color = !empty($this->setting['button_color']) ? $this->setting['button_color'] : 'gold';
$this->button_shape = !empty($this->setting['button_shape']) ? $this->setting['button_shape'] : 'pill';
Expand Down
9 changes: 9 additions & 0 deletions assets/js/angelleye-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ jQuery(document).ready(function ($) {
if (angelleye_admin.shop_based_us == "no") {
angelleye_woocommerce_paypal_express_disallowed_funding_methods.push("credit");
}
if(jQuery.inArray('card', angelleye_woocommerce_paypal_express_allowed_funding_methods) > -1 === true) {
var woocommerce_paypal_express_disallowed_card_types = jQuery('#woocommerce_paypal_express_disallowed_card_types').val();
if (woocommerce_paypal_express_disallowed_card_types === null) {
woocommerce_paypal_express_disallowed_card_types = [];
}
jQuery.grep(woocommerce_paypal_express_disallowed_card_types, function (value) {
angelleye_woocommerce_paypal_express_disallowed_funding_methods.push(value);
});
}
window.paypalCheckoutReady = function () {
paypal.Button.render({
env: 'sandbox',
Expand Down
1 change: 1 addition & 0 deletions assets/js/angelleye-in-context-checkout.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public function __construct() {
'paypal' => __('PayPal', 'paypal-for-woocommerce')
);
}
$this->disallowed_card_types = array(
'visa' => esc_html_x( 'Visa', 'credit card type', 'paypal-for-woocommerce' ),
'mastercard' => esc_html_x( 'MasterCard', 'credit card type', 'paypal-for-woocommerce' ),
'amex' => esc_html_x( 'American Express', 'credit card type', 'paypal-for-woocommerce' ),
'discover' => esc_html_x( 'Discover', 'credit card type', 'paypal-for-woocommerce' ),
'maestro' => esc_html_x( 'Maestro', 'credit card type', 'paypal-for-woocommerce' ),
'jcb' => esc_html_x( 'JCB', 'credit card type', 'paypal-for-woocommerce' ),
);
$this->init_form_fields();
$this->init_settings();
$this->enable_tokenized_payments = $this->get_option('enable_tokenized_payments', 'no');
Expand Down Expand Up @@ -399,7 +407,11 @@ function is_funding_icon_should_show_php() {
} else {
jQuery('#woocommerce_paypal_express_button_label option[value="credit"]').remove();
}

if( jQuery.inArray('card', jQuery('#woocommerce_paypal_express_disallowed_funding_methods').val()) ) {
jQuery("#woocommerce_paypal_express_disallowed_card_types").closest('tr').show();
} else {
jQuery("#woocommerce_paypal_express_disallowed_card_types").closest('tr').hide();
}
if( is_funding_icon_should_show_php() === false) {
jQuery("#woocommerce_paypal_express_button_fundingicons").closest('tr').hide();
jQuery("#woocommerce_paypal_express_button_fundingicons").val("false");
Expand Down Expand Up @@ -1023,6 +1035,15 @@ public function init_form_fields() {
'desc_tip' => true,
'options' => $this->disallowed_funding_methods_array,
),
'disallowed_card_types' => array(
'title' => __('Hide Card Type(s)', 'paypal-for-woocommerce'),
'type' => 'multiselect',
'class' => 'wc-enhanced-select in_context_checkout_part',
'description' => __('Individual credit card type(s) selected here will be hidden from buyers during checkout.', 'paypal-for-woocommerce'),
'default' => 'medium',
'desc_tip' => true,
'options' => $this->disallowed_card_types,
),
'button_layout' => array(
'title' => __('Button Layout', 'paypal-for-woocommerce'),
'type' => 'select',
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Automatic updates should work great for you. As always, though, we recommend ba
== Changelog ==

= 1.4.12 - xx.xx.2018 =
* Feature - Adds ability to hide individual credit card types from Express Checkout Smart Payment Buttons. ([PFW-179](https://github.com/angelleye/paypal-woocommerce/pull/1159))
* Fix - Resolves an issue where Smart Buttons would not display on Checkout page when Page Setup options were changed from default. ([PFW-147](https://github.com/angelleye/paypal-woocommerce/pull/1151))
* Fix - Resolves some PHP notices. ([PFW-135](https://github.com/angelleye/paypal-woocommerce/pull/1152))
* Fix - Adjusts the check for SSL to coincide with changes made in recent updates to WooCommerce. ([PFW-168](https://github.com/angelleye/paypal-woocommerce/pull/1155))
Expand Down