Fix Pay later locations according to selected smart button locations

This commit is contained in:
Narek Zakarian 2022-12-19 20:23:09 +04:00
parent edfbf2308c
commit 416881da70
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -1283,6 +1283,24 @@ return array(
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
return $settings->has( 'smart_button_locations' ) ? $settings->get( 'smart_button_locations' ) : array();
$button_locations = $container->get( 'wcgateway.button.locations' );
unset( $button_locations['mini-cart'] );
$smart_button_selected_locations = $settings->has( 'smart_button_locations' ) ? $settings->get( 'smart_button_locations' ) : array();
$pay_later_button_locations = array();
if ( empty( $smart_button_selected_locations ) ) {
return $pay_later_button_locations;
}
foreach ( $button_locations as $location_key => $location ) {
if ( ! in_array( $location_key, $smart_button_selected_locations, true ) ) {
continue;
}
$pay_later_button_locations[ $location_key ] = $location;
}
return $pay_later_button_locations;
},
);