When I place the copied button code inside a element, nothing shows up on the web page. (eg.
)
When inspected in the Firefox browser, the
appears as written above. When the same
is placed outside the table on the same page, the Buy Button appears as it should and works. The Firefox inspector shows the expanded auto-generated code beginning with the snippet below.
Thanks @PaulNewton . Your reply led me to discover the apparent cause of the problem.
I believe the issue turned out to be that I had two instances of the Buy Button on the page (one outside the table and one inside). Both were referring to the same product-component number. More specifically, I was using duplicates of the
part of the code, and only had one copy of the portion. The first was showing up, but the second one wasn’t. The one inside the table appeared after I deleted the one that was elsewhere on the page.
Now I have a formatting issue. I would like better control over the margins and padding of the Buy Button component.
The generated button code uses a class that defines the top margin as 20px. It seems to be hard coded. See below:
.shopify-buy__btn-wrapper { margin-top: 20px; }
How can I override the margins and padding for the Buy Button component at the top level?
EDIT 2: It looks like the top spacing issue may also be affected by an inline style (height:43px) for the generated iframe. So I would need access to that attribute as well.
For those who are interested in the specific code modifications I made to the default Buy Button generated by the Shopify interface, please see the attached graphic. I have highlighted the key modifications I made to format and position the button inside a table cell.
For clarity within the table HTML code, I split the Shopify generated code between the portion (placed in my HTML section), and the product button