Skip Navigation

[Resolved] Woocommerce views plugin has config problem with load-balanced servers

This support ticket is created 5 years, 6 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.

Our next available supporter will start replying to tickets in about 0.52 hours from now. Thank you for your understanding.

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 3 voices.

Last updated by ahmedI 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1129380

The Woocommerce plugin for views is causing a weird problem for me. I set the value of the Product template, and it works for a bit, then it stops working, or only works sporadically.

I think I've discovered why.

We run our sites on Pantheon, which has a load-balanced setup. That means the full path to WordPress resources can change as the bindings change.

In other words, /srv/bindings/1234/code/wp-content/plugins/woocommerce-views/templates/single-product.php

might become /srv/bindings/5678/code/wp-content/plugins/woocommerce-views/templates/single-product.php

So what happens is you set the value in the admin page for Woocommerce views, then another server serves the page, sees that the page doesn't exist on that server and bumps it back to default, which of course breaks your custom product page.

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

My temporary fix is to actually replace the single-product.php template in the Woocommerce plugin folder with the one from Woocommerce views (because even a copy in the child theme won't work), but this is obviously fraught with peril.

#1129658

Hello,

This is an exception with your load-balanced web server.

In my opinion, the best option is synchronizing your website files and path in each servers , then Woocommerce Views plugin will be able to locate the same file in different web server.

And Woocommerce Views plugin is using a wordpress option "woocommerce_views_theme_template_file" to store the file path, and use wordpress function get_option() to retrieve the option value, so you can use filter hook "option_woocommerce_views_theme_template_file" to change the file path to what you want, for example:

add_filter('option_woocommerce_views_theme_template_file', function($value, $option){
	return array('twentyseventeen' => '\www\wordpress\wp-content\plugins\woocommerce-views\templates\single-product-2.php');
}, 10, 2);

Please replace "twentyseventeen" with your theme slug

#1129965

I assume there's no way to use a relative path to the WordPress installation directory?

#1130424

Yes, it is possible, I have tried it in my localhost, you can use var ABSPATH to get the WordPress installation directory, then setup the template file path, for example:

add_filter('option_woocommerce_views_theme_template_file', function($value, $option){
		return array('twentyseventeen' => ABSPATH  . '\wp-content\plugins\woocommerce-views\templates\single-product.php');
	}, 10, 2);
#1138416

Hi,
I have the exact same problem and i tried your solution Luo but it didn't work.

I changed the theme slug and everything.

Any suggestions?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.