Announcement

Collapse
No announcement yet.

Attribute Machine json data

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

    Attribute Machine json data

    When selecting an attribute Attribute_Machine makes an ajax call to get json variant and inventory data in the variable possible_response

    Via javascript, How do I access the data after Attribute_Machine is finished.

    The client wants to display the actual Inventory out message on the screen (example: Summer 2016)
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    It is available globally on the page as a JS object. The instance of attribute macine on the page is always named "am" + product id so you can do something like this:

    Code:
    <script>
                if (typeof am&mvt:product:id; !== 'undefined') {
                    var attrMachCall = am&mvt:product:id;;
                };
     </script>
    Then you can access data using your attrMachCall object
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      I don't find the data as part of am&mvt:product:id; however I did find amPossible&mvt:product:id; contains the initial variant data for the first option when the page loads.

      When another option is selected, is does not seem this is overwritten after the ajax call.

      Should I attach my own click event to the <LI> tag ? I tried adding code to AttributeMachine.prototype.Swatch_Click but it does not seem the variable is getting updated.


      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment


        #4
        Brennan

        The after further study the data you pointed me to is the initial data when the page is loaded.

        When a swatch is selected an NEW ajax call is made returning the attribute and variant data. However appear the variant data is not stored and only the attribute data is returned. It seems the variant inventory is used to enable or disable the add to cart button, then discarded. Later the fact that the button is disabled it used within [scripts.js].outofStock() to change the text to the hard coded value "Sold Out".

        It's looking like I will need to perform another ajax call to reload the variant inventory data for the selected option. This will mean reverse engineering AttributeMachine.prototype.Initialize unless you have another way or some sample code.
        Ray Yates
        "If I have seen further, it is by standing on the shoulders of giants."
        --- Sir Isaac Newton

        Comment

        Working...
        X