All Projects → mtx-z → Sage9-Woocommerce-Integration

mtx-z / Sage9-Woocommerce-Integration

Licence: other
How to use Woocommerce (3.4.3) with Sage 9.0.1 (Blade + SoberWP controllers), WP 4.9.7 (17/07/2018)

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Sage9-Woocommerce-Integration

sage-woocommerce
No description or website provided.
Stars: ✭ 64 (+146.15%)
Mutual labels:  sage, woocommerce
selene
A opinionated Wordpress base theme based on Sage.
Stars: ✭ 31 (+19.23%)
Mutual labels:  blade, sage
Sage
WordPress starter theme with a modern development workflow
Stars: ✭ 11,531 (+44250%)
Mutual labels:  blade, sage
Wpemerge Theme
An organized, ES6 and SASS powered theme taking advantage of the WP Emerge framework. 🚀
Stars: ✭ 249 (+857.69%)
Mutual labels:  blade
avaje-http
Controller generation for Javalin, Helidon SE.
Stars: ✭ 23 (-11.54%)
Mutual labels:  controllers
ava
Ava WordPress Theme
Stars: ✭ 46 (+76.92%)
Mutual labels:  woocommerce
x-blade-components
Laravel Blade Components ready to use
Stars: ✭ 36 (+38.46%)
Mutual labels:  blade
Java China
🍡 此项目已废弃,请移步至 https://github.com/junicorn/roo
Stars: ✭ 232 (+792.31%)
Mutual labels:  blade
BetterDummy
Unlock your displays on your Mac! Smooth scaling, HiDPI unlock, XDR/HDR extra brightness upscale, DDC, brightness and dimming, dummy displays, PIP and lots more!
Stars: ✭ 9,601 (+36826.92%)
Mutual labels:  override
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+26300%)
Mutual labels:  controllers
Routing Controllers
Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage in Express / Koa using TypeScript and Routing Controllers Framework.
Stars: ✭ 3,557 (+13580.77%)
Mutual labels:  controllers
gamepad.js
A simple HTML5 Gamepad handler that provides keyboard-like events for Gamepad sticks and buttons.
Stars: ✭ 21 (-19.23%)
Mutual labels:  controllers
geekbb
😎 Geek dev club.
Stars: ✭ 26 (+0%)
Mutual labels:  blade
HadesVR
The "DIY" SteamVR compatible VR setup made for tinkerers.
Stars: ✭ 88 (+238.46%)
Mutual labels:  controllers
woominecraft-wp
A FREE Minecraft Donation Plugin for WordPress designed to work in conjunction with WooMinecraft for Bukkit/Spigot & WooCommerce to allow the purchasing of virtual items in MineCraft and have them delivered to the servers.
Stars: ✭ 33 (+26.92%)
Mutual labels:  woocommerce
Roo
😋 美观大气的论坛社区
Stars: ✭ 238 (+815.38%)
Mutual labels:  blade
ionic3-woocommerce
Ionic 3 Woocommerce Template
Stars: ✭ 17 (-34.62%)
Mutual labels:  woocommerce
kiwi
Built using only nodejs core. Lightweight, intuitive together with great performance and response timing.
Stars: ✭ 45 (+73.08%)
Mutual labels:  controllers
joycon
Device access library for Joycon(Nintendo Switch)
Stars: ✭ 59 (+126.92%)
Mutual labels:  controllers
Responders
A set of Rails responders to dry up your application
Stars: ✭ 1,925 (+7303.85%)
Mutual labels:  controllers

Sage 9.0.1 Woocommerce (3.4.3) Integration

How to use Woocommerce (3.4.3) with Sage 9.0.1 (Blade + SoberWP controllers), WP 4.9.7 (17/07/2018)

Check dev branches for latest updates.

Check previous release if error with latest.

Features

  • Includes:
    • Blade Woocommerce templates
      • Override using default .php file, or rename to .blade.php to use blade (SoberWP controllers variable are available in both case)
      • place your woocommerce templates overrides in /your-sage-theme/resources/views/woocommerce/
        • eg: /plugins/woocommerce/templates/content-single-product.php => /your-sage-theme/resources/views/woocommerce/content-single-product.blade.php
        • eg: /plugins/woocommerce/templates/single-product/meta.php => /your-sage-theme/resources/views/woocommerce/single-product/meta.blade.php
        • still need test for sub-templates, but seems to works with meta.blade.php
    • SoberWP controllers with Woocommerce blade (or php) templates
      • Get \App global default Sage controller variables available in Woocommerce Blade templates
      • Create custom controllers for Woocommerce templates with same Woocommerce/SoberWP template/naming hierarchy naming logic (eg: single-product controller for single-product.blade.php then content-single-product.blade.php template)

Sources and supports

Changelog

What I usualy do

Editing shop page

  • I prefer not use the default woocommerce shop page. So I do my own template/controller (wp_query) and pagination (will publish soon, really easy) and redirect official shop page to this custom one. As this template is mostly managed by our App\woocommerce_content() and sub-templated. But it is doable, updating woocommerce_content and related sub-template. Longer maybe ? Cleaner for sure :)
  • Single product page, my account, checkout templates should be easy to override
  • I'll publish another repo with "how to's" and helpers for Sage (time, time, time...)

How

Blade for Woocommerce

  • Since V1.1, we force /resources/views/woocommerce.blade.php as first in woocommerce default template file array (see changelog)
  • we add_filter on
    • template_include: edit single-product.php and archive-product.php template path to /resources/views/woocommerce/*.blade.php (then retrieve controller data and render blade as usual)
    • wc_get_template_part: edit woocommerce template method to look for blade files then php files
    • wc_get_template: tell woocommerce to get template from resources/views/
  • single-product.php and archive-product.php includes woocommerce.blade.php template
  • woocommerce.blade.php calls our overrided App\woocommerce_content(get_defined_vars()) that output Woocommerce content

SoberWP controllers data for Woocommerce

  • SoberWP Controller.php (new Loader()) will parse all controller and methods and store them using "slugified" $template name as keys in $this->instance (the controller::class object is stored)
  • SoberWP controller.php loader() will add_filter('sage/template/' . $template . '-data/data') for all controllers (filter string/controller) with a method that return, (among other datas) the controller data we want
  • Sage/WP will normally get single-product.php template (changed as single-product.blade.php in our add_filter('template_include') and add_filter('wc_get_template_part') updates targeted in /resources/views thanks to our add_filter('wc_get_template')) as template hierarchy rules
  • Sage will apply_filter('sage/template/' . $template . '-data/data') (it uses body_class() to find the $template name to match the correct controllers with current template) to add data to the blade->render (that also render sub-templates that could also need controller data) from template_include filter (that we override but just for the "single-product.php" and "archive-product.php" replace update, and load controller data)
  • At the moment, (we are in resources/views/woocommerce/single-product.blade.php), data are defined in get_defined_data() (as rendered from filter template_include with controllers data), so WE HAVE THE DATA HERE
  • from here, we call helpers::template() (We don't have HTMl here, we call a method to output Woocommerce content) using woocommerce as template, and we send our vars (from get_dedined_vars()) to it
  • woocommerce.blade.php will call App\woocommerce_content(get_defined_vars()) ===> HERE we lose data if we don't pass get_defined_vars() as parameter
    • App\woocommerce_content() is overrided from Woocommerce wp-content/plugins/woocommerce/includes/wc-template-functions.php
    • to add a parameter to pass $args, which are our datas
  • App\woocommerce_content() will output correct Woocommerce template hierarchy, passing $args to wc_get_template_part() it calls

Todo

  • few test with SoberWP 2.0.1
    • Few errors as default Namespace changes from \App to \App\Controller
    • should be fixable when Sage update to SoberWP Controller 2.0.1
  • Lot of Woocommerce features and templates (and controller variables passing) to test...
  • controllers variables to sub templates (& nested)

Careful

  • Absolutely not tested with all Woocommerce templates and features
    • Checkout, My accounts, Emails, nested templates, Woocommerce plugins templates... need more tests
  • Test before usage in production (I do and it runs smoothly tho, but it's not a complex store)
  • still WIP, issues and improvement reports are welcomed !
  • Notice error about theme requiring header.php and sidebar.php as it's deprecated to be without since 3.0.0, see roots/sage@1620
    • (Theme without header.php is deprecated since version 3.0.0 with no alternative available. Please include a header.php/sidebar.php template in your theme. \wp-includes\functions.php)

DEBUG

SoberWP

@debug('dump')
@debug('hierarchy')
@debug('controller')
@debug

get hooked methods for given filter

function print_filters_for( $hook = "" ) {
global $wp_filter;
    if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
        return;

    print "<pre>";
    print_r( $wp_filter[$hook] );
    print "</pre>";
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].