Shopify themes, liquid, logos, and UX
I am experiencing difficulty placing a Buy Button inside a table on my user-created custom web page.
I am following the instructions for placing a Buy Button on a user-created webpage. (Ref: https://help.shopify.com/en/manual/online-sales-channels/buy-button/create-buy-button )
When I place the copied button code inside a <td> element, nothing shows up on the web page. (eg. <td><div id='product-component-1234567890123'></div></td>)
When inspected in the Firefox browser, the <div> appears as written above. When the same <div> 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.
<div id="product-component-1234567890123" class="shopify-buy-frame shopify-buy-frame--product shopify-buy__layout-vertical" style="max-width: 280px;"><iframe style="width: 100%; overflow: hidden; border: medium none; height: 43px;" horizontalscrolling="no" verticalscrolling="no" allowtransparency="true" scrolling="no" name="frame-product-6633845784802" frameborder="0"></iframe></div>
Solved! Go to the solution
This is an accepted solution.
You'll have to learn the configuration system
https://shopify.github.io/buy-button-js/customization/#styles
https://github.com/Shopify/buy-button-js
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
This is an accepted solution.
SOLVED
Many thanks to @PaulNewton for pointing me to the code and documentation for BuyButton.js.
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 <script> portion (placed in my HTML <head> section), and the product button <div> portion (placed within the table's <td>).
Is the console error showing in your screenshot related to the buy button?
Make sure whatever context the table is in so is the buy button javascript, i.e. no iframes inside iframes.
Without seeing or digging through the rest of your code a fix could be to wait for the button to load then move into the table <td>.
Otherwise you may need to debug your page and the buy-button js to find if there's a bug.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
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 <div> part of the code, and only had one copy of the <script> 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: I would also like to override the top level inline style that defines :max-width=280px.
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.
This is an accepted solution.
You'll have to learn the configuration system
https://shopify.github.io/buy-button-js/customization/#styles
https://github.com/Shopify/buy-button-js
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Thanks. I'm on it ...
This is an accepted solution.
SOLVED
Many thanks to @PaulNewton for pointing me to the code and documentation for BuyButton.js.
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 <script> portion (placed in my HTML <head> section), and the product button <div> portion (placed within the table's <td>).
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024