Display Products inventory status at search results page

General ShopSite user discussion

Display Products inventory status at search results page

Postby MichelleC » Mon Feb 02, 2009 2:33 pm

HELP! if anyone out there can review this code and tell me what is missing/why not working, desperately needed and greatly appreciated.

Following help shared here, we set our products to display per the settings at back office for inventory and Quantity on hand.
So, if the quantity on hand is set to "0" for a product, the product info displays but a dimmed image shows up (and will not put product in cart), and text displays saying product is out of stock. This works GREAT at SKU level, and displays correctly at Product/More Info pages.

When we tried to have similar results at the Search Products display page= it is only half working.
So, all code displays correctly, and works for QOH "0" settings. But when a product is in inventory, the Add to Cart button is non functioning.
See at www.vdcusa.com and type Peenuts in Site Search box.
----
Here is the code- maybe I am missing something very obvious here- I can't see it. Stuck in rock and hard place here= happy with inventory status at product pages, but have had customers call complaining about the add to cart button at search results not allowing them to add the product to cart (because, it is broken live and won't)
ANY Help SO appreciated! THANKS!
-------
[-- DEFINE PRODUCT --]
[-- IF PRODUCT.DisplayMoreInformationPage --]
<script type="text/javascript">
function YouSave(){
var MSRP = "[-- PRODUCT.Price --]".substr(1);
var OurPrice = "[-- PRODUCT.SaleAmount --]".substr(1);
Savings = Math.round((MSRP - OurPrice) / MSRP * 100)
document.write("<p style='color:#003978; font-weight:bold;'>Save: " + Savings + "%" + "</p>")
}
</script>

<tr>
[-- IF PRODUCT.DisplayGraphic "checked" --]
[-- IF PRODUCT.Graphic --]
[-- IF PRODUCT.DisplayMoreInfoPage --]
<td class="product_img" align="center" valign="top"><a href="[-- PRODUCT.MoreInfoURL --]"><img "[-- IF PRODUCT.Graphic --][-- PRODUCT.Graphic Remove_HTML --][-- ELSE --]src="media/NeedProductImage.jpg"[-- END_IF --]"> </a></td>
[-- ELSE --]
<td class="product_img" align="center" valign="top"><a href="[-- PRODUCT.MoreInfoURL --]"><img "[-- IF PRODUCT.Graphic --][-- PRODUCT.Graphic Remove_HTML --][-- ELSE --]src="media/NeedProductImage.jpg"[-- END_IF --]"> </a></td>
[-- END_IF --]
[-- END_IF --]

[-- END_IF --]

<td align="left" valign="top" width="191px">


[-- IF PRODUCT.DisplayName --]
<p style="color:#000;">SKU:[-- PRODUCT.SKU --]</p>
[-- IF PRODUCT.DisplayMoreInfoPage --]
<a href="[-- PRODUCT.MoreInfoURL --]">
<p style="color:#003978;">[-- PRODUCT.Name --]</p>
</a>
[-- ELSE --]
<p style="color:#003978;">[-- PRODUCT.Name --]</p>
[-- END_IF --]
[-- END_IF --]
</td>
<td style="width:138px" >
[-- IF PRODUCT.QuantityOnHand 0 --]
###### out of stock#######

<p style="color:#676767;">Anticipated availability:<br />[-- PRODUCT.Field2 --]</p>
<p style="color:#E3372E; font-weight:bold;">Out of Stock</p>
[-- IF PRODUCT.DisplayOrderQuantity checked --]
[-- IF PRODUCT.DisplayOrderingOptions --]
#do nothing
[-- ELSE --]
[-- IF VAR.MoreInfoPage "yes" --]
<br>
[-- END_IF --]
[-- END_IF --]
[-- STORE.Qty --] <input type=text size=2 name="[-- PRODUCT.RecordNumber --]:qnty" value="0" >&nbsp;&nbsp;
[-- END_IF --]

[-- IF VAR.AddButtonGraphic --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- ELSE_IF ADDIMAGE? --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- ELSE --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- END_IF --]

######
[-- ELSE --]
###### in stock#######

<p style="color:#676767;">Price:[-- PRODUCT.Price --]</p>
<p style="color:#E3372E; font-weight:bold;">Our Price: [-- PRODUCT.SaleAmount --]</p>
<script type="text/javascript">
YouSave();
</script>

#######
[-- END_IF --]

</td>

<td align="center" style="white-space: nowrap; width:133px">
[-- IF PRODUCT.QuantityOnHand 0 --]
######out of stock#######
[-- IF VAR.AddButtonGraphic --]
<img src="/btn_addtocart_Dim.jpg" />
[-- ELSE_IF ADDIMAGE? --]
<img style="opacity: .25;" src="http://vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- ELSE --]
<img style="opacity: .25;" src="http://vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- END_IF --]

