-
AuthorPosts
-
September 4, 2016 at 7:28 pm #1160916
Hi Themeco folks,
I’m trying to create a custom add-to-cart button for a landing page (vs. a product page). How do I do this?
Here’s what I’ve put together based on two previous threads:
https://community.theme.co/forums/topic/how-to-add-add-to-cart-button-under-any-product-in-any-page-using-cornerstone/
https://community.theme.co/forums/topic/single-product-add-to-cart-button-placement/<p style="text-align: center;"><a class="button add_to_cart_button product_type_simple" href="/wp-admin/admin-ajax.php?add-to-cart=742" rel="nofollow" data-product_id="742" data-quantity="1">Click Here to Buy Now!</a></p>
There are 2 problems I need help solving:
1) How do I make this a full-width/block style button? I’d also like it to be yellow (I just need the coding; I can pick a hex value).
2) The current WooCommerce button (“CLICK HERE TO BUY NOW” in the screenshot) works, BUT after adding it to the cart, you’re redirected to the blank page in the second screenshot (16.24.08.png).URL: http://theapproachcoach.com/
WordPress version: 4.6
X version: 4.6.1 (using a child theme)
Cornerstone version: 1.3.1Thank you in advance!
September 4, 2016 at 10:39 pm #1161095Hello There,
Thanks for writing in! To assist you better with this issue, would you mind providing us the url of your site with login credentials, so we can take a closer look? This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / passwordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thank you.
September 6, 2016 at 9:45 am #1163105This reply has been marked as private.September 6, 2016 at 12:37 pm #1163324Hi there,
Please add the class ajax_add_to_cart to the link you have added then add this CSS code in the customizer:
#post-585 #x-section-3 .x-text .add_to_cart_button { background-color: yellow; }
Hope this helps.
September 6, 2016 at 2:14 pm #1163425Hi, and thanks for the fast reply.
The code to change the color of the button worked, but:
1) How do I make it the full-width/block style?And problem #2 still exists — the item is added to the cart, but the user is immediately redirected to the blank page in the screenshot. (I took the page live to see if that made a difference, and it doesn’t. You still get the screenshot as the result.)
Here’s the code I added, per your instructions above:
<p style="text-align: center;"><a class="button add_to_cart_button product_type_simple" class="ajax_add_to_cart" href="/wp-admin/admin-ajax.php?add-to-cart=742" rel="nofollow" data-product_id="742" data-quantity="1">Click Here to Buy Now!</a></p>
What next? Thank you.
September 6, 2016 at 4:06 pm #1163529Hi there,
#1 Please update the code to:
#post-585 #x-section-3 .x-text .add_to_cart_button { background-color: yellow; width: 100%; }
#2 There are two occurrence of the class attribute in the a tag you have added. Please use this instead:
<p style="text-align: center;"><a class="button add_to_cart_button product_type_simple ajax_add_to_cart" href="/wp-admin/admin-ajax.php?add-to-cart=742" rel="nofollow" data-product_id="742" data-quantity="1">Click Here to Buy Now!</a></p>
Hope this helps.
September 8, 2016 at 2:04 pm #1166884This worked! Thank you.
September 8, 2016 at 3:19 pm #1166991You are most welcome. 🙂
October 18, 2016 at 8:44 am #1220827Is it possible to make code very similar to this, but using
<p style=”text-align: center;”><wc_quick_buy_link product=”87″ qty=”1″ type=”button”>Save Your Space!</p>
Instead?
As this is a quick buy rather than add to cart.
October 18, 2016 at 10:47 am #1220979 -
AuthorPosts