Custom Feed dynamic stock numbers

ndriverwoodndriverwood Member Posts: 2

Hi there,

I'm attempting to have our custom feed for google merchant pull dynamic stock numbers for google's <g:quantity> requirement. I've attempted to run the code with a couple of different twig tags to no avail.

My most recent tag attempt was <g:quantity> {{stock_level}} </g:quantity>. I haven't been able to pull any actual numbers from our inventory with this and have resorted to a simple yes/no stock integer for the quantity number, albeit that's not ideal. Am I missing something here? I'm not particularly familiar with PHP/twig so this is a learning process.

Here's the full code block

</g:product_type>

  <g:quantity>{{stock_level}}</g:quantity>

        {% if product.available %}

          <g:availability>in stock</g:availability>

        {% else %}

          <g:availability>out of stock</g:availability>

        {% endif %}

Any help would be greatly appreciated, thank you!

3 comments

  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 340 moderator

    Hi,

    You should be able to use {{ variant.stock_level }} for this.

  • ndriverwoodndriverwood Member Posts: 2

    Thanks for the advice Ali!

    I feel like im placing it in the wrong spot still, as the inventory still doesnt seem to be pulling data for the feed. I've attached the feed below.


  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 340 moderator

    You'd have to loop through the variants. Attached to this message you will find your feed with a variants loop example.

    Side notes:

    • The feed needs to be worked on to have all the other data correctly shown.
    • Add "?google=true&include_variants=true" to the end of your url to have the information shown correctly in your feed.

    Hope this helps.


Sign In or Register to comment.