######
[-- ELSE --]
###### in stock#######

<form name="form_one" action="[-- SHOPPING_CART_URL Base --]/order.cgi" method="post">
<input type="hidden" name="storeid" value="[-- STORE.ID --]">
<input type="hidden" name="dbname" value="products">
<input type="hidden" name="function" value="add">
<input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">
[-- IF PRODUCT.DisplayOrderQuantity checked --]
[-- IF PRODUCT.DisplayOrderingOptions --]
#do nothing
[-- ELSE --]
[-- IF VAR.MoreInfoPage "yes" --]
<br>
[-- END_IF --]
[-- END_IF --]
[-- STORE.Qty --] <input type=text size=2 name="[-- PRODUCT.RecordNumber --]:qnty" value="1" >&nbsp;&nbsp;
[-- END_IF --]

[-- IF VAR.AddButtonGraphic --]
<input type=image class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
[-- ELSE_IF ADDIMAGE? --]
<input type=image class="add-img" [--addimage--]>
[-- ELSE --]
<input class="add" type=submit value="[-- ADDTEXT --]">
[-- END_IF --]
</form>
#######
[-- END_IF --]

[-- ELSE --]
<p style="padding-top:10px">[-- PRODUCT.ProductDescription --]</p>



[-- END_IF --]

</td>
</tr>
<tr>
<td>


</td>
</tr>
<tr></tr>
[-- END_DEFINE PRODUCT --]
MichelleC
 
Posts: 28
Joined: Wed Jan 21, 2009 9:08 am

Postby Jim » Mon Feb 02, 2009 3:39 pm

Viewing the source of the search results the input button is outside of the form tags. That is why the submit isn't working.

You need to follow the logic through and see why that is happening. Maybe the quantity on hand is a negative value? so it isn't equal to the 0 that the code is checking for?

You might want to put a print type statement in the various IF statements to see where the problem is located.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby MichelleC » Mon Feb 02, 2009 4:13 pm

Hi Jim. Thanks- but I am still lost- ?
The form close tag, follows the button:
[-- ELSE --]
###### in stock#######

<form name="form_one" action="[-- SHOPPING_CART_URL Base --]/order.cgi" method="post">
<input type="hidden" name="storeid" value="[-- STORE.ID --]">
<input type="hidden" name="dbname" value="products">
<input type="hidden" name="function" value="add">
<input type="hidden" name="itemnum" value="[-- PRODUCT.RecordNumber --]">
[-- IF PRODUCT.DisplayOrderQuantity checked --]
[-- IF PRODUCT.DisplayOrderingOptions --]
#do nothing
[-- ELSE --]
[-- IF VAR.MoreInfoPage "yes" --]
<br>
[-- END_IF --]
[-- END_IF --]
[-- STORE.Qty --] <input type=text size=2 name="[-- PRODUCT.RecordNumber --]:qnty" value="1" >&nbsp;&nbsp;
[-- END_IF --]
[-- IF VAR.AddButtonGraphic --]
<input type=image class="add" src="[-- OUTPUT_DIRECTORY_URL --]/[-- VAR.Media --]/[-- VAR.AddButtonGraphic --]" name="Add to Cart" alt="Add to Cart">
[-- ELSE_IF ADDIMAGE? --]
<input type=image class="add-img" [--addimage--]>
[-- ELSE --]
<input class="add" type=submit value="[-- ADDTEXT --]">
[-- END_IF --]
</form>

___________

I printed out the code, and have pored over it to make sure there is not a break in logic, or an extra shopsite tag that would roger it (i.e., and extra [--END IF--] )

Also, the search results that serve for peenuts- show a sku that is on hand and one that is definitely out of stock. Peenuts 120 count is set to "0". The Peenuts 60 count is set to "9999" on hand. It seems like it is all set, but I can't understand why the Add to Cart button for the 60 count is visible, shows the cursor switch to a hand to indicate linked, but will not redirect and submit item to cart?


