Skip to content

1.0.0

Compare
Choose a tag to compare
@gchtr gchtr released this 08 May 09:59
· 6 commits to 1.x since this release
bddcccb

Breaking changes 💥

(More details further down)

  • Added support for Timber 2.0 and removed 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. Use get_post() instead.
  • Removed wc_action() Twig function. Use {% do action() %} instead of {% do wc_action() %}.

What’s changed since 1.0.0-rc.1

  • 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 WooCommerce system status correctly display outdated WooCommerce templates, even if they are Twig templates.
  • Changed Twig template loader to not load views from the caller directory.

Other changes

  • Added support for PHP 8.0 and higher.
  • Removed custom arguments for the init function in 486766c
  • Fixed a bug when context didn’t contain a post for singular product templates in 1a2b3c8

New way to set up integration

🚫 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;
} );

Removed arguments for the integration

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.

Use a custom class for products

🚫 Before

Timber\Integrations\WooCommerce\WooCommerce::init( [
    'product_class' => 'MyProductClass',
] );

✅ After

add_filter( 'timber/product/classmap', function( $classmap ) {
    $classmap['product'] = 'MyProductClass';

    return $classmap;
}, 20 );

No more custom product iterator

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.

Set a subfolder for the Twig templates

🚫 Before

Timber\Integrations\WooCommerce\WooCommerce::init( [
    'subfolder' => 'woo',
] );

✅ After

add_filter( 'timber/woocommerce/views_folder', function( $subfolder ) {
    return 'woo';
} );

Updated Twig functions

🚫 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') %}

Full Changelog: 1.0.0-rc.1...1.0.0