@@ -23,8 +23,7 @@ import withRegistration from '../../components/with-registration'
2323import { Skeleton as ImageGallerySkeleton } from '../../components/image-gallery'
2424import { HideOnDesktop , HideOnMobile } from '../../components/responsive'
2525import QuantityPicker from '../../components/quantity-picker'
26- import useToast from '../../hooks/use-toast'
27- import { API_ERROR_MESSAGE } from '../../constants'
26+ import { useErrorHandler } from '../../hooks/use-errors'
2827import DisplayPrice from '../../components/display-price'
2928import Swatch from '../../components/swatch-group/swatch'
3029import SwatchGroup from '../../components/swatch-group'
@@ -114,7 +113,7 @@ const ProductView = forwardRef(
114113 ref
115114 ) => {
116115 const { currency : activeCurrency } = useCurrency ( )
117- const toast = useToast ( )
116+ const showError = useErrorHandler ( )
118117 const intl = useIntl ( )
119118 const location = useLocation ( )
120119 const {
@@ -194,10 +193,10 @@ const ProductView = forwardRef(
194193 const { scrollErrorIntoView = true } = opts
195194 // Validate that all attributes are selected before proceeding.
196195 const hasValidSelection = validateOrderability ( variant , quantity , stockLevel )
197- const showError = ! isProductASet && ! isProductABundle && ! hasValidSelection
198- const scrollToError = showError && scrollErrorIntoView
196+ const hasError = ! isProductASet && ! isProductABundle && ! hasValidSelection
197+ const scrollToError = hasError && scrollErrorIntoView
199198
200- toggleShowOptionsMessage ( showError )
199+ toggleShowOptionsMessage ( hasError )
201200
202201 if ( scrollToError ) {
203202 errorContainerRef . current . scrollIntoView ( {
@@ -242,13 +241,6 @@ const ProductView = forwardRef(
242241 } )
243242 }
244243
245- const showError = ( ) => {
246- toast ( {
247- title : intl . formatMessage ( API_ERROR_MESSAGE ) ,
248- type : 'error'
249- } )
250- }
251-
252244 const handleCartItem = async ( ) => {
253245 const hasValidSelection = validateAndShowError ( )
254246
0 commit comments