Is the logic broken because of where in the table rows we want the information to display? (thinking this part might be off?---
<td style="width:138px" >
[-- IF PRODUCT.QuantityOnHand 0 --]
###### out of stock#######
<p style="color:#676767;">Anticipated availability:<br />[-- PRODUCT.Field2 --]</p>
<p style="color:#E3372E; font-weight:bold;">Out of Stock</p>
[-- IF PRODUCT.DisplayOrderQuantity checked --]
[-- IF PRODUCT.DisplayOrderingOptions --]
#do nothing
[-- ELSE --]
[-- IF VAR.MoreInfoPage "yes" --]
<br>
[-- END_IF --]
[-- END_IF --]
[-- STORE.Qty --] <input type=text size=2 name="[-- PRODUCT.RecordNumber --]:qnty" value="0" >&nbsp;&nbsp;
[-- END_IF --]
[-- IF VAR.AddButtonGraphic --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- ELSE_IF ADDIMAGE? --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- ELSE --]
<img style="opacity: .25;" src="http://www.vdcusa.com/shopsite_sc/images/btn_addtocart_Dim.jpg" />
[-- END_IF --]
######
[-- ELSE --]
###### in stock#######
<p style="color:#676767;">Price:[-- PRODUCT.Price --]</p>
<p style="color:#E3372E; font-weight:bold;">Our Price: [-- PRODUCT.SaleAmount --]</p>
<script type="text/javascript">
YouSave();
</script>
#######
[-- END_IF --]
</td>

-----
I have really really pored over this, and marked code in different color highlighters...the in a table bit is all I can think of? It is very difficult to display results properly without a table.
phew.
Again, any help/ further clarification is greatly appreciated. Thank you!
MichelleC
 
Posts: 28
Joined: Wed Jan 21, 2009 9:08 am

Postby Jim » Mon Feb 02, 2009 9:08 pm

Here is the html generated for the first product on the search results page when I search for peenuts
Code: Select all
<!-- Start of ROW -->
<script type="text/javascript">
function YouSave(){
   var MSRP = "$44.99".substr(1);
   var OurPrice = "$36.89".substr(1);
   Savings = Math.round((MSRP - OurPrice) / MSRP * 100)
   document.write("<p style='color:#003978; font-weight:bold;'>Save: " + Savings + "%" + "</p>")
}
</script>

<tr>
          <td class="product_img" align="center" valign="top"><a href="http://vdcusa.com/shopsite_sc/Vitamin-Discount-Center-Peenuts-Herbal-Prostate-Formula-by-Peenuts-60-Capsules-853754001058.asp"><img " src="http://vdcusa.com/shopsite_sc/media/ss_size2/853754001058.jpg" alt="853754001058.jpg" width="63" height="115" vspace="3" hspace="3" border="0""> </a></td>
     
 
 <td align="left" valign="top" width="191px">
 
 
        <p style="color:#000;">SKU:853754001058</p>
      <a href="http://vdcusa.com/shopsite_sc/Vitamin-Discount-Center-Peenuts-Herbal-Prostate-Formula-by-Peenuts-60-Capsules-853754001058.asp">
   <p style="color:#003978;">Peenuts Herbal Prostate Formula by Peenuts - 60 Capsules</p>

</a>
   </td>
  <td style="width:138px" > 
 
 
     
<p style="color:#676767;">Price:$44.99</p>
<p style="color:#E3372E; font-weight:bold;">Our Price: $36.89</p>
<script type="text/javascript">
   YouSave();
</script>

 
  </td>
 
  <td align="center" style="white-space: nowrap; width:133px">
         <!-- VAR ADDBUTTONGRAPHIC IS NOT DEFINED -->

          <input type=image class="add-img" src="http://vdcusa.com/shopsite_sc/images/en-US/buttons/vdc_addtocart.jpg">
        </form>


          </td>
       </tr>
       <tr>
          <td>


  </td>

</tr>
<tr></tr>
</tr> <!-- END OF ROW -->


Note that you have an input button and a closing form tag but no opening form tag for the product. (There is an opening form for the search box higher up on the page but that won't work for the add to cart.)
Code: Select all
          <input type=image class="add-img" src="http://vdcusa.com/shopsite_sc/images/en-US/buttons/vdc_addtocart.jpg">
        </form>
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby MichelleC » Tue Feb 03, 2009 11:12 am

fixed now- THANKS so much! :D
MichelleC
 
Posts: 28
Joined: Wed Jan 21, 2009 9:08 am

Postby MichelleC » Tue Feb 03, 2009 2:36 pm

Fix one thing, break another...sigh. So= now, the browser back button action, creates a loop = where the last item selected, and put in cart, and added in with each action.
For example, you place item A in cart, and say you really like back browsing instead of buttons (Continue Shopping) and you back browse. Say you decide to back browse again= if you look at View Your Cart status (the script display) or chose to click through to cart, the last item you added to cart has now been added for every time/instance you took that action.
Ack! i can't seem to find a prior post about this behavior - anyone run into this? wondered if it had to do with the changes that we made?
any help greatly appreciated. thanks so much.
MichelleC
 
Posts: 28
Joined: Wed Jan 21, 2009 9:08 am

Postby MichelleC » Tue Feb 03, 2009 2:42 pm

oh- some additional info-
have tested and seen this error in:
IE 7
IE 6
and in Safari (surprising)
But, does not occur in Firefox 3.0.5
thanks, in advance, if anyone can comment on it- has run into this. I don't know where to start...it did not do this before...something in the cgi string-??
MichelleC
 
Posts: 28
Joined: Wed Jan 21, 2009 9:08 am


Return to User Forum

Who is online

Users browsing this forum: No registered users and 99 guests