Z
Z
ZHeka2021-11-24 16:55:51
JavaScript
ZHeka, 2021-11-24 16:55:51

How to correctly inject a widget into a shopify site, etc.? (The site owner will do it himself)?

Hello! Here is the assignment I received.
We have a widget (modal + a couple of links) that needs to be embedded into user sites (they do it themselves through the admin panel) our widget. The user adds js code according to our tutorial.

see an example of competitors)
https://help.sezzle.in/support/solutions/articles/...

our widget is also there, but it gets up - incorrectly. must be clearly under the price.

What is the point of the question. We need our module to be in a certain place, under the item's price.
And the idea of ​​the developers before me was what to look for id:
const tag =
document.getElementById("product-price") ||
document.getElementById("productPrice-product-template")

and then paste our code after this element.

But for some reason, cunning people change either on the shopify constructor, or where and how else. and they have an ID for the price figures, it can be completely different, or maybe without an ID at all (but there are few of them).

And the actual question. How can (mb experience who has or ideas) adequately look for a place where to insert a widget.
An array of all possible variations of the word price seems to be not the best practice))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question