Closed jorgeatorres closed 3 years ago
Nice work @jorgeatorres and thanks for the clear testing instructions!!
My checkout is still showing the Pay Later button even though I'm hiding the PayPal Credit option in my PPEC Settings :(
I found the issue is that it doesn't like my disallowed_methods
array keys going from [0] to [2] and it seems we need to reindex/reorder the array:
[disallowed_methods] => Array
(
[0] => CREDIT
[2] => PAYLATER
)
This is being caused by the array_unique
and array_merge
i assume:
$hide_funding_methods = $settings->{ $prefix . 'hide_funding_methods' };
$hide_funding_methods = is_array( $hide_funding_methods ) ? $hide_funding_methods : array();
$data['disallowed_methods'] = array_unique(
array_merge(
$hide_funding_methods,
( ! $credit_supported || in_array( 'CREDIT', $hide_funding_methods, true ) ) ? array( 'CREDIT', 'PAYLATER' ) : array()
)
);
Hi @mattallan!
Thanks for reviewing. You're absolutely right, it's because the array is no longer indexed sequentially and so wp_localize_script()
turns it into a regular object instead.
I've pushed some code to make sure it's an array on the PHP side but also make sure our function on the JS side is more robust and can work with objects, just in case.
Let me know what you think!
I like it! Much nicer fix than what I was thinking :) (I didn't see the foreach loop using $i++
in JS)
LGTM :100:
Description
Pay Pal is rolling out a "Pay Later" button to replace the current "PayPal Credit" button. This change is already available in sandbox mode and will make it to the live environment soon.
This PR updates our code so that hiding "Credit" as a funding source results in "Pay Later" being hidden too. It also simplifies some of the code dealing with Credit in
WC_Gateway_PPEC_Cart_Handler::get_button_settings()
.Steps to test:
trunk
.paylater
).Documentation
We might need to update screenshots referring to "PayPal Credit".
Changelog entry
Hide "Pay Later" funding method when "Credit" is disabled.