Skip Navigation

[Resolved] Add To Cart button not displaying in Blocks

This thread is resolved. Here is a description of the problem and solution.

Problem:

How to display add to cart button in an archive list

Solution:

You can try shortcode [wpv-woo-buy-or-select]

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-woo-buy-or-select

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by jamesW-26 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1714353

I am trying to:
Buil a content template for WooCommerce products in an archive list.

Link to a page where the issue can be seen:
hidden link

I expected to see:
An add to cart button

Instead, I got:
Nothing

If you go to the page, then open the browsers Developer Tools and select where the add to cart button should be, this is all that is there:
<div class="wooviews-add-to-cart" data-woocommerce-views-add-to-cart="f705ed43-848d-4d95-bc5c-85cf268a89f7"></div>

#1714437

Hello,

The Woocommerce Views "Add to Cart Button" block is using shortcode [wpv-woo-buy-options]
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-woo-buy-options

It works only in single Product detail page, the URL you mentioned above is a WordPress archive page, so you will need to try another shortcode: [wpv-woo-buy-or-select]

I have tried to add a shortcode block in content template, and display below shortcode:
hidden link
[wpv-woo-buy-or-select add_to_cart_text="Add to basket" link_to_product_text="More details"]
it works fine in front-end:
hidden link

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-woo-buy-or-select

#1714451

Thanks very much Luo, that's great.

Can you please advise how I can center the button in the column? I've tried ...

display: block;
margin-left: auto;
margin-right: auto;

but it doesn't work.

#1714455
center.JPG

I have checked the URL again:
hidden link

I can see the button is centered in the column, see my screenshot center.JPG

Is it resolved? please let me know if you need more assistance for it.

#1714511

Hi Luo,

There was some CSS hgher up that was affecting it, but I've fixed it now.

Cheers