1.1.0 (2024-09-10)
- Add
timber/woocommerce/views_folder
filter (4c0222c)
- docs: Update Getting Started guide with recommended way of initializing the integration (#45) (4de815c)
- Added support for Timber 2.0 and removes support for Timber 1.x.
- Bumped minimum required PHP version to 7.4.
- Updated how to set up the integration.
- Removed
Product()
function in Twig. Useget_post()
instead. - Removed
wc_action()
Twig function. Use{% do action() %}
instead of{% do wc_action() %}
.
- Added support for PHP 8.0 and higher.
🚫 Before
if ( class_exists( 'WooCommerce' ) ) {
\Timber\Integrations\WooCommerce\WooCommerce::init();
}
✅ After
add_filter( 'timber/integrations', function ( array $integrations ): array {
$integrations[] = new \Timber\Integrations\WooCommerce\WooCommerceIntegration();
return $integrations;
} );
If you passed options to the Timber\Integrations\WooCommerce\WooCommerce::init()
, you will have to change how you pass them. The new way to init the integration doesn’t take any arguments anymore.
🚫 Before
Timber\Integrations\WooCommerce\WooCommerce::init( [
'product_class' => 'MyProductClass',
] );
✅ After
add_filter( 'timber/product/classmap', function( $classmap ) {
$classmap['product'] = 'MyProductClass';
return $classmap;
}, 20 );
Post iterators were removed in Timber 2.0. If you’ve used the product_iterator
argument, you can use the setup()
and teardown()
methods on your custom product class instead.
🚫 Before
Timber\Integrations\WooCommerce\WooCommerce::init( [
'subfolder' => 'woo',
] );
✅ After
add_filter( 'timber/woocommerce/views_folder', function( $subfolder ) {
return 'woo';
} );
🚫 Before
# Getting a product
<img src="{{ Product(id).thumbnail.src|resize(200, 200) }}">
# Calling an action
{% do wc_action('woocommerce_before_shop_loop') %}
✅ After
# Getting a product
<img src="{{ get_post(id).thumbnail.src|resize(200, 200) }}">
# Calling an action
{% do action('woocommerce_before_shop_loop') %}
- Fixed a bug when Twig templates would be falsely rendered on the /system_status endpoint of the WooCommerce REST API.
- Added the possibility to make the system status work with outdated WooCommerce templates.
- Changed Twig template loader to not load views from the caller directory.
- Fixed a bug when product global is not present on singular product pages.
- Updated PHP requirements to allow PHP 8.0 and higher.
- Fixed a couple of issues with
$product
global not being kept in sync. - Added small improvements in documentation.
- Improved when this integration applies Product classes and Product Iterators to single posts and lists of posts. This should make it easier to have collections of WooCommerce products and other WordPress post types on the same page. Internally, this integration now uses a Class Map for the
product
post type. This means that you can also extend this integration’sTimber\Integrations\WooCommerce\Product
class with your ownProduct
class. - Improved default archive-product.twig template and added default templates for loop/loop-start.twig and loop/loop-end.twig.
- Added a default checkout/form-checkout.twig template.
- Added a
$context
parameter to therender_default_template()
function. When you pass a context to this function, it will be merged with Timber’s default context. - Added a
post
variable to the context in Twig template partials. - Fixed a bug when calling
Timber\Post::__construct()
messed up the$product
global. - Fixed a compatibility issue with admin-ajax.
- Fixed merge bug.
- Added Twig function
wc_action()
that can be used instead ofaction()
when calling hooks from Twig. In Twig, you would use it like this:{% do wc_action('woocommerce_single_product_summary') %}
. This was added to fix compatibility problems when hooks were used with parameters. (See #14, thanks @pascalknecht) - Added support for Automatic Twig partial selection when using
wc_get_template_part()
. You could only usewc_get_template()
before. Now, you can use both. - Fixed a bug when the
$post
global was not properly set when looping over products. - Updated default templates.
- Updated internal repository folder structure.
- Fixed bug that prevented the integration from working with different versions of Twig. Thanks @chrislind and @VincentLoy!
- Removed non-working support for installing the integration as a WordPress plugin. The integration can only be installed through Composer. Future versions of Timber will will drop support for installation as a plugin. That’s why drop it here, too.
- Improved default templates.
- Improved documentation.