Skip Navigation

[Resolved] Add to cart + other block doesn't render, can't figure out why.

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.

This topic contains 13 replies, has 2 voices.

Last updated by Diego Walter Ricciardi 2 months, 1 week ago.

Assigned support staff: Waqar.

Author
Posts
#2418403
filter_notshortcode.png
archive_noaddtocart.png
template_addtocart.png
block template.png

I'm refactoring a bit the archive / layouts etc.
I'm using the classic editor for the woocommerce product archive for easier filter / search managment and using a Blocks template for the product loop.
I have literally no clue why add to cart block doesn't render.
I'll post screenshot but I would need a private answer to link to the page etc / since it's a staging/dev site and the pages are pw protected.

I have already conflict tested everything (this site is the dev site, but it uses the same plugins / themes and everything as the production site) disabled themes, plugins, everything this persist.

I'm sure it's probably something stupid I'm missing but since I didn't specifically touch anything about the cart, I have no clue what's going on.

/edit:
Also after filtering, the shortcode for the yith wishlist gets the same treatment, doesn't render. Adding screenshot. This was known, it also happens in the production site but was never a priority, I wonder if it's related.

#2419555

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

Does the add-to-cart button show up correctly if WooCommerce's own default product page template is used?
( you can test this by temporarily unassigning the Toolset's content template for the single product pages )

I'm setting your next reply as private so that you can share temporary admin login details, along with the example product page where this add-to-cart button is missing.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2419893

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

While I can see the issue of the missing add-to-cart button on your website's product category archive page, I couldn't reproduce this on my test website.

This suggests that something specific to your website is involved. Do I have your permission to download a clone/snapshot of the website, to troubleshoot this on a different server?

#2419935

Sure, download, no problem Waqar.

#2420101

I think the issue comes from the block templates... Not sure if it's because I'm not using blocks for the search and using blocks for the templates? They behave strangely too, like they aren't templates for a product loop.

#2420549

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the permission and I've downloaded the website's clone.

I'll be performing some tests on this clone and will share the findings as soon as this testing completes.

Thank you for your patience.

#2421529

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Just wanted to let you know that I'm still working on this.

I'll be able to share the findings, by the end of the day today.

#2421777

Excellent Waqar, I wonder what hour is end of day to you!
Thank you

#2422203

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting, as this investigation took longer than I initially expected.

During troubleshooting, I discovered that if the WooCommerce product or product taxonomy archive is set to use the classic editor and its loop item template is set to use the blocks editor, the Toolset's "Add to Cart Button" block doesn't work, as expected.

I've shared these findings with the concerned team for further review. For now, there are two workarounds that you can use to replace the "Add to Cart Button" block:

1. You can use the Toolset's "wpv-woo-buy-or-select" shortcode in a "Fields and Text" block:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-woo-buy-or-select

Example:


[wpv-woo-buy-or-select add_to_cart_text="Add to cart"]

OR

2. You can use WooCommerce's "Mini Cart" block.

#2422423

Excellent Waqar other issue in the same dev.
When you paginate or filter in the archive, the shortcode [yith_wcwl_add_to_wishlist] in the Block Template disappears.
You can check it by simply: hidden link
and changing any filter.
I think the issue is with how the page 'refreshes' after the filter, as in maybe it doesn't register as a new page or a page refresh and therefor the shortcode doesn't render since it's not a toolset shortcode. I'm not sure how to or if it can be fixed.
If you change a filter, AJAX reload, doesn't render but if already filtered you hit F5, jazzam.
The only workaround I can think of is maybe adding the shortcode with custom JS code after the AJAX event, but I'd rather not, I think it can impact performance.

//EDIT:
Pagination doesn't work either** le'ts not forget.

#2423077

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for the update and glad that it is sorted now.

1. In my tests, the "Enable AJAX loading" needs to be disabled from WP Admin -> YITH -> Wishlist -> General Settings, to make the wishlist button work with the archive's AJAX-based refreshes.

You can see this working on your staging website now.

2. The pagination is not showing in the archive for these two reasons:

a). In the clone that I have, the archive "mainWooArchive" has this code for the pagination in the "Loop Editor" section, but it is missing from the staging website:


<ul class="pagination">
	<li class="page-item">[wpv-pager-archive-prev-page][wpml-string context="wpv-views"]Previous[/wpml-string][/wpv-pager-archive-prev-page]</li>
	<li class="page-item">[wpv-pager-archive-next-page][wpml-string context="wpv-views"]Next[/wpml-string][/wpv-pager-archive-next-page]</li>
</ul>
[wpv-pager-archive-nav-links output="bootstrap"]

I've added this back and the pagination is now being included in the archive page's markup.

b). On the other hand, the pagination is not showing on the front end, because of this custom CSS code added at WP Admin -> Appearance -> Customize -> Additional CSS:


.woocommerce .products ul, .woocommerce ul.products .product_meta>span {
	display: inherit;
}

.woocommerce .products ul, .woocommerce ul.products .product_meta>span.posted_in {
	display: none;
}

.woocommerce .products ul, .woocommerce ul.products .product_meta>span.tagged_as {
	display: none;
}

If you'll remove these CSS code lines, the pagination links will start showing.

#2423117

Excellent.
One last thing Waqar.
I've been trying to show/hide in the conditional block a container and I can't work out how.
In templates > wooSinglePage
There's 2 containers, the 2nd one has yet another template for showing cross_sales, I would like to hide the entire container if the product in question doesn't have cross_sales. But I can't seem to make it work, I tried with the shortcode wpv-woo-related_products if not empty show, but idk.

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-using-woocommerce-cross-sales-for-conditional-display/

#2424713

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

I've created a new ticket for your question about using cross-sell products in the conditional display and will follow up on it, shortly.
( ref: https://toolset.com/forums/topic/split-using-woocommerce-cross-sales-for-conditional-display/ )

You're welcome to mark this ticket as resolved and start a new one for each new question or concern.

#2424873

My issue is resolved now. Thank you!