Skip to content

Commit

Permalink
Express Checkout - JSv4, ref #997
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Mar 9, 2018
1 parent d103f42 commit 7f142c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ public function ec_enqueue_scripts_product_page() {
$js_value = array('is_page_name' => '', 'enable_in_context_checkout_flow' => ( $this->enable_in_context_checkout_flow == 'yes' ? 'yes' : 'no'));
if ($this->angelleye_is_in_context_enable() == true && ( is_checkout() || is_product() || is_cart())) {
$cancel_url = !empty($this->cancel_page) ? get_permalink($this->cancel_page) : wc_get_cart_url();
$allowed_funding_methods_json = json_encode(array_values(array_diff($this->allowed_funding_methods, $this->disallowed_funding_methods)));
if( !empty($this->disallowed_funding_methods['venmo']) ) {
unset($this->disallowed_funding_methods['venmo']);
}
if (($key = array_search('venmo', $this->disallowed_funding_methods)) !== false) {
unset($this->disallowed_funding_methods[$key]);
}
$disallowed_funding_methods_json = json_encode($this->disallowed_funding_methods);
wp_enqueue_script('angelleye-in-context-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true);
wp_enqueue_script('angelleye-in-context-checkout-js-frontend', PAYPAL_FOR_WOOCOMMERCE_ASSET_URL . 'assets/js/angelleye-in-context-checkout.js', array('jquery'), $this->version, true);
wp_localize_script('angelleye-in-context-checkout-js-frontend', 'angelleye_in_content_param', array(
Expand All @@ -498,8 +506,8 @@ public function ec_enqueue_scripts_product_page() {
'button_layout' => $this->button_layout,
'button_fundingicons' => $this->button_fundingicons,
'cancel_page' => $cancel_url,
'allowed_funding_methods' => json_encode($this->allowed_funding_methods),
'disallowed_funding_methods' => json_encode($this->disallowed_funding_methods),
'allowed_funding_methods' => $allowed_funding_methods_json,
'disallowed_funding_methods' => $disallowed_funding_methods_json,
'set_express_checkout' => add_query_arg('pp_action', 'set_express_checkout', add_query_arg('wc-api', 'WC_Gateway_PayPal_Express_AngellEYE', home_url('/')))
)
);
Expand Down
5 changes: 5 additions & 0 deletions assets/js/angelleye-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ jQuery(document).ready(function ($) {
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;
});

var angelleye_woocommerce_paypal_express_disallowed_funding_methods = angelleye_woocommerce_paypal_express_disallowed_funding_methods.filter(function(elem){
return elem !== 'venmo';
});

window.paypalCheckoutReady = function () {
paypal.Button.render({
env: angelleye_env,
Expand Down
10 changes: 3 additions & 7 deletions assets/js/angelleye-in-context-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
}
allowed_funding_methods_var = jQuery.parseJSON(angelleye_in_content_param.allowed_funding_methods);
disallowed_funding_methods_var = jQuery.parseJSON(angelleye_in_content_param.disallowed_funding_methods);
allowed_funding_methods_var = jQuery.grep(allowed_funding_methods_var, function (value) {
return jQuery.inArray(value, disallowed_funding_methods_var) < 0;
});

angelleye_cart_style_object = {size: angelleye_in_content_param.button_size,
color: angelleye_in_content_param.button_color,
shape: angelleye_in_content_param.button_shape,
Expand Down Expand Up @@ -103,11 +101,9 @@

angelleye_in_content_param.allowed_funding_methods = jQuery.parseJSON(angelleye_in_content_param.allowed_funding_methods);
angelleye_in_content_param.disallowed_funding_methods = jQuery.parseJSON(angelleye_in_content_param.disallowed_funding_methods);

window.paypalCheckoutReady = function () {
angelleye_in_content_param.allowed_funding_methods = jQuery.grep(angelleye_in_content_param.allowed_funding_methods, function (value) {
return jQuery.inArray(value, angelleye_in_content_param.disallowed_funding_methods) < 0;
});


var get_attributes = function () {
var select = $('.variations_form').find('.variations select'),
data = {},
Expand Down
3 changes: 2 additions & 1 deletion classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,8 @@ public function init_form_fields() {
'options' => array(
'credit' => __('PayPal Credit', 'paypal-for-woocommerce'),
'card' => __('Credit or Debit card', 'paypal-for-woocommerce'),
'elv' => __('ELV', 'paypal-for-woocommerce')
'elv' => __('ELV', 'paypal-for-woocommerce'),
'venmo' => __('VENMO', 'paypal-for-woocommerce')
),
),
'button_layout' => array(
Expand Down

0 comments on commit 7f142c5

Please sign in to comment.