How can I update metafields using if condition in a product's stock analysis?

How can I update metafields using if condition in a product's stock analysis?

gary07
Excursionist
60 0 10

Hi

 

I am trying to update the meta field from one metafeild to another one

 

I have one metafeild with below value

 

Namespace and key product.stockanalysis

 

<ProductStockAvailability> <LIWCode>100342105</LIWCode> <SICode>-999</SICode> <LocalStock>0</LocalStock> <UnallocatedBackOrders>0</UnallocatedBackOrders> <APIDefaultBranchCode>1</APIDefaultBranchCode> <DepotStockRequested>true</DepotStockRequested> <AdditionalAvailability> <ProductStockAvailabilitySchedule> <AvailabilityType>SupplierOther</AvailabilityType> <IsExistingPO>false</IsExistingPO> <Quantity>1</Quantity> <DueDateNum>-999</DueDateNum> <HasDueDateNum>false</HasDueDateNum> </ProductStockAvailabilitySchedule> </AdditionalAvailability> <DepotAvailability /> <LocalStockAnalysis /></ProductStockAvailability>

 

Result metafeild name and key

 

product.localstock

product.suppilerstock

Now I want <LocalStock>0</LocalStock> and <Quantity>1</Quantity> to show on sperate metafeild is it possible

 

I am using this condition on flow but not working properly

{% metafields.product.stockanalysis %}
{% assign metafield_content = metafields.product.stockanalysis %}
{% if metafield_content contains '<LocalStock>' and metafield_content contains '</LocalStock>' %}
{% assign start = metafield_content | split: '<LocalStock>' | last %}
{% assign end = start | split: '</LocalStock>' | first %}
{{ end }}
{% else %}
"Metafield does not contain the desired text"
{% endif %}

 

 

Replies 0 (0)