Generoi/sage-woocommerce templates not picked up?

Hi again,

Run into another problems and would be grateful for a helping hand or two.

In /resources/views/woocommerce

I’m trying to override the cart and checkout page for woocommerce, but they don’t seem to be picked up by sage/sage-woocommerce. Other templates works, so I’m wondering if there’s something i missed?

for example, these works as expected:

/resources/views/woocommerce/myaccount/form-login.blade.php
/resources/view/woocommerce/myaccount/my-account.blade.php

However, cart and checkout, it displays the default template from woocommerce not matter what I have in the file:

/resources/woocommerce/cart/cart.blade.php
/resources/woocommerce/checkout/form-checkout.blade.php

Is there something specific to the cart and checkout page that I should know about?

Thanks, in advance!

My 2cts here: Is there a chance that you are using the Full Site Editing (FSE) cart block / cart template page?

Not that i’m aware of. Though I’m pretty ignorant about the FSE and blocks in general.

Is there a setting or lines of code that says my theme is a block theme? (Did a quick search and doesn’t seem mine is. My theme.json also doesn’t indicate anything about FSE/Blocks.)

When I go to Appearance->Customize, it’s the old style wordpress menu instead of blocks.

Yes, this looks like Classic WooCommerce templating.

Does overriding any WooCommerce template work?
Have you also done the extra steps (discover + publish) for generoi/sage-woocommerce?

Hey thanks,

Yes. I’ve done discover and publish, and yes other templates work.
Screenshot 2024-01-08 at 4.31.43 PM

So myaccount works and archive-product and single-product works.

And with cart and checkout, it doesn’t. Since you mentioned block themes, I’d like to mention that when I navigate to the cart and checkout page, blocks are generated. (i.e. it’s just a lot of div with nothing in the html.)

I’ve also tried putting cart.blade.php up a level (/woocommerce/cart.blade.php) to no avail.

Could you show a screenshot of the DOM of the cart and/or checkout page? Just to be sure?

Certainly

This is the checkout page.

This confirms the suspicion that those are Gutenberg blocks. Those can not be overridden like classic WooCommerce blocks.

From server side the render_block filter can be used. Depending on the block (server-side rendered or hybrid (JS + server-side)) the block edit React markup may also need to be adjusted.

You may also find this discussion interesting:

Note that this particular discussion is about a product list - but there are different approaches to re-using the classic/server-side markup and modifying it for those Gutenberg blocks, so this could be useful with the cart block also.

2 Likes

Thanks!

I have now solved this.

For anyone who might have the same problem, Woocommerce now install all the pages with blocks instead of shortcode. You can remove the default blocks from the cart and checkout page and insert the old shortcode with a shortcode block. This will return Woocommerce to its old behaviour.

Cheers and thanks again for your help, strarsis.

1 Like

This may be relevant:

Hi, after installing the plugin I tried to edit woocommerce/single-product.blade.php, but the changed won’t appear in the browser. Do you have any idea how to get this working? I followed all steps in in the installation…

Are you using the shortcodes for the legacy WooCommerce pages?
Otherwise not the classic WooCommerce templates are used, but the Gutenberg blocks instead (with their own backend/JavaScript editor templates).

Thanks for the reply. I’m talking about normal product pages. It looks like the package isn’t completely loaded. The theme still thinks WooCommerce support isnt active…

Could you be putting it in ~themedir/woocommerce/ instead of ~/themedir/resources/views/woocommerce/?

1 Like