Solved

How can i skip products in my "last viewed" product block?

  • 18 January 2023
  • 3 replies
  • 74 views

Badge +3

Hi,

 

I’m currently implementing a “Last viewed” products as a custom coded block in my campaigns. However i want to be able to skip products if they are out of stock. Is there a way to do this in django?

The products shown are consistent with the “last viewed” products in the persons profile

 

 

However we include the block on most of our global campaigns and some recipients might see products that are out of stock. Again, any way to be able to skip products of the recently viewed if they are out of stock?

 

 

 

 

 

icon

Best answer by Dov 23 January 2023, 16:40

View original

3 replies

Userlevel 7
Badge +61

Hi @sperezclavier,

Thanks for sharing this question with us.

Not at this time but we can use django to evaluate whether or not the individual’s recently viewed items in the grid are out of stock or not. If it is out of stock, we can cancel the email send. You can achieve that using the following code:

{% catalog item.ItemId unpublished="cancel" %}

(Existing code)

{% endcatalog %}

We have more information on catalog look-up tags here.

I hope that’s helpful.

Badge +3

Hi Dov, thank you for the quick response. So if i added that Django snippet at the beginning and end it will cancel the email campaign for that particular person? (i’m trying this in a campaign FYI, not in a flow)

Is there another way i can track last viewed products to include them in a campaign? It seems to be working very well for our bottom line but some recipients might have issues us showing them products that are out of stock.

 

The code i’m using is this:

 

<style>.KL_custom_product_block {
margin-left:auto;
margin-right:auto;
}
@media only screen and (max-width: 480px) {
.mobile{
height: 130px !important;
}
.mobileBrand{
height: 40px !important;
}
.font3colBrand {
font-size: 13px !important;
}
.font3colName {
font-size: 12px !important;
}
.mobileName{
padding: 0px 5px 0px 5px !important;
}
.product_mobile3{
width: 32% !important;
}
.product_mobile2{
width: 49% !important;
}
.product_mobile1{
width: 100% !important;
}
td.kmTextBlockInner td.kmTextContent td.kl-text {
padding-right: 0px !important;
padding-left: 0px !important;
}
.kl-text{
padding-right: 0px !important;
padding-left: 0px !important;
}
}
</style>
{% if person.ViewedItems|length >= 6 %}
<table class="KL_custom_product_block" style="table-layout: fixed;" width="100%" align="center">
<tbody>
<tr>{% for item in person.ViewedItems|slice:'1:4' %}{% if item or is_editing %}
<th class="product_mobile3" style="width: 33%; height: auto; float: left;" valign="top" width="33%" height="auto">
<table width="100%" align="center">
<tbody>
<tr>
<th class="mobile" width="100%" height="160">
<p style="text-align: center;" align="center"><a href="{{ item.Url }}" style="font-weight: 200; text-align: center;" target="_blank" rel="noopener"><img class="mobile" style="max-height: 160px; width: auto; height: auto;" src="{{ item.ImageThumbnailUrl }}" alt="{{ item.Title }}" width="auto" height="160" /></a></p>
</th>
</tr>
<tr>
<th class="mobileName" style="padding: 0px 20px;" valign="top" width="100%" height="40">
<p style="text-align: center;" align="center"><span class="font3colName" style="font-size: 13px; font-weight: 200; font-family: Helvetica, Arial, 'sans-serif';">{{ item.Title }}</span></p>
</th>
</tr>
</tbody>
</table>
</th>
{% endif %}{% endfor %}</tr>
<tr>{% for item in person.ViewedItems|slice:'4:7' %}{% if item or is_editing %}
<th class="product_mobile3" style="width: 33%; height: auto; float: left;" valign="top" width="33%" height="auto">
<table width="100%" align="center">
<tbody>
<tr>
<th class="mobile" width="100%" height="160">
<p style="text-align: center;" align="center"><a href="{{ item.Url }}" style="font-weight: 200; text-align: center;" target="_blank" rel="noopener"><img class="mobile" style="max-height: 160px; width: auto; height: auto;" src="{{ item.ImageThumbnailUrl }}" alt="{{ item.Title }}" width="auto" height="160" /></a></p>
</th>
</tr>
<tr>
<th class="mobileName" style="padding: 0px 20px;" valign="top" width="100%" height="40">
<p style="text-align: center;" align="center"><span class="font3colName" style="font-size: 13px; font-weight: 200; font-family: Helvetica, Arial, 'sans-serif';">{{ item.Title }}</span></p>
</th>
</tr>
</tbody>
</table>
</th>
{% endif %}{% endfor %}</tr>
</tbody>
</table>
{% endif %}

 

Userlevel 7
Badge +61

Hi @sperezclavier,

Thanks for providing this update.

That’s a great question. That particular catalog look-up tag was designed for flows but since it’s pulling the catalog ID, it may still work for a campaign. I recommend inserting the code and running a test with your own profile to see if it works. There isn’t a way to get “more granular“ for out of stock items on an item-by-item basis using this code, like you mentioned in your original question. In other words, if this did work for campaigns it would only skip the email rather than curate only in-stock items for the user. Since showcasing potentially out of stock items is your main concern, you may want to consider using a product block instead. This is because for Magento and Shopify stores, if a product goes out of stock, we'll hide it from your catalog so it won't appear in any product feed. You can read more about product blocks here.

I hope that’s helpful and thanks for being a community member.

Reply