Sage 9, Sensei plugin, WooCommerce templating

Hi!

Im trying to override a third party plugin, Sensei from WooCommerce with Sage. As others have done with WooCommerce I created a folder in resources, /resources/sensei/archive-course.php and in that put: <?php echo App\Template('sensei'); ?>
Then in my views folder, /resources/views/archive-course.blade.php. Tho I dont seem to be able to override it. Since its WooCommerce that have made the plugin and overriding it in the standard way is the same as with WooCommerce, I thought it would behave similar…

Im not sure what I am missing since Im fairly new to Sage and Blade in general. Any help is greatly appreciated!

Kr,
Jesper

I haven’t heard of Sensei before, but I’d recommend adding this to your Sage project and see if it helps with replacing templates https://github.com/roots/sage-woocommerce.

Read the readme on there and apply that same stuff to the Sensei templates.

@codepuncher So its been a while and Ive installed that and also been in contact with one of the developers. I think Im on the right track, tho I cant seem to be able to make it run my functions instead. I put a “woothemes-sensei.php” file as you can see in the image.

All Im trying at this point is getting it to load this file so that I can go from there and I think I will be alright. I cant see that the other plugin is doing anything different… Anything Im missing?

Im using visual studio code and xdebugger and can see it entering the other file but not mine. Below is the other plugin and breakpoints that hits.

Any help or pointers is greatly appreciated!

Hi @Heichichi,

Adding it under vendor/roots/sage-sensei won’t make Sage load it automatically. For that, you would need to make it a Composer package, host it somewhere (like on Github or Packagist), and use Composer to install it in your theme (like with Sage WooCommerce).

Your first and simplest option is to skip all of that and just put your woothemes-sensei.php file in your theme’s app folder, and then modify this bit in your theme’s functions.php file to tell Sage to load it:

/**
 * Sage required files
 *
 * The mapped array determines the code library included in your theme.
 * Add or remove files to the array as needed. Supports child theme overrides.
 */
array_map(function ($file) use ($sage_error) {
    $file = "../app/{$file}.php";
    if (!locate_template($file, true, true)) {
        $sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
    }
}, ['helpers', 'setup', 'filters', 'admin', 'woothemes-sensei']);

I would start here to get things working.

If you later want to package your Sensei code to publish it to the world or make it more easily reusable for yourself, then you would need to look into the Composer stuff.

1 Like

Any progress, on this? i’m also looking to do the same. Otherwise i’m going to create my own composer package for sensei, sadly some function are different from woocommerce.

That would be great to see a sage-sensei package! Packages like this would be so helpful.

Anyone get this working? Sensei and Sage Blade tempaltes?

I am struggling with Sensei integration as well. So I guess I will have to get the same functions working for woocommerce into Sensei v3.5.

I have one question though in case someone has made some progress with this; as I understand, the problem getting sensei working is the theme wrappers, as described here . Is it the same problem that Woocommerce-Sage addresses?

Anyway, if someone has made progress with this, or is working at it at the moment I would appreciate any insights.

Hi Sergi, I have this working on my site using this code that I made:

Now you can add single-course.blade.php and single-lesson.blade.php under your-theme/resources/views/sensei (like this one https://gist.github.com/dacmail/efbfcb4b15840ed3f993647b5c43f724)

Others templates files you need to change yo have to put under your-theme/resources/sensei/ without using blade.

I hope this can help you. Sorry for my english.

Thanks! I was struggling with the module taxonomy template, which gets wrapped using its system.

I will give it a try and confirm it works…