How can I smoothly integrate a theme app extension with product selection in my Remix app?

Shopify Partner
3 0 0

I want to add a page to my Remix app that allows the merchant to select which product pages to add my theme app extension on (like basic check boxed lists). I have the gui that shows their products and I have the theme app extension which they can manually customize on a given page, but I just need to find a way to smoothly connect them (perhaps by default my button goes below the add to cart button or something).


Is this possible? Or do all liquid injections have to be done manually by the merchant?

Reply 1 (1)

Shopify Partner
469 53 89

Hmmm, you could use store the products in an metafield and conditionally check with liquid:


Store the Values: In your app or through the Shopify admin, store the list of product IDs or handles in a metafield as a single string, with each value separated by a comma.

Liquid Code Example:
Suppose you have a metafield product_list in the settings namespace that contains a list of product handles. Here's how you could check if the current product is in that list:

{% assign product_list = settings.product_list | split: ',' %}
{% if product_list contains product.handle %}
  <!-- Your code here to display or do something for the included product -->
{% endif %}
In this code:

settings.product_list refers to your metafield.
split: ',' turns the string into an array, splitting it at each comma.
product.handle is the handle of the current product.
The if statement checks if the product_list array contains the handle of the current product.


Have I helped? Consider putting coffee in my mouth!
Buy Me a Coffee