Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Jul 29, 2020
2 parents 18940a3 + e0c3613 commit de2530f
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 263 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Timber Integration for WooCommerce

## 0.5.2
## 0.5.3 - 2020-07-29

- Added Twig function `wc_action()` that can be used instead of `action()` 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](https://github.com/mindkomm/timber-integration-woocommerce/blob/master/docs/usage.md#automatic-twig-partial-selection) when using `wc_get_template_part()`. You could only use `wc_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.

## 0.5.2 - 2018-09-06

- 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.

## 0.5.1
## 0.5.1 - 2018-04-30

- Improved default templates.
- Improved documentation.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ Here’s a short list of features it adds and problems it tries to solve:

- [Automatic handling of the `$product` global](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/usage.md#product-global). Whenever you loop through a list of WooCommerce products, the integration will set the `$product` global for you. This will improve compatibility for WooCommerce and its integrations.
- [Enhance Timber’s context](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/usage.md#woocommerce-context).
- [Automatic Twig partial selection](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/usage.md#automatic-twig-partial-selection)
- [Automatic Twig partial selection](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/usage.md#automatic-twig-partial-selection).
- Provide default templates, tips and examples.

## Why would I need this?

This integrations makes sense if you need to develop a highly customized WooCommerce theme in a Timber context. If you try to stick to WooCommerce’s default as much as possible, you might not need this.

## Documentation

- [Installation](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/installation.md)
- [Getting Started](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/getting-started.md)
- [Usage Guide](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/usage.md)
- [Images](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/images.md)
- [Examples](https://github.com/MINDKomm/timber-integration-woocommerce/blob/master/docs/examples.md)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"autoload": {
"psr-4": {
"Timber\\Integrations\\WooCommerce\\": "lib/Timber/Integrations/WooCommerce"
"Timber\\Integrations\\WooCommerce\\": "lib/"
}
}
}
93 changes: 45 additions & 48 deletions defaults/archive-product.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,72 @@
# @hooked woocommerce_breadcrumb - 20
# @hooked WC_Structured_Data::generate_website_data() - 30
#}
{% do action('woocommerce_before_main_content') %}
{% do wc_action('woocommerce_before_main_content') %}

<h1 class="heading-1" id="main-title">{{ title }}</h1>
<header class="woocommerce-products-header">
{% if fn('apply_filters', 'woocommerce_show_page_title', true) %}
<h1 class="woocommerce-products-header__title page-title">{{ title }}</h1>
{% endif %}

{#
# woocommerce_archive_description hook.
#
# @hooked woocommerce_taxonomy_archive_description - 10
# @hooked woocommerce_product_archive_description - 10
#}
{% do action('woocommerce_archive_description') %}

{#
# woocommerce_before_shop_loop hook.
#
# @hooked wc_print_notices - 10
# @hooked woocommerce_result_count - 20
# @hooked woocommerce_catalog_ordering - 30
#}
{% do action('woocommerce_before_shop_loop') %}
{##
# Hook: woocommerce_archive_description.
#
# @hooked woocommerce_taxonomy_archive_description - 10
# @hooked woocommerce_product_archive_description - 10
#}
{% do wc_action('woocommerce_archive_description') %}
</header>

{% if posts %}
<ul class="products">
{% do fn('woocommerce_product_subcategories') %}
{% if fn('woocommerce_product_loop') %}
{#
# woocommerce_before_shop_loop hook.
#
# @hooked wc_print_notices - 10
# @hooked woocommerce_result_count - 20
# @hooked woocommerce_catalog_ordering - 30
#}
{% do wc_action('woocommerce_before_shop_loop') %}

{##
# Depending on your WooCommerce display settings, the `woocommerce_product_subcategories` function
# might reset the $wp_query global. By calling `have_posts()`, we check if there are posts we can
# display.
#}
{% for post in posts if fn('have_posts') %}
<li class="product-items">
{% include 'woocommerce/teaser-product.twig' %}
</li>
{% endfor %}
<ul class="products columns-{{ fn('wc_get_loop_prop', 'columns')|e }}">
{% if fn('wc_get_loop_prop', 'total') %}
{##
# Depending on your WooCommerce display settings, the
# `woocommerce_product_subcategories` function might reset the $wp_query global. By
# calling `have_posts()`, we check if there are posts we can display.
#}
{% for post in posts if fn('have_posts') %}
{{ fn('wc_get_template_part', 'content', 'product' ) }}
{% endfor %}
{% endif %}
</ul>

{% elseif not fn('woocommerce_product_subcategories', [{
before: fn('woocommerce_product_loop_start', false),
after: fn('woocommerce_product_loop_end', false)
}]) %}
{##
# woocommerce_no_products_found hook.
# woocommerce_after_shop_loop hook.
#
# @hooked wc_no_products_found - 10
# @hooked woocommerce_pagination - 10
#}
{% do action('woocommerce_no_products_found') %}
{% do wc_action('woocommerce_after_shop_loop') %}
{% else %}

{##
# Hook: woocommerce_no_products_found.
#
# @hooked wc_no_products_found - 10
#}
{% do wc_action( 'woocommerce_no_products_found' ) %}
{% endif %}

{##
# woocommerce_after_shop_loop hook.
#
# @hooked woocommerce_pagination - 10
#}
{% do action('woocommerce_after_shop_loop') %}

{##
# woocommerce_after_main_content hook.
#
# @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
#}
{% do action('woocommerce_after_main_content') %}
{% do wc_action('woocommerce_after_main_content') %}

{#
# woocommerce_sidebar hook.
#
# @hooked woocommerce_get_sidebar - 10
#}
{% do action('woocommerce_sidebar') %}

{% do wc_action('woocommerce_sidebar') %}
{% endblock %}
42 changes: 42 additions & 0 deletions defaults/content-product.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{# Ensure visibility. #}
{% if product and product.is_visible() %}
<li {{ fn('wc_product_class') }}>
{##
# Hook: woocommerce_before_shop_loop_item.
#
# @hooked woocommerce_template_loop_product_link_open - 10
#}
{% do wc_action('woocommerce_before_shop_loop_item') %}

{##
# Hook: woocommerce_before_shop_loop_item_title.
#
# @hooked woocommerce_show_product_loop_sale_flash - 10
# @hooked woocommerce_template_loop_product_thumbnail - 10
#}
{% do wc_action('woocommerce_before_shop_loop_item_title') %}

{##
# Hook: woocommerce_shop_loop_item_title.
#
# @hooked woocommerce_template_loop_product_title - 10
#}
{% do wc_action('woocommerce_shop_loop_item_title') %}

{##
# Hook: woocommerce_after_shop_loop_item_title.
#
# @hooked woocommerce_template_loop_rating - 5
# @hooked woocommerce_template_loop_price - 10
#}
{% do wc_action('woocommerce_after_shop_loop_item_title') %}

{##
# Hook: woocommerce_after_shop_loop_item.
#
# @hooked woocommerce_template_loop_product_link_close - 5
# @hooked woocommerce_template_loop_add_to_cart - 10
#}
{% do wc_action('woocommerce_after_shop_loop_item') %}
</li>
{% endif %}
58 changes: 34 additions & 24 deletions defaults/single-product.twig
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{% extends 'base.twig' %}

{% block content %}
{##
# woocommerce_before_main_content hook.
#
# @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
# @hooked woocommerce_breadcrumb - 20
#}
{% do wc_action('woocommerce_before_main_content') %}

<div class="container">
<div id="product-{{ post.id }}" {{ fn('post_class', ['product', 'product--' ~ post.product.get_type()]) }}>
{##
# woocommerce_before_single_product hook.
#
# @hooked wc_print_notices - 10
#}
{% do action('woocommerce_before_single_product') %}

<h1 class="heading-1" id="main-title">{{ post.title }}</h1>

{% if post.thumbnail %}
<img src="{{ post.thumbnail.src('thumbnail') }}">
{% endif %}
{##
# Hook: woocommerce_before_single_product.
#
# @hooked wc_print_notices - 10
#}
{% do wc_action('woocommerce_before_single_product') %}

<div id="product-{{ post.id }}" {{ fn('wc_product_class') }}>
{##
# woocommerce_before_single_product_summary hook.
# Hook: woocommerce_before_single_product_summary.
#
# @hooked woocommerce_show_product_sale_flash - 10
# @hooked woocommerce_show_product_images - 20
#}
{% do action('woocommerce_before_single_product_summary') %}
{% do wc_action('woocommerce_before_single_product_summary') %}

<div class="product-summary">
<div class="summary entry-summary">
{##
# woocommerce_single_product_summary hook.
#
Expand All @@ -38,22 +38,32 @@
# @hooked woocommerce_template_single_sharing - 50
# @hooked WC_Structured_Data::generate_product_data() - 60
#}
{% do action( 'woocommerce_single_product_summary' ) %}

<div class="content">{{ post.content }}</div>
{% do wc_action('woocommerce_single_product_summary') %}
</div>

{##
# woocommerce_after_single_product_summary hook.
# Hook: woocommerce_after_single_product_summary.
#
# @hooked woocommerce_output_product_data_tabs - 10
# @hooked woocommerce_upsell_display - 15
# @hooked woocommerce_output_related_products - 20
#}
{% do action('woocommerce_after_single_product_summary') %}
{% do wc_action('woocommerce_after_single_product_summary') %}
</div>

{% do action('woocommerce_after_single_product') %}
</div>
{% do wc_action('woocommerce_after_single_product') %}

{##
# woocommerce_after_main_content hook.
#
# @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
#}
{% do wc_action('woocommerce_after_main_content') %}

{##
# woocommerce_sidebar hook.
#
# @hooked woocommerce_get_sidebar - 10
#}
{% do wc_action('woocommerce_sidebar') %}
{% endblock %}
48 changes: 0 additions & 48 deletions defaults/teaser-product.twig

This file was deleted.

Loading

0 comments on commit de2530f

Please sign in to comment.