Announcement

Collapse
No announcement yet.

Mirodata Availability Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mirodata Availability Error

    I perused all other threads on microdata to make sure this wasn't already addressed, but I've encountered something I consider an error in the product listing templates:

    Code:
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                <link itemprop="availability" href="http://schema.org/InStock" content="[availability_itemprop]" />
    I was trying to see why I was getting microdata errors for product availability and encountered the above. Does anyone have answers to the following questions:
    1. By referencing "http://schema.org/InStock" instead of "http://schema.org/ItemAvailability", is the microdata automatically asserting that the item is In Stock?
    2. It appears that the [availability_itemprop] variable returns the front-end availability contents instead of a schema.org valid enumeration for the availability property; does a variable exist that propagates the correct enumerations?
    3. Can 3dcart generate "preorder" availability?


    I looked into my what my competitors were doing -- one of them doesn't include availability at all (what I'm leaning toward, honestly... better missing than incorrect), and one of them only generates availability microdata for items that are In Stock (cute, but if I'm going to figure out how to fix it, I'm going to fix it for all variables, not just one).

    Any help on this would be appreciated!
    Webmaster: Texas Media Systems

  • #2
    The accepted values for the availability property are:
    Discontinued
    InStock
    InStoreOnly
    LimitedAvailability
    OnlineOnly
    OutOfStock
    PreOrder
    SoldOut
    I am not sure what [availability_itemprop] returns, It is different than the typical [availability] and is not documented.
    however I almost believe that we need some custom javascript to handle the different options.
    I have a separate template for my discontinued items that is hard coded with "Discontinued"

    Comment


    • #3
      A custom template for discontinued items is a great idea, and agree that this whole mess is likely going to take some javascript to clean up.

      Here's my first pass at the logic.

      If [stock] is greater than 0, return "LimitedAvailability"
      If [stock] is greater than 5, return "InStock"
      If [stock] is less than or equal to 0, and [show_out_stock] equals -1, return "OutOfStock"
      If [stock] is less than or equal to 0, and [show_out_stock] equals 1, return "SoldOut"
      If [stock] is less than or equal to 0, and [show_out_stock] equals 2, return "PreOrder"

      Custom Templates could be employed to take care of the following cases:
      "Discontinued" - Once discontinued, items shouldn't need to change
      "InStoreOnly" - Items too big/fragile/temperature-sensitive to ship
      "OnlineOnly" - Digital downloads?
      Webmaster: Texas Media Systems

      Comment


      • #4
        Logic looks good.
        Please post an update when you have it figured out.

        Comment


        • #5
          I'm afraid I don't have the jQuery skills do it. I thought I did, but I don't. I'm still studying it for a solid solution, but it's been moved to the back-burner unfortunately.
          Webmaster: Texas Media Systems

          Comment


          • #6
            Does anyone know how to pull a 3dcart variable (eg; [stock], or [price]) in a javascript file?

            I've been working on the above problem and I can get the value of the variable if I insert the javascript directly into the template, but not if I link my script.
            Webmaster: Texas Media Systems

            Comment


            • #7
              I'd rather store the javascript in an external library, but here's what I'm using (following the logic supplied above). This has been inserted directly into the main listing template just above the div it affects.

              Code:
              <script type="text/javascript">
              	  $(document).ready(function() {
              	var stockval = ("[stock]");
              	var showoutstock = ("[show_out_stock]");
              	
              	if (stockval > 0) {
              		if (stockval > 5) {
              		$("#ItemAvailability").prepend("<link itemprop=\"availability\" href=\"http://schema.org/ItemAvailability\" content=\"InStock\" />");
              		} else {
              		$("#ItemAvailability").prepend("<link itemprop=\"availability\" href=\"http://schema.org/ItemAvailability\" content=\"LimitedAvailability\" />");
              		}
              	} else {
              		if (showoutstock == -1) {
              		$("#ItemAvailability").prepend("<link itemprop=\"availability\" href=\"http://schema.org/ItemAvailability\" content=\"OutOfStock\" />");
              		} else if (showoutstock == 1) {
              		$("#ItemAvailability").prepend("<link itemprop=\"availability\" href=\"http://schema.org/ItemAvailability\" content=\"SoldOut\" />");
              		} else {
              		$("#ItemAvailability").prepend("<link itemprop=\"availability\" href=\"http://schema.org/ItemAvailability\" content=\"PreOrder\" />");
              		}
              	}
              });
              		</script>
              I just added an id to the div preceeding the link that currently appears there:
              Code:
              <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" id="ItemAvailability">
              If there is 5 or more of an item, the microdata shows that it's in stock. If stock is between 1 and 4, it has limited availability. If it's out of stock then the following shows up based on what "Inventory Control" is set for on the item:
              Default = out of stock
              Out of Stock = sold out
              Backorder or Waiting List = preorder

              I'm using a custom template for discontinued items and the microdata for that is static.

              Use this code at your own risk.
              Webmaster: Texas Media Systems

              Comment


              • #8
                TMS Clint, thank you for sharing your work.

                Comment


                • #9
                  Bad news... This code doesn't work. Sure, it supplies the correct values if you are to look at the source code yourself, but that's after the page has been rendered. Using Google's Structured Data Testing Tool, I found that my code isn't being fetched. I just opened the following support ticket:

                  The code in the product templates that produces 'availability' microdata is formatted incorrectly. I've checked the newer product templates (templates >> common-html5 >> listing_0.html) to make sure it wasn't something out-dated in my much older theme. I've laid out the problem in full in the forums (http://forums.3dcart.com/forum/shopp...lability-error), but here it is in brief:

                  The code for availability is:
                  <link itemprop="availability" href="http://schema.org/[availability_itemprop]" />

                  However the variable [availability_itemprop] returns results that don't fit Schema.org's permissible values. For example: if an item is in stock then the variable returns "In Stock" instead of "InStock". What's more, if we make use of 3dcart's custom availability messages, then the variable returns that value instead. For instance, when it should be returning "OutOfStock" instead of "Out Of Stock;" it could be returning "Available In May!" instead.

                  Do you have a variable field that will correctly supply the following? ::

                  Discontinued
                  InStock
                  InStoreOnly
                  LimitedAvailability
                  OnlineOnly
                  OutOfStock
                  PreOrder
                  SoldOut
                  Right now I'm trying to work out how to MacGyver the current system. I'm thinking about adding the relevant Schema.org terms to my custom availability messages and using jQuery to render what the visitor sees.

                  3dcart-product_01.png
                  Webmaster: Texas Media Systems

                  Comment


                  • #10
                    This has been a problem for a while. I'm not sure if any javascript solution will help since Google is going to use what the googlebot sees, but I may be wrong on that. We weren't able to get it working with javascript.

                    What we ended up doing was using the extra_field_13 field to store InStock or OutOfStock, and changing our listing to this -

                    <link itemprop="availability" href="http://schema.org/ItemAvailability" content="[extra_field_13]" />

                    We use the advanced API to update the extra_field_13 every few hours. If your inventory isn't going in and out of stock frequently like ours is updating it once a day would probably be enough.

                    Its not as good as a completely dynamic solution but it is the best we've been able to come up with. 3dcart told us they were working on a fix in December but to the best of my knowledge they haven't come up with one yet.

                    Comment


                    • #11
                      I don't have enough experience with APIs to program them. But I was able to MacGuyver a solution using an extra field.

                      As in the picture above I gave the following variables the following values across all products:
                      • [instock_message] = "InStock"
                      • [outofstock_message] = "OutOfStock"
                      • [backorder_message] = "PreOrder"

                      Since the [availability_itemprop] variable is overridden by those values, the following code is always correct for microdata (and more importantly is read by the googlebot):
                      HTML Code:
                      <link itemprop="availability" href="http://schema.org/[availability_itemprop]" />
                      Then I set the visual availability in the product listing to [extra_field_8]:
                      HTML Code:
                      <td class="price-info"><div id="availability">[extra_field_8]</div>
                      I re-purposed the jQuery above in my fifth post to deliver a blanket message (based on stock level and inventory control setting) UNLESS there is data in Extra Field 8. Now [extra_field_8] works the same way that instock, outofstock, and backorder message worked before.

                      But now I have to find everywhere that [availability] is referenced and replace it with [extra_field_8] and my jQuery (for example, the search results page).

                      In answer to the support ticket I submitted, I was told to ask for the feature in the UserVoice Forums. Except it's already been posted. And the problem with that is the request is marked "completed" and points to this Knowledgebase Article. And the problem there is that it advocates using the code we know doesn't work:
                      HTML Code:
                      <link itemprop="availability" href="http://schema.org/InStock" content="[availability_itemprop]" />
                      In my opinion, inaccurate support is worse than no support. If you want to see if your items are listing correctly, try using Google's Structured Data Testing Tool. Before removing the erroneous code from my site, my products were getting flagged (penalized?) for having "invalid availability microdata." Hopefully I'll see some improved performance now that I've addressed the issue.
                      Webmaster: Texas Media Systems

                      Comment

                      Working...
                      X