Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WooCommerce support #2086

Closed
wants to merge 4 commits into from
Closed

Add WooCommerce support #2086

wants to merge 4 commits into from

Conversation

mejta
Copy link
Contributor

@mejta mejta commented Jul 27, 2018

Making WooCommerce work in Sage can be a hard task to do right for a beginner. I tried to find a way, and this is what I came with. I think that WooCommerce is such a popular plugin that it should be supported out-of-the-box. I've created the pull request with an as little footprint as possible.

With this pull request, you can easily overwrite any WooCommerce template by placing it into /resources/views/woocommerce folder, and it just works. You can even use controllers to inject variables you need as usual. Hooks are called only if WooCommerce is activated, checking the WC_ABSPATH constant defined.

@QWp6t
Copy link
Member

QWp6t commented Jul 27, 2018

Hey thanks for the PR. Looks like this is mostly a duplicate of #1923 (feel free to review that PR and poach anything you want from it), which we discussed internally and decided against.

Something like this should probably be in our docs or as a guide on our website (for example, we already have a guide for using WooCommerce with Sage 8.x, but not one for Sage 9). I believe @retlehs can get you set up if you want to publish a guide on our site.

I'll still leave the PR open for now in case any other members of the team have had a change of heart.

@mejta
Copy link
Contributor Author

mejta commented Jul 27, 2018

Hi,

Thank you for your reply. I saw your pull request, but it didn’t work as expected. In this PR I use different filters and it catches all templates now without errors mentioned in previous PR (with exception of get_header/footer/sidebar).

I also feel that problems with WooCommerce implementation are so frequent that it should be supported. Also WooCommerce is created by WordPress authors and that makes this plugin somehow special. So I would vote for merging :)

If decidion won’t be to merge that, I will be happy to publish the blog post with the guide on your site.

@retlehs
Copy link
Member

retlehs commented Jul 27, 2018

@bdmason wrote this up as a guide this week: https://gist.github.com/bdmason/f26bb8891a3c066ce609200d5ad95912

was planning on publishing this on the site once i gave it a quick test. this PR also seems like a good approach

@retlehs
Copy link
Member

retlehs commented Jul 27, 2018

but to follow up on what @QWp6t said, we'll be looking to keep this as a guide rather than including by default within sage

it could possibly be an option in the sage-installer

Also WooCommerce is created by WordPress authors and that makes this plugin somehow special. So I would vote for merging :)

this doesn't mean much to us fwiw. jetpack 🚮 was also written by wordpress authors, and woocommerce somehow gets away with aggressively promoting that garbage within their own plugin

@Log1x
Copy link
Member

Log1x commented Jul 27, 2018

It's a nice approach. I think it'd serve nicely as a mu-plugin brought it via Composer rather than directly into sage/sage-installer along with a conditional wrap checking for function_exists('\App\sage') to prevent unwarranted effects by the unknowing.

@MWDelaney
Copy link
Member

I like the "just works" promise of this solution, and the fact that templates are within views.

@RistoNiinemets
Copy link
Contributor

It would be a great addition to Sage installer, but not included by default.

@MWDelaney
Copy link
Member

Could this be packaged as a composer library and autoloaded? This and the Bootstrap Navwalker might make a good start of a “useful Sage addons” set of composer libraries managed (or at least endorsed) by Roots?

@mejta
Copy link
Contributor Author

mejta commented Jul 30, 2018

Thank you all for the inputs. I understand that this won't appear in Sage. So now the question is if I should write a guide and how @retlehs? And this is a really no-config piece of code that can be autoloaded with the composer. I think that @MWDelaney had a great idea about the curated Sage addons list.

(I'm also a fan of minimal code, so I made a refactoring to make the code even smaller.)

@retlehs
Copy link
Member

retlehs commented Jul 30, 2018

@mejta i created a repo at https://github.com/roots/sage-woocommerce - could you please submit a PR over there with the code from this PR?

just need to add a composer.json & autoload the PHP, but we can handle that part if you don't wanna worry about it

@QWp6t QWp6t closed this Jul 30, 2018
@mejta
Copy link
Contributor Author

mejta commented Aug 1, 2018

I will, later this week.

@mtx-z
Copy link

mtx-z commented Aug 1, 2018

I also wrote a quick repository to make Sage 9.0.1 works with Woocommerce 3.4.3 : https://github.com/mtx-z/Sage9-Woocommerce-Integration.

It's not as tested as https://github.com/hambos22/sage-woo maybe, but it is "easily" applicable to a fresh Sage app (to get blade and controllers working). It uses the woocommerce.blade.php technic (hambos22 don't).

@mejta
Copy link
Contributor Author

mejta commented Aug 2, 2018

@retlehs Please, can you initialise the repository https://github.com/roots/sage-woocommerce with readme file or something? It's not possible to fork and open PR in an empty repository. Thank you.

@mejta
Copy link
Contributor Author

mejta commented Aug 2, 2018

@retlehs I've created https://github.com/mejta/sage-woocommerce repository that can be cloned to the repository you've created.

@retlehs
Copy link
Member

retlehs commented Aug 2, 2018

thanks @mejta - just imported it to https://github.com/roots/sage-woocommerce

@bramvdpluijm
Copy link

@mejta @retlehs Hey guys! I really tried everything regarding WooCommerce and sage 9. I installed the composer package composer require roots/sage-woocommerce and created the folder structure as stated in the readme of https://github.com/roots/sage-woocommerce. My folder structure looks like this: /resources/views/woocommerce. In there I have 2 files "archive-product.blade.php" and "single-product.blade.php". They just won't overwrite the normal WooCommerce templates. What am I missing?

@MWDelaney
Copy link
Member

@bramvdpluijm can you start a thread on https://discourse.roots.io to discuss this issue?

@bramvdpluijm
Copy link

Sure thing. I created this https://discourse.roots.io/t/woocommerce-sage-9-blade-support/13300. Have a look @MWDelaney . Feel free to join the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants