Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Dynamic Button in Extension

Dynamic Button in Extension

Denys_Slipko
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)

EcomGraduates
Shopify Partner
764 67 112

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>');
buyButton.after(extensionElement);

 

 

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


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner