App compatibility with themes' post add-to-cart action

We are working on making our upsell app compatible with premium themes for post add-to-cart behavior i.e. to open cart drawer (or any configured post ATC behavior).

We are currently at ~28 themes and the lines of code (only for storing configs for each theme) is more than 500 lines.

I am curious if we are going in the right direction or not…

We are storing a config in an object with theme name as the key, and the post ATC behavior as the value.

The expectation was that themes from the same vendor/developer will use the same approach but they don’t, its slightly different.

Other apps have done this, although I am not sure if they support all premium themes.

What do you guys suggest on approaching this?

also has anyone done this before and open-sourced the solution/configs?

thanks

Hi @junaidkbr

The approach you’re taking does sound like a sensible strategy - I know some devs like @farid have experience in this so they may share some best practices to be aware of.

Thanks for mentioning me @Liam-Shopify yes indeed we created an architecture where we can add supported themes from separate files.

basically we keep code under asset and based on current theme we are injecting the file which is holding theme code dynamically. This allows us to keep the size of main block file under the limit.

1 Like

Thanks @Liam-Shopify and @farid

Any way you could open-source this? If not, maybe share with me; this will save a ton of time.

Thanks!