Dynamic Button in Extension

Shopify Partner
10 0 2

Hey! Now I am making an application in which there will be an extension that will be installed on the product page in the store. It is necessary that the extensions dynamically adjust (find) a place, for example, under the buy button.
Is it possible to implement this? Since the classes or attributes of each theme may be different.
Or you can still do it only through the instruction so that the user adds the snippet to the page manually.
thanks in advance

Reply 1 (1)

Shopify Partner
588 48 79

Use jQuery to select the element on the page where you want to insert the extension. For example, you can use a CSS selector to target the "Buy" button:



var buyButton = $('.buy-button-selector');



Create a new element for the extension and insert it after the selected element. For example:



var extensionElement = $('<div>My extension goes here</div>');



Style the extension element using CSS to ensure it is positioned correctly relative to the selected element.