Docs/check payment method support (#50845)
* Fixed minor issues with recently added snippets docs Fixed a few duplicate titles and encoding issues in the docs that were recently added via public resources. * Create docs-check_payment_method_support * update manifest * fix linter errors --------- Co-authored-by: Yaku <15178758+jacoswan@users.noreply.github.com>
This commit is contained in:
parent
796854770c
commit
7dd2f11805
|
@ -5,8 +5,6 @@ tags: payment-methods
|
|||
current wccom url: https://woocommerce.com/document/check-if-payment-gateway-supports-refunds-subscriptions-preorders/
|
||||
---
|
||||
|
||||
# Check if a Payment Method Support Refunds, Subscriptions or Pre-orders
|
||||
|
||||
If a payment method's documentation doesn’t clearly outline the supported features, you can often find what features are supported by looking at payment methods code.
|
||||
|
||||
Payment methods can add support for certain features from WooCommerce and its extensions. For example, a payment method can support refunds, subscriptions or pre-orders functionality.
|
||||
|
@ -41,4 +39,4 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
|
|||
);
|
||||
```
|
||||
|
||||
If you don’t find `$this->supports` in the plugin files, that may mean that the payment method isn’t correctly declaring support for refunds, subscripts or pre-orders.
|
||||
If you don't find `$this->supports` in the plugin files, that may mean that the payment method isn't correctly declaring support for refunds, subscripts or pre-orders.
|
||||
|
|
|
@ -5,15 +5,11 @@ tags: code-snippet, tax
|
|||
current wccom url: https://woocommerce.com/document/setting-up-taxes-in-woocommerce/configuring-specific-tax-setups-in-woocommerce/#configuring-special-tax-setups
|
||||
---
|
||||
|
||||
# Code snippets for configuring special tax scenarios
|
||||
|
||||
## Scenario A: Charge the same price regardless of location and taxes
|
||||
|
||||
Scenario A: Charge the same price regardless of location and taxes
|
||||
|
||||
If a store enters product prices including taxes, but levies various location-based tax rates, the prices will appear to change depending on which tax rate is applied. In reality, the base price remains the same, but the taxes influence the total. [Follow this link for a detailed explanation](https://woocommerce.com/document/how-taxes-work-in-woocommerce/#cross-border-taxes).
|
||||
|
||||
Some merchants prefer to dynamically change product base prices to account for the changes in taxes and so keep the total price consistent regardless of tax rate. Enable that functionality by adding the following snippet to your child theme’s functions.php file or via a code snippet plugin.
|
||||
Some merchants prefer to dynamically change product base prices to account for the changes in taxes and so keep the total price consistent regardless of tax rate. Enable that functionality by adding the following snippet to your child theme's functions.php file or via a code snippet plugin.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
@ -23,7 +19,7 @@ add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
|
|||
|
||||
## Scenario B: Charge tax based on the subtotal amount
|
||||
|
||||
The following snippet is useful in case where a store only ads taxes when the subtotal reaches a specified minimum. In the code snippet below that minimum is 110 of the store’s currency. Adjust the snippet according to your requirements.
|
||||
The following snippet is useful in case where a store only ads taxes when the subtotal reaches a specified minimum. In the code snippet below that minimum is 110 of the store's currency. Adjust the snippet according to your requirements.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
@ -42,7 +38,7 @@ function big_apple_get_tax_class( $tax_class, $product ) {
|
|||
|
||||
Some merchants may require different tax rates to be applied based on a customer role to accommodate for wholesale status or tax exemption.
|
||||
|
||||
To enable this functionality, add the following snippet to your child theme’s functions.php file or via a code snippet plugin. In this snippet, users with “administrator” capabilities will be assigned the **Zero rate tax class**. Adjust it according to your requirements.
|
||||
To enable this functionality, add the following snippet to your child theme's functions.php file or via a code snippet plugin. In this snippet, users with “administrator” capabilities will be assigned the **Zero rate tax class**. Adjust it according to your requirements.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
@ -62,7 +58,7 @@ add_filter( 'woocommerce_product_variation_get_tax_class', 'wc_diff_rate_for_use
|
|||
|
||||
## Scenario D: Show 0 value taxes
|
||||
|
||||
Taxes that have 0-value are hidden by default. To show them regardless, add the following snippet to your theme’s functions.php file or via a code snippet plugins:
|
||||
Taxes that have 0-value are hidden by default. To show them regardless, add the following snippet to your theme's functions.php file or via a code snippet plugins:
|
||||
|
||||
```php
|
||||
add_filter( 'woocommerce_order_hide_zero_taxes', '__return_false' );
|
||||
|
@ -70,7 +66,7 @@ add_filter( 'woocommerce_order_hide_zero_taxes', '__return_false' );
|
|||
|
||||
## Scenario E: Suffixes on the main variable product
|
||||
|
||||
One of the tax settings for WooCommerce enables the use of suffixes to add additional information to product prices. It’s available for use with the variations of a variable product, but is disabled at the main variation level as it can impact website performance when there are many variations.
|
||||
One of the tax settings for WooCommerce enables the use of suffixes to add additional information to product prices. It's available for use with the variations of a variable product, but is disabled at the main variation level as it can impact website performance when there are many variations.
|
||||
|
||||
The method responsible for the related price output can be customized via filter hooks if needed for variable products. This will require customization that can be implemented via this filter:
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 189 KiB |
|
@ -4,10 +4,13 @@ menu_title: Disabling marketplace suggestions
|
|||
current wccom url: https://woocommerce.com/document/woocommerce-marketplace-suggestions-settings/#section-6
|
||||
---
|
||||
|
||||
## Disabling Marketplace Suggestions Programmatically
|
||||
|
||||
For those who prefer to programmatically disable marketplace suggestions that are fetched from woocommerce.com, add the `woocommerce_allow_marketplace_suggestions` filter to your theme’s `functions.php` or a custom plugin.
|
||||
|
||||
For example:
|
||||
|
||||
```php
|
||||
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false' );
|
||||
```
|
||||
|
||||
This filter will completely remove Marketplace Suggestions from your WooCommerce admin.
|
||||
|
|
|
@ -18,7 +18,7 @@ The functionality to hide all other methods, and only show Free Shipping, requir
|
|||
|
||||
Before adding snippets, clear your WooCommerce cache. Go to WooCommerce > System Status > Tools > WooCommerce Transients > Clear transients.
|
||||
|
||||
Add this code to your child theme’s `functions.php`, or via a plugin that allows custom functions to be added. Please don’t add custom code directly to a parent theme’s `functions.php` as changes are entirely erased when a parent theme updates.
|
||||
Add this code to your child theme's `functions.php`, or via a plugin that allows custom functions to be added. Please don't add custom code directly to a parent theme's `functions.php` as changes are entirely erased when a parent theme updates.
|
||||
|
||||
## Code Snippets
|
||||
|
||||
|
@ -34,7 +34,7 @@ This means you can use `add_filter()` on `woocommerce_shipping_free_shipping_is_
|
|||
|
||||
### How do I only show Free Shipping?
|
||||
|
||||
The following snippet hides everything but `free_shipping`, if it’s available and the customer's cart qualifies.
|
||||
The following snippet hides everything but `free_shipping`, if it's available and the customer's cart qualifies.
|
||||
|
||||
```php
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_availabl
|
|||
|
||||
### How do I only show Local Pickup and Free Shipping?
|
||||
|
||||
The snippet below hides everything but `free_shipping` and `local_pickup`, if it’s available and the customer's cart qualifies.
|
||||
The snippet below hides everything but `free_shipping` and `local_pickup`, if it's available and the customer's cart qualifies.
|
||||
|
||||
```php
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
---
|
||||
post_title: Legacy Local Pickup Advanced Settings and Customization
|
||||
post_title: Advanced settings and customization for legacy Local Pickup
|
||||
tags: code-snippet
|
||||
current wccom url: https://woocommerce.com/document/local-pickup/#advanced-settings-customization
|
||||
note: Docs links out to Skyverge's site for howto add a custom email - do we have our own alternative?
|
||||
---
|
||||
|
||||
# Advanced settings and customization for legacy Local Pickup
|
||||
|
||||
## Disable local taxes when using local pickup
|
||||
|
||||
Local Pickup calculates taxes based on your store’s location (address) by default, and not the customer’s address. Add this snippet at the end of your theme's `functions.php` to use your standard tax configuration instead:
|
||||
Local Pickup calculates taxes based on your store's location (address) by default, and not the customer's address. Add this snippet at the end of your theme's `functions.php` to use your standard tax configuration instead:
|
||||
|
||||
```php
|
||||
add_filter( 'woocommerce_apply_base_tax_for_local_pickup', '__return_false' );
|
||||
|
@ -19,7 +17,7 @@ Regular taxes is then used when local pickup is selected, instead of store-locat
|
|||
|
||||
## Changing the location for local taxes
|
||||
|
||||
To charge local taxes based on the postcode and city of the local pickup location, you need to define the shop’s base city and post code using this example code:
|
||||
To charge local taxes based on the postcode and city of the local pickup location, you need to define the shop's base city and post code using this example code:
|
||||
|
||||
```php
|
||||
add_filter( 'woocommerce_countries_base_postcode', create_function( '', 'return "80903";' ) );
|
||||
|
@ -33,5 +31,5 @@ Update `80903` to reflect your preferred postcode/zip, and `COLORADO SPRINGS` wi
|
|||
_Shipping Address_ is not displayed on the admin order emails when Local Pickup is used as the shipping method.
|
||||
|
||||
Since all core shipping options use the standard order flow, customers receive the same order confirmation email whether they select local pickup or any other shipping option.
|
||||
Use this guide to create custom emails for local pickup if you’d like to send a separate email for local pickup orders: [How to Add a Custom WooCommerce Email](https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/).
|
||||
Use this guide to create custom emails for local pickup if you'd like to send a separate email for local pickup orders: [How to Add a Custom WooCommerce Email](https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/).
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ tags: code-snippet
|
|||
current wccom url: https://woocommerce.com/document/woocommerce-localization/#making-your-translation-upgrade-safe
|
||||
---
|
||||
|
||||
# Making your translation upgrade safe
|
||||
|
||||
Like all other plugins, WooCommerce keeps translations in `wp-content/languages/plugins`.
|
||||
|
||||
However, if you want to include a custom translation, you can add them to `wp-content/languages/woocommerce`, or you can use a snippet to load a custom translation stored elsewhere:
|
||||
|
|
|
@ -9,7 +9,7 @@ current wccom url: https://woocommerce.com/document/ssl-and-https/#websites-behi
|
|||
|
||||
WooCommerce uses the `is_ssl()` WordPress function to verify if your website using SSL or not.
|
||||
|
||||
`is_ssl()` checks if the connection is via HTTPS or on Port 443. However, this won’t work for websites behind load balancers, especially websites hosted at Network Solutions. For details, read [WordPress is_ssl() function reference notes](https://codex.wordpress.org/Function_Reference/is_ssl#Notes).
|
||||
`is_ssl()` checks if the connection is via HTTPS or on Port 443. However, this won't work for websites behind load balancers, especially websites hosted at Network Solutions. For details, read [WordPress is_ssl() function reference notes](https://codex.wordpress.org/Function_Reference/is_ssl#Notes).
|
||||
|
||||
Websites behind load balancers or reverse proxies that support `HTTP_X_FORWARDED_PROTO` can be fixed by adding the following code to the `wp-config.php` file, above the require_once call:
|
||||
|
||||
|
|
|
@ -5,20 +5,18 @@ tags: code-snippet
|
|||
current wccom url: https://woocommerce.com/document/installing-uninstalling-woocommerce/#uninstalling-woocommerce
|
||||
---
|
||||
|
||||
# Uninstall and remove all WooCommerce Data
|
||||
|
||||
The WooCommerce plugin can be uninstalled like any other WordPress plugin. By default, the WooCommerce data is left in place though.
|
||||
|
||||
If you need to remove *all* WooCommerce data as well, including products, order data, coupons, etc., you need to to modify the site’s `wp-config.php` *before* deactivating and deleting the WooCommerce plugin.
|
||||
If you need to remove *all* WooCommerce data as well, including products, order data, coupons, etc., you need to to modify the site's `wp-config.php` *before* deactivating and deleting the WooCommerce plugin.
|
||||
|
||||
As this action is destructive and permanent, the information is provided as is. WooCommerce Support cannot help with this process or anything that happens as a result.
|
||||
|
||||
To fully remove all WooCommerce data from your WordPress site, open `wp-config.php`, scroll down to the bottom of the file, and add the following constant on its own line above `/* That’s all, stop editing. */`.
|
||||
To fully remove all WooCommerce data from your WordPress site, open `wp-config.php`, scroll down to the bottom of the file, and add the following constant on its own line above `/* That's all, stop editing. */`.
|
||||
|
||||
```php
|
||||
define( 'WC_REMOVE_ALL_DATA', true );
|
||||
|
||||
/* That’s all, stop editing! Happy publishing. */
|
||||
/* That's all, stop editing! Happy publishing. */
|
||||
```
|
||||
|
||||
Then, once the changes are saved to the file, when you deactivate and delete WooCommerce, all of its data is removed from your WordPress site database.
|
||||
|
|
|
@ -5,8 +5,6 @@ tags: code-snippet
|
|||
current wccom url: https://woocommerce.com/document/digital-downloadable-product-handling/#protecting-your-uploads-directory
|
||||
---
|
||||
|
||||
## Using NGINX server to protect your upload directory
|
||||
|
||||
If you using NGINX server for your site along with **X-Accel-Redirect/X-Sendfile** or **Force Downloads** download method, it is necessary that you add this configuration for better security:
|
||||
|
||||
```php
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,120 +4,148 @@ post_title: Template structure & Overriding templates via a theme
|
|||
|
||||
---
|
||||
|
||||
**Note:** this document is geared toward template development for classic themes. Check this other document for [block theme development](../../plugins/woocommerce-blocks/docs/designers/theming/README.md).
|
||||
We are unable to provide support for customizations under our [Support Policy](http://woocommerce.com/support-policy/). If you
|
||||
need to further customize a snippet, or extend its functionality, we highly
|
||||
recommend [Codeable](https://codeable.io/?ref=z4Hnp), or a [Certified WooExpert](https://woocommerce.com/experts/).
|
||||
**NOTE** This document makes reference to classic themes which use PHP templates. If you are working on a block theme with HTML templates, [please check the Theming docs for block themes](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-blocks/docs/designers/theming/README.md).
|
||||
Overview
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
---
|
||||
WooCommerce template files contain the markup and template structure for the frontend and HTML emails of your store.
|
||||
|
||||
Below is video walkthrough showing how one may go about updating the template files.
|
||||
|
||||
WooCommerce template files contain the **markup** and **template structure** for **frontend and HTML emails** of your
|
||||
store.
|
||||
|
||||
[![Documentation for Template structure & Overriding templates via a theme](https://embed-ssl.wistia.com/deliveries/a2f57c5896505b39952aa8411a474066.jpg?image_play_button_size=2x&image_crop_resized=960x540&image_play_button=1&image_play_button_color=694397e0)](https://woocommerce.com/document/template-structure/?wvideo=8mvl4bro0g)
|
||||
|
||||
When you open these files, you will notice they all contain **hooks** that allow you to add/move content without needing
|
||||
to edit template files themselves. This method protects against upgrade issues, as the template files can be left
|
||||
completely untouched.
|
||||
|
||||
## Template List
|
||||
## Template list
|
||||
|
||||
---
|
||||
The various template files on your WooCommerce site can be found via an FTP client or your hosts file manager, in `/wp-content/plugins/woocommerce/templates/`. Below are links to the current and earlier versions of the WooCommerce template files on Github, where you can view the code exactly as it appears in those files:
|
||||
|
||||
Template files can be found within the **/woocommerce/templates/** directory:
|
||||
| Latest Version | Files |
|
||||
| -------------- | ----- |
|
||||
| 8.9 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.9.0/plugins/woocommerce/templates) |
|
||||
|
||||
| Latest version | Files |
|
||||
|:---------------|:-----------------------------------------------------------------------------------------------------------|
|
||||
| v8.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.4.0/plugins/woocommerce/templates) |
|
||||
|
||||
---
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
<details>
|
||||
<summary>Expand to view files of all major previous versions</summary>
|
||||
Below are the links to the files of all major previous WooCommerce versions:
|
||||
|
||||
| Version | Files |
|
||||
|---------|------------------------------------------------------------------------------------------------------------|
|
||||
| v8.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.3.0/plugins/woocommerce/templates) |
|
||||
| v8.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.2.0/plugins/woocommerce/templates) |
|
||||
| v.8.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.1.0/plugins/woocommerce/templates) |
|
||||
| v8.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.0.0/plugins/woocommerce/templates) |
|
||||
| v7.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.9.0/plugins/woocommerce/templates) |
|
||||
| v7.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.8.0/plugins/woocommerce/templates) |
|
||||
| v7.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.7.0/plugins/woocommerce/templates) |
|
||||
| v7.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.6.0/plugins/woocommerce/templates) |
|
||||
| v7.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.5.0/plugins/woocommerce/templates) |
|
||||
| v7.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.4.0/plugins/woocommerce/templates) |
|
||||
| v7.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.3.0/plugins/woocommerce/templates) |
|
||||
| v7.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.2.0/plugins/woocommerce/templates) |
|
||||
| v7.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.1.0/plugins/woocommerce/templates) |
|
||||
| v7.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.0.0/plugins/woocommerce/templates) |
|
||||
| v6.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.9.0/plugins/woocommerce/templates) |
|
||||
| v6.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.8.0/plugins/woocommerce/templates) |
|
||||
| v6.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.7.0/plugins/woocommerce/templates) |
|
||||
| v6.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.6.0/plugins/woocommerce/templates) |
|
||||
| v6.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.5.0/plugins/woocommerce/templates) |
|
||||
| v6.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.4.0/plugins/woocommerce/templates) |
|
||||
| v6.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.3.0/plugins/woocommerce/templates) |
|
||||
| v6.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.2.0/plugins/woocommerce/templates) |
|
||||
| v6.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.1.0/plugins/woocommerce/templates) |
|
||||
| v6.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.0.0/plugins/woocommerce/templates) |
|
||||
| v5.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.9.0/templates) |
|
||||
| v5.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.8.0/templates) |
|
||||
| v5.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.7.0/templates) |
|
||||
| v5.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.6.0/templates) |
|
||||
| v5.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.5.0/templates) |
|
||||
| v5.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.4.0/templates) |
|
||||
| v5.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.3.0/templates) |
|
||||
| v5.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.2.0/templates) |
|
||||
| v5.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.1.0/templates) |
|
||||
| v5.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.0.0/templates) |
|
||||
| v4.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.9.0/templates) |
|
||||
| v4.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.8.0/templates) |
|
||||
| v4.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.7.0/templates) |
|
||||
| v4.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.6.0/templates) |
|
||||
| v4.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.5.0/templates) |
|
||||
| v4.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.4.0/templates) |
|
||||
| v4.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.3.0/templates) |
|
||||
| v4.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.2.0/templates) |
|
||||
| v4.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.1.0/templates) |
|
||||
| v4.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.0.0/templates) |
|
||||
| v3.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.9.0/templates) |
|
||||
| v3.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.8.0/templates) |
|
||||
| v3.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.9.0/templates) |
|
||||
| v3.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.6.0/templates) |
|
||||
| v3.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.5.0/templates) |
|
||||
| v3.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.4.0/templates) |
|
||||
| v3.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.3.0/templates) |
|
||||
| v3.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.2.0/templates) |
|
||||
| v3.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.1.0/templates) |
|
||||
| v3.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.0.0/templates) |
|
||||
| v2.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/2.6.0/templates) |
|
||||
</details>
|
||||
<!-- markdownlint-enable MD033 -->
|
||||
| -------------- | ----- |
|
||||
| 8.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.8.0/plugins/woocommerce/templates) |
|
||||
| 8.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.7.0/plugins/woocommerce/templates) |
|
||||
| 8.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.6.0/plugins/woocommerce/templates) |
|
||||
| 8.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.5.0/plugins/woocommerce/templates) |
|
||||
| 8.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.4.0/plugins/woocommerce/templates) |
|
||||
| 8.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.3.0/plugins/woocommerce/templates) |
|
||||
| 8.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.2.0/plugins/woocommerce/templates) |
|
||||
| 8.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.1.0/plugins/woocommerce/templates) |
|
||||
| 8.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/8.0.0/plugins/woocommerce/templates) |
|
||||
| 7.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.9.0/plugins/woocommerce/templates) |
|
||||
| 7.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.8.0/plugins/woocommerce/templates) |
|
||||
| 7.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.7.0/plugins/woocommerce/templates) |
|
||||
| 7.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.6.0/plugins/woocommerce/templates) |
|
||||
| 7.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.5.0/plugins/woocommerce/templates) |
|
||||
| 7.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.4.0/plugins/woocommerce/templates) |
|
||||
| 7.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.3.0/plugins/woocommerce/templates) |
|
||||
| 7.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.2.0/plugins/woocommerce/templates) |
|
||||
| 7.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.1.0/plugins/woocommerce/templates) |
|
||||
| 7.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/7.0.0/plugins/woocommerce/templates) |
|
||||
| 6.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.9.0/plugins/woocommerce/templates) |
|
||||
| 6.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.8.0/plugins/woocommerce/templates) |
|
||||
| 6.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.7.0/plugins/woocommerce/templates) |
|
||||
| 6.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.6.0/plugins/woocommerce/templates) |
|
||||
| 6.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.5.0/plugins/woocommerce/templates) |
|
||||
| 6.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.4.0/plugins/woocommerce/templates) |
|
||||
| 6.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.3.0/plugins/woocommerce/templates) |
|
||||
| 6.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.2.0/plugins/woocommerce/templates) |
|
||||
| 6.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.1.0/plugins/woocommerce/templates) |
|
||||
| 6.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/6.0.0/plugins/woocommerce/templates) |
|
||||
| 5.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.9.0/templates) |
|
||||
| 5.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.8.0/templates) |
|
||||
| 5.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.7.0/templates) |
|
||||
| 5.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.6.0/templates) |
|
||||
| 5.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.5.0/templates) |
|
||||
| 5.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.4.0/templates) |
|
||||
| 5.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.3.0/templates) |
|
||||
| 5.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.2.0/templates) |
|
||||
| 5.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.1.0/templates) |
|
||||
| 5.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/5.0.0/templates) |
|
||||
| 4.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.9.0/templates) |
|
||||
| 4.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.8.0/templates) |
|
||||
| 4.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.7.0/templates) |
|
||||
| 4.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.6.0/templates) |
|
||||
| 4.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.5.0/templates) |
|
||||
| 4.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.4.0/templates) |
|
||||
| 4.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.3.0/templates) |
|
||||
| 4.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.2.0/templates) |
|
||||
| 4.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.1.0/templates) |
|
||||
| 4.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/4.0.0/templates) |
|
||||
| 3.9.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.9.0/templates) |
|
||||
| 3.8.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.8.0/templates) |
|
||||
| 3.7.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.7.0/templates) |
|
||||
| 3.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.6.0/templates) |
|
||||
| 3.5.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.5.0/templates) |
|
||||
| 3.4.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.4.0/templates) |
|
||||
| 3.3.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.3.0/templates) |
|
||||
| 3.2.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.2.0/templates) |
|
||||
| 3.1.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.1.0/templates) |
|
||||
| 3.0.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/3.0.0/templates) |
|
||||
| 2.6.0 | [View template files](https://github.com/woocommerce/woocommerce/tree/2.6.0/templates) |
|
||||
|
||||
|
||||
## Changing Templates via Hooks
|
||||
|
||||
When you open a template file, you will notice they all contain _hooks_ that allow you to add/move content without needing to edit template files themselves. Hooks are a way for one piece of code to interact/modify another piece of code at specific, pre-defined spots. This method allows implementing a code snippet that “hooks” into a particular a theme location. It avoids upgrade issues, as the template files can be left completely untouched and doesn't require a child theme to be configured.
|
||||
|
||||
Let's take a look at [/wp-content/plugins/woocommerce/templates/emails/admin-new-order.php](https://github.com/woocommerce/woocommerce/blob/8.9.0/plugins/woocommerce/templates/emails/admin-new-order.php) and see what a hook looks like. Starting on line 30, we see the following code, which is responsible for producing the order details section of the New Order email.
|
||||
|
||||
```php
|
||||
/*
|
||||
* @hooked WC_Emails::order_details() Shows the order details table.
|
||||
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
|
||||
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
|
||||
* @since 2.5.0
|
||||
*/
|
||||
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
|
||||
```
|
||||
|
||||
The code above outputs the block highlighted in red in the image below, which is the New Order email a shop manager receives following a successful order on their site:
|
||||
|
||||
![image](https://woocommerce.com/wp-content/uploads/2020/05/templating-using-hooks.webp)
|
||||
|
||||
A code below can be used as a starting point to build out desired functionality. It can then be added to a code snippets plugin to modify the output at that particular location in the template, without having to edit the template itself. The same goes for other hooks, wherever in the templates they may appear.
|
||||
|
||||
```php
|
||||
add_action( 'woocommerce_email_order_details', 'my_custom_woo_function');
|
||||
function my_custom_woo_function() {
|
||||
/* Your code goes here */
|
||||
}
|
||||
```
|
||||
|
||||
## Changing Templates by Editing the Files
|
||||
|
||||
Editing files directly in a plugin or a parent theme creates the risk of causing errors that could bring a site to a grinding halt. But more importantly, any changes made in this way will disappear when the plugin or theme updates itself; a process that entirely deletes the old version and replaces it with a fresh, updated copy.
|
||||
|
||||
Instead, the recommended approach is to [set up a child theme](https://developer.woocommerce.com/docs/how-to-set-up-and-use-a-child-theme/), which creates a safe directory where to make overriding changes that will not be automatically updated.
|
||||
|
||||
For this example, let's call our child theme `storefront-child`. With `storefront-child` in place, edits can be made in an upgrade-safe way by using overrides. Copy the template into a directory within your child theme named `/storefront-child/woocommerce/` keeping the same file structure but removing the `/templates/` subdirectory.
|
||||
|
||||
To override the admin order notification in our example, copy `wp-content/plugins/woocommerce/templates/emails/admin-new-order.php` to `wp-content/themes/storefront-child/woocommerce/emails/admin-new-order.php`
|
||||
|
||||
The copied file will now override the WooCommerce default template file, so you can make any changes you wish to the copied file, and see it reflected in the resulting output.
|
||||
|
||||
---
|
||||
|
||||
## How to Edit Files
|
||||
**Note** A (desirable) side-effect of your templates being upgrade-safe is that WooCommerce core templates will update, but your custom overrides will not. You may occassionally see notices in your System Status report that says, e.g. “version 3.5.0 is out of date. The core version is 3.7.0″. Should that happen, follow the Fixing Outdated WooCommerce Templates guide to bring them in line.
|
||||
|
||||
---
|
||||
|
||||
Edit files in an **upgrade-safe** way using **overrides**. Copy the template into a directory within your theme named `/woocommerce` keeping the same file structure but removing the `/templates/` subdirectory.
|
||||
|
||||
Example: To override the admin order notification, copy: `wp-content/plugins/woocommerce/templates/emails/admin-new-order.php` to `wp-content/themes/yourtheme/woocommerce/emails/admin-new-order.php`.
|
||||
|
||||
The copied file will now override the WooCommerce default template file.
|
||||
|
||||
**Warning:** Do not edit these files within the core plugin itself as they are overwritten during the upgrade process and any customizations will be lost. For more detailed information, see [Fixing Outdated WooCommerce Templates](https://woocommerce.com/document/fix-outdated-templates-woocommerce/).
|
||||
|
||||
## For Custom Templates
|
||||
## Declare Theme Support for Custom Templates
|
||||
|
||||
If you are a theme developer or using a theme with custom templates, you must declare WooCommerce theme support using the `add_theme_support` function. See [Declaring WooCommerce Support in Themes](https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes) at GitHub.
|
||||
|
||||
If your theme has a `woocommerce.php` file, you will be unable to override the `woocommerce/archive-product.php` custom template in your theme, as `woocommerce.php` has priority over other template files. This is intended to prevent display issues.
|
||||
If your theme has `woocommerce.php`, you will be unable to override `woocommerce/archive-product.php` custom template in your theme, as `woocommerce.php` has priority over other template files. This is intended to prevent display issues.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: enhancement
|
||||
|
||||
Fixed minor issues in the developer documentation recently added by public resources team
|
Loading…
Reference in New Issue