Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Fjord 622 posts 1488 karma points c-trib
    22 days ago
    Rasmus Fjord
    0

    Do we need a stock level on each variant or will it inherit from product?

    Hey

    Ive been googling around for an answer about how the stock datatype works with variants.

    Because we have a customer where they only have a stock field on the "product" but not on each variant. But the stock didnt tick down, on purchases.

    On the variant we have a "sku" and a "name", but I could on the specific variant they hadnt given a SKU, so im guessing that was why, since stock is stored on sku level.

    I just got a bit confused, and couldnt find any doc :)

    Bonus question the alias "sku" is something that is "hardcoded" like "umbracoNaviHide" and is not something we should set somewhere right?

  • Matt Brailsford 2021 posts 9918 karma points MVP 5x c-trib
    22 days ago
    Matt Brailsford
    0

    Hi Rasmus,

    Yea, I think because you give the variants their own unique SKU the logic that sets the stock level uses that SKU to update with and because you don't have variant stock levels, it's not changing anything.

    In answer to your second question, yea, "sku" is a fixed alias so can't be changed, but, in this example, I'm wondering if we can use that to our advantage and you give your variants a "variantSku" property instead, which means TC won't attempt to use that as true SKU and attempt to set the stock level. It might then mean that it will use the stock level of the main product (I'm not really sure, but worth trying). You could then set variantSku as a property that gets copied to the order line so you can still show it in receipts etc.

  • Rasmus Fjord 622 posts 1488 karma points c-trib
    1 week ago
    Rasmus Fjord
    0

    I will give it a test and get back!

  • Rasmus Fjord 622 posts 1488 karma points c-trib
    1 week ago
    Rasmus Fjord
    0

    I just tested this, by changing the sku property on the variant to an variantSku alias. But this dosnt change the stock on the "product" level. So im gussing that its not working the way i thought.

    Dont know if its changed or something since v3.2.4.

  • Matt Brailsford 2021 posts 9918 karma points MVP 5x c-trib
    1 week ago
    Matt Brailsford
    0

    Hmm, I'll need to dig into it further.

    I don't have thorough knowledge of how all the variants stuff works so I'll have to dig through it. I would have thought that would do it, but I'll have to set something up and see if I can replicate / suggest a solution.

  • Matt Brailsford 2021 posts 9918 karma points MVP 5x c-trib
    6 days ago
    Matt Brailsford
    0

    Ok, I've done a bit of digging and can see why there is a problem (thought I still need to figure out how to fix it).

    Ultimately, when you save an order that has variants, it seems to be pretty much assuming that you will have variant stock levels. When you save the order, and it calls to update the stock level, it builds an SKU to update the stock on by combining the product SKU + variant ID. The problem is, if you don't supply a variant SKU, it still generates an ID so it ends up trying to update the stock on an SKU that doesn't exist.

    I'm gonna have to figure this out, but ultimately, when saving the product, it really needs a better way of knowing if the variant has independent stock levels (other than the current check, which is, is the variant null).

    I'll see what I can figure out and let you know. I just wanted to give you an update.

  • Matt Brailsford 2021 posts 9918 karma points MVP 5x c-trib
    6 days ago
    Matt Brailsford
    0

    Ok, I think I know what you need to do.

    If you aren't using variants with their own SKU, then you need to make sure you send the productIndentifier of the parent product for the order lines productIdentifier property.

    <input name="productIdentifier" value="@productPage.Id" type="hidden" />
    

    For all the variant properties that you need recorded on the order, you'd then want to copy them to the orderlines properties collection.

    <input name="AddOrUpdateOrderLine" value="productIdentifier, quantity, properties" type="hidden" />
    <input name="storeId" value="@storeId" type="hidden" />
    <input name="productIdentifier" value="@productPage.Id" type="hidden" />
    <input name="properties" value="variantSku,variantName,etc" type="hidden" />
    <input name="variantSku" value="V1000" type="hidden" />
    <input name="variantName" value="Blue / Black" type="hidden" />
    ....
    

    Essentially at this point your variants are no longer really variants, the values have just been copied to the order line, but I don't think this really matters if your don't need stock control.

    Hopefully this helps.

    Matt

  • Rasmus Fjord 622 posts 1488 karma points c-trib
    3 days ago
    Rasmus Fjord
    0

    Hey Matt

    Awesome, i will take it for a spin and see if i can make it work.

Please Sign in or register to post replies

Write your reply to:

Draft