How do I point Companies to a specific link using if statement?

Hi, I’d like to show Companies a different download link to their price lists when they have logged in. Each company is attached to a specific Catalog and so is there a way of using if/else statement to do this. I know this doesn’t work but can anybody point me to where I can find the code for this please?

{% if company.catalog.id == 123 %}
Show Pricelist X

{% elsif company.catalog.id == 456 %}
Show Pricelist Y
{% endif %}

Does Pricelist X and Pricelist Y relate to Shopify pricing catalogs? Or are these static links to PDFs or something similar?

If the former, the customer/company-specific pricing should show automatically for the logged-in user. You Shouldn’t need to set up this logic.

If you are simply wondering how to show different content for different groups of customers/companies, you might need to add a metafield to the company record to set the “catalog” and then use that in your conditional.

Something like this (untested pseudo-code):

{%- case customer.company.metafields.catalog -%}
  {%- when "x" -%}
    (Pricelist X)
  {%- when "y" -%}
    (Pricelist Y)
  {%- else -%}
    (Default pricelist)
{%- endcase -%}

Many thanks for your reply. I had previously tried metafields but Matrixify doesn’t allow for bulk import to Company metafields and with over 1000 companies, I was hoping for a more dynamic solution.
Your right in saying Pricelist X and Pricelist Y would be pdf links and when they log in they do see their specific pricing for the products but we also want the user to be able to download a pdf depending on what catalog list they are on.

This is the code I used for the metafields:
{% if customer. current_company.metafields.custom.price_list_link_url != blank %}
{{ customer. current_company.metafields.custom.price_list_link_url | metafield_tag }}
{% endif %}

Without using metafields, is there a solution for linking the company catalog?
eg: customer.company.catalog

It seems you are right—Matrixify doesn’t support importing company metafields.

How many different catalogs do you have?

Could you manually flag the ones that have specific pricelists with the default fallback for all those that are b2b but do not have a catalog flag (metafield) set?

Hi. I have over 8 catalogs and over 2000 companies so a dynamic solution would be more favourable.

@DavidA2024 Do you have any pattern for the companies that we can use to identify which catalog it is assigned? like in their name or location?

{% if customer.current_company.name contains "x" %}
   Pricelist X
{% endif %}

{% if customer.current_company.name contains "y" %}
   Pricelist Y
{% endif %}

You can check here https://shopify.dev/docs/api/liquid/objects/customer maybe there’s some identifier we can use to identify which catalog the company is assigned? How about tags?

Thank you Leysam, this is looking positive. There are no common identifiers in the companies apart form sharing a catalog (pricelist). But I could tag the customers in the company with the pricelist name and refer to that.

I’ve fixed it by tagging the customers and then using this:

{% for tag in customer.tags %}
{% if tag == “uk pricelist” %}
CLICK HERE
{% endif %}
{% endfor %}

{% for tag in customer.tags %}
{% if tag == “eu pricelist” %}
CLICK HERE
{% endif %}
{% endfor %}

Perfect! Glad you managed to find a solution :slightly_smiling_face: