10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { forceImagesHTTPS } from '../../utils/http.js' ;
13
+ import { errorWithResponse , forceImagesHTTPS } from '../../utils/http.js' ;
14
14
import { gql , parseRating , parseSpecialToDate } from '../../utils/product.js' ;
15
15
16
16
/**
@@ -37,22 +37,26 @@ export const adapter = (config, variants) => variants.map(({ selections, product
37
37
prices : {
38
38
regular : {
39
39
// TODO: determine whether to use min or max
40
- amount : minPrice . regular . amount . value ,
41
- currency : minPrice . regular . amount . currency ,
42
- maximumAmount : maxPrice . regular . amount . value ,
43
- minimumAmount : minPrice . regular . amount . value ,
40
+ amount : minPrice ? .regular . amount . value ,
41
+ currency : minPrice ? .regular . amount . currency ,
42
+ maximumAmount : maxPrice ? .regular . amount . value ,
43
+ minimumAmount : minPrice ? .regular . amount . value ,
44
44
} ,
45
45
final : {
46
46
// TODO: determine whether to use min or max
47
- amount : minPrice . final . amount . value ,
48
- currency : minPrice . final . amount . currency ,
49
- maximumAmount : maxPrice . final . amount . value ,
50
- minimumAmount : minPrice . final . amount . value ,
47
+ amount : minPrice ? .final . amount . value ,
48
+ currency : minPrice ? .final . amount . currency ,
49
+ maximumAmount : maxPrice ? .final . amount . value ,
50
+ minimumAmount : minPrice ? .final . amount . value ,
51
51
} ,
52
52
} ,
53
53
selections : ( selections ?? [ ] ) . sort ( ) ,
54
54
} ;
55
55
56
+ if ( ! minPrice && ! maxPrice ) {
57
+ throw errorWithResponse ( 400 , 'no variant price range found' ) ;
58
+ }
59
+
56
60
if ( config . attributeOverrides ?. variant ) {
57
61
Object . entries ( config . attributeOverrides . variant ) . forEach ( ( [ key , value ] ) => {
58
62
variant . attributeMap [ key ] = variant . attributeMap [ value ] ?? variant [ key ] ;
0 commit comments