Fix an issue with COD not showing when first enabled (https://github.com/woocommerce/woocommerce-blocks/pull/3088)

* Fix issue with COD not showing when first set

* generating changeset for pull request

* generating changeset for pull request

* change condition to arrays only

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Seghir Nadir 2020-09-14 15:36:14 +01:00 committed by GitHub
parent 76ebf9c860
commit 62de2eb6fc
2 changed files with 6 additions and 2 deletions

View File

@ -49,7 +49,7 @@ const canMakePayment = ( { cartNeedsShipping, selectedShippingMethods } ) => {
return false;
}
if ( ! settings.enableForShippingMethods ) {
if ( ! settings.enableForShippingMethods.length ) {
// Store does not limit COD to specific shipping methods.
return true;
}

View File

@ -63,7 +63,11 @@ final class CashOnDelivery extends AbstractPaymentMethodType {
* @return array Array of shipping methods (string ids) that allow COD. (If empty, all support COD.)
*/
private function get_enable_for_methods() {
return $this->get_setting( 'enable_for_methods', [] );
$enable_for_methods = $this->get_setting( 'enable_for_methods', [] );
if ( '' === $enable_for_methods ) {
return [];
}
return $enable_for_methods;
}