mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Fix price sorting error by filtering null values before sort
Prevents "TypeError: a is null" when comparing prices.
This commit is contained in:
parent
f038cbc2b0
commit
0eb2f1258a
1 changed files with 10 additions and 6 deletions
|
@ -162,12 +162,16 @@ class SingleProductBootstrap {
|
|||
},
|
||||
]
|
||||
.map( ( f ) => f() )
|
||||
.sort((a, b) => {
|
||||
if (parseInt(a.replace(/\D/g, '')) < parseInt(b.replace(/\D/g, '')) ) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
})
|
||||
.filter( ( val ) => val !== null && val !== undefined )
|
||||
.sort( ( a, b ) => {
|
||||
if (
|
||||
parseInt( a.replace( /\D/g, '' ) ) <
|
||||
parseInt( b.replace( /\D/g, '' ) )
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
} )
|
||||
.find( ( val ) => val );
|
||||
|
||||
if ( typeof priceText === 'undefined' ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue