fix(storefront): BCTHEME-709 "Out of Stock" banner is duplicated and overlaps "Add to cart" button on PDP#2198
fix(storefront): BCTHEME-709 "Out of Stock" banner is duplicated and overlaps "Add to cart" button on PDP#2198bc-vlad-dlogush wants to merge 1 commit intobigcommerce:masterfrom bc-vlad-dlogush:BCTHEME-709
Conversation
…overlaps "Add to cart" button on PDP
There was a problem hiding this comment.
I do not think this is a proper way to address this issue of the double banner being displayed as it does not work in all cases. Specifically if you have a complex product that does not have any default option values set, see below on my test store where I copied your changes in product-view.html:

The add to cart button is gone but the out of stock message is not displayed. If I were to set at least one default option value then the message would display when loading this page.
Which brings me to my second point. The behavior to display the out of stock message with this code block removed is dependent on an ajax call to the remote product-attributes endpoint. When that call is made, if the response indicates that the product is out of stock then we will display the out of stock message. I do not think we should rely on that ajax call for displaying out of stock on an initial page load and really should try to eliminate use of that call altogether.
I will add some more details shortly about where that call is being made and how I think we should address this issue of the double error messages.
|
This logic here is what is triggering on initial page load whenever there are default option values set. It fires the remote product-attributes ajax call and is using the results to update the option data on the page including the OOS state of the product: This code is what is adding the 2nd error message when the selected option values are OOS: Traditionally this was needed because the context that we provided to the page was incomplete and incorrect for certain situations:
I believe we are at a point now with the stencil context where these items have been corrected and we can move away from making this ajax call on initial page load altogether. The data received in the stencil context should correctly match up with any default selections if there are any and take partial selections into account. The last piece of this was merged yesterday with this fix to OOS labeling when products are tracking inventory by variant: So rather than remove the checks to |
|
In summation, the reasons I recommend going this more complex route for a fix are:
|
|
Hey @bc-vlad-dlogush I had some free time so I made a draft PR to fix the issue while also addressing Jason's points. Feel free to take a look here: |
|
@BC-krasnoshapka @bc-vlad-dlogush can you check out @jordanarldt 's solution to see if this hits all of the points that @bc-jz mentioned? |
What?
This PR removes the duplicate "Out of Stock" banner.
Tickets / Documentation
Screenshots (if appropriate)