Examples
Here is the example of “Google Merchant” compatible XML feed:
XML header
<!--?xml version="1.0" encoding="utf-8"?--> http://www.example.com A description of your content
XML item
[alg_product_url] [alg_product_short_description] [alg_product_image_url] [alg_product_price] new [alg_product_sku]
XML footer
Another similar example with CDATA:
XML header
<!--?xml version="1.0" encoding="utf-8"?-->
XML item
[alg_product_sku] [alg_product_short_description cdata="yes"] [alg_product_categories cdata="yes"] [alg_product_url] [alg_product_image_url] [alg_product_price] new
XML footer
[alg_product_sku];[alg_product_title];[alg_product_url];[alg_product_price];
With “Product XML Feeds for WooCommerce” plugin you can create XML feeds for any specifications. For example, below you can see settings for a Facebook XML feed. Specifications can be found here and feed debug (validation) tool is here.
XML header
<!--?xml version="1.0"?--> http://www.example.com A description of your content
XML item
[alg_product_id] [alg_product_name cdata="yes"] [alg_product_short_description cdata="yes"] [alg_product_url] [alg_product_image_url] Example new in stock [alg_product_price] GBP
XML footer
Shortcodes
Global Shortcode Attributes
In addition to shortcode specific attributes, which are listed in section below, there are common (i.e. global) shortcode attributes, which can be used with any of the shortcodes:
before
– Will be added at the beginning of final result in case if the resulting value is not empty. Default value: None.after
– Will be added at the end of final result in case if the resulting value is not empty. Default value: None.
find
– Should be used with “replace” attribute to make replacements in final result. Default value: None.replace
– Should be used with “find” attribute to make replacements in final result. Default value: None.find_replace_sep
– Should be used with “find” and “replace” attributes in case if you want to find and replace multiple values at once. Default value: None.
on_empty
– Will be outputted instead of empty string, in case if final shortcode’s result is empty. Default value: None.on_empty_apply_shortcodes
– Set toyes
if you want to process shortcodes inon_empty
attribute. If set toyes
, you need to replace[
and]
with{
and}
. Default value:no
. E.g.:[alg_product_meta name="_some_meta_key" on_empty="{alg_product_name}" on_empty_apply_shortcodes="yes"]
strip_tags
– Strips HTML and PHP tags from a shortcode output. Uses PHP strip_tags() function. Default value:yes
.strip_shortcodes
– Deletes all shortcode tags from a shortcode output. When set toyes
uses WordPress strip_shortcodes() function. When set toyes-force
will delete all that “looks” like shortcodes, i.e. is wrapped in square brackets. Differently fromyes
this option will delete inactive shortcodes as well. Also it will leave the content inside shortcodes. Default value:no
.cdata
– Wraps shortcode output in CDATA. Default value:no
.custom_function
– If set will apply any custom function on a shortcode output. For example, you can make an output uppercase by settingcustom_function="strtoupper"
. Default value: None.
product_id
– Can be used in products shortcodes. Default value: current product’s ID.use_parent_id
– Can be used in products shortcodes. If set toyes
will use parent’s ID instead of child’s ID for variations. Default value:no
.
-
convert_currency_from
– Currency to convert from. Can be used in numeric results only. Default value: None.convert_currency_to
– Currency to convert to. Default value: None.convert_currency_precision
– Defines the number of decimals when rounding the final result. Default value:2
.
When converting currency, the exchange rates are automatically retrieved from European Central Bank (ECB). Currency conversion example:
[alg_product_price convert_currency_from="EUR" convert_currency_to="USD" convert_currency_precision="2"]
Shortcodes List
Dimensions
- [alg_product_weight]
- [alg_product_length]
- [alg_product_width]
- [alg_product_height]
- [alg_product_dimensions]
Taxonomies
- [alg_product_tags]
- [alg_product_categories]
- [alg_product_categories_names]
- [alg_product_categories_urls]
- [alg_product_terms]
Taxes
Shipping
Stock
Price & Currency
- [alg_shop_currency]
- [alg_product_price]
- [alg_product_sale_price]
- [alg_product_regular_price]
- [alg_product_price_including_tax]
- [alg_product_price_excluding_tax]
- [alg_product_you_save]
- [alg_product_you_save_percent]
Title & Descriptions
- [alg_product_title]
- [alg_product_excerpt]
- [alg_product_short_description]
- [alg_product_description]
- [alg_product_formatted_name]
- [alg_product_name]
Images
Custom Fields
Attributes
Formatting
Variations
General
- [alg_current_datetime]
- [alg_product_id]
- [alg_product_type]
- [alg_product_url]
- [alg_product_sku]
- [alg_product_total_sales]
- [alg_product_average_rating]
- [alg_product_time_since_last_sale]
- [alg_product_function]
Shortcode Descriptions
[alg_current_datetime]
Displays current date & time.
Attributes
datetime_format
– Date & time format. Default value: your site date & time format.
Example
[alg_current_datetime datetime_format="Y-m-d H:i:s"]
[alg_shop_currency]
Displays shop’s currency code.
Example
[alg_shop_currency]
[alg_product_id]
Displays product’s ID.
Example
[alg_product_id]
[alg_product_type]
Displays product’s type, e.g.: simple, variable, external etc.
Example
[alg_product_type]
[alg_product_image_url]
Displays product’s image URL.
Attributes
image_size
– Registered image size to retrieve. Default value: shop_thumbnail
.
Example
[alg_product_image_url image_size="full"]
[alg_product_gallery_image_url]
Displays product’s gallery image URL. In case if there is no image available, empty string will be outputted.
Attributes
image_nr
– Number of gallery image to retrieve URL for. Default value: 1
.
Example
[alg_product_gallery_image_url image_nr="1"]
[alg_product_gallery_image_url image_nr="2"]
[alg_product_gallery_image_url image_nr="3"]
[alg_product_url]
Displays product’s URL (i.e. permalink).
Example
[alg_product_url]
[alg_product_price]
Displays product’s price.
Attributes
multiply_by
– Multiply price by this value before displaying. Default value: None.
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
variable_price_type
– Display variable product’s price as lowest variation price only (simple
), or as all variations price range (range
). Default value: range
.
Example
[alg_product_price multiply_by="1.25" hide_currency="no"]
[alg_product_sku]
Displays product’s SKU.
Example
[alg_product_sku]
[alg_product_title]
Displays product’s title.
Example
[alg_product_title]
[alg_product_weight]
Displays product’s weight.
Example
[alg_product_weight]
[alg_product_excerpt]
Displays product’s excerpt.
Attributes
length
– If not zero, will limit the excerpt length. Default value: 0
.
Example
[alg_product_excerpt length="10"]
[alg_product_short_description]
Displays product’s short description.
Attributes
length
– If not zero, will limit the short description length. Default value: 0
.
apply_filters
– Sets if woocommerce_short_description should be applied. Default value: no
.
Example
[alg_product_short_description length="10"]
[alg_product_description]
Displays product’s (full) description.
Example
[alg_product_description]
[alg_product_custom_field]
Displays product’s custom field.
Attributes
name
– Custom field’s name. Default value: None.
Example
[alg_product_custom_field name="total_sales"]
[alg_product_meta]
Displays product’s meta.
Attributes
name
– Meta name (i.e. key). Default value: None.
Example
[alg_product_meta name="total_sales"]
[alg_product_you_save]
Displays product’s savings amount (i.e. regular price minus sale price amount).
Attributes
hide_if_zero
– If set to yes
will output empty string instead of numerical zero for products that are not on sale. Default value: no
.
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
Example
[alg_product_you_save]
[alg_product_you_save_percent]
Displays product’s savings amount in percent (i.e. regular price minus sale price amount in percent).
Attributes
hide_if_zero
– If set to yes
will output empty string instead of numerical zero for products that are not on sale. Default value: no
.
reverse
– If set to yes
will reverse final result (i.e. 100 – percent). Default value: no
.
Example
[alg_product_you_save_percent]
[alg_product_tags]
Displays product’s tags.
Attributes
add_links
– Will add links to the tags page. Default value: yes
.
sep
– Separator. Default value: ,
.
Example
[alg_product_tags add_links="no"]
[alg_product_total_sales]
Displays product’s total sales number.
Attributes
hide_if_zero
– If set to yes
will output empty string instead of numerical zero. Default value: no
.
offset
– Will be added to final result. Default value: 0
.
Example
[alg_product_total_sales]
[alg_product_shipping_class]
Displays product’s shipping class. “Standard” class is outputted as an empty string – if you want to change that, you can use on_empty
attribute (which is available in all plugin’s shortcodes).
Example
[alg_product_shipping_class on_empty="Standard"]
[alg_product_dimensions]
Displays product’s dimensions.
Example
[alg_product_dimensions]
[alg_product_length]
Displays product’s length.
Attributes
to_unit
– Will convert final result to this units. Default value: None.
round
– Will round the final result. Default value: no
.
precision
– If round is set to yes
, you can define rounding precision (i.e. number of decimals) here. Default value: 2
.
Example
[alg_product_length]
[alg_product_width]
Displays product’s width.
Attributes
to_unit
– Will convert final result to this units. Default value: None.
round
– Will round the final result. Default value: no
.
precision
– If round is set to yes
, you can define rounding precision (i.e. number of decimals) here. Default value: 2
.
Example
[alg_product_width]
[alg_product_height]
Displays product’s height.
Attributes
to_unit
– Will convert final result to this units. Default value: None.
round
– Will round the final result. Default value: no
.
precision
– If round is set to yes
, you can define rounding precision (i.e. number of decimals) here. Default value: 2
.
Example
[alg_product_height]
[alg_product_formatted_name]
Displays product’s formatted name.
Example
[alg_product_formatted_name]
[alg_product_name]
Displays product’s name.
Example
[alg_product_name]
[alg_product_stock_availability]
Displays product’s stock availability.
Example
[alg_product_stock_availability]
[alg_product_tax_class]
Displays product’s tax class.
Example
[alg_product_tax_class]
[alg_product_average_rating]
Displays product’s average rating.
Example
[alg_product_average_rating]
[alg_product_categories]
Displays product’s categories.
Example
[alg_product_categories]
[alg_product_categories_names]
Displays product’s category names.
Attributes
sep
– Separator. Default value: ,
.
Example
[alg_product_categories_names]
[alg_product_categories_urls]
Displays product’s category URLs.
Attributes
sep
– Separator. Default value: ,
.
Example
[alg_product_categories_urls]
[alg_product_list_attributes]
Displays product’s attributes.
Example
[alg_product_list_attributes]
[alg_product_list_attribute]
Displays product’s (single) attribute.
Attributes
name
– Required name of the attribute to display. Default value: None.
Examples
[alg_product_list_attribute name="size"]
[alg_product_list_attribute name="pa_color"]
[alg_product_stock_quantity]
Displays product’s stock quantity.
Example
[alg_product_stock_quantity]
[alg_product_sale_price]
Displays product’s sale price.
Attributes
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
Example
[alg_product_sale_price]
[alg_product_regular_price]
Displays product’s regular price.
Attributes
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
show_always
– If set to no
will display regular price only for products that are on sale. Default value: yes
.
Example
[alg_product_regular_price]
[alg_product_time_since_last_sale]
Displays product’s time since last sale.
Attributes
order_status
– Sets which order statuses to count as sale. Default value: wc-completed
.
days_to_cover
– Sets maximum number of days to check. Default value: 90
.
hide_if_no_sales
– If set to yes
will display empty string, if there were no sales found. Otherwise will output “No sales yet.” string. Default value: no
.
Example
[alg_product_time_since_last_sale]
[alg_product_price_including_tax]
Displays product’s price including tax.
Attributes
multiply_by
– Optional multiplication coefficient. Default value: None.
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
variable_price_type
– Display variable product’s price as lowest variation price only (simple
), or as all variations price range (range
). Default value: range
.
Example
[alg_product_price_including_tax]
[alg_product_price_excluding_tax]
Displays product’s price excluding tax.
Attributes
multiply_by
– Optional multiplication coefficient. Default value: None.
hide_currency
– Display price as number only, or format it with currency code. Default value: yes
.
variable_price_type
– Display variable product’s price as lowest variation price only (simple
), or as all variations price range (range
). Default value: range
.
Example
[alg_product_price_excluding_tax]
[alg_product_available_variations]
Displays product’s available variations.
Attributes
sep
– Separator for variation attributes. Default value: ,
.
sep2
– Separator for variation attributes and price. Default value: :
.
sep3
– Separator for variations. Default value: |
.
Example
[alg_product_available_variations]
Example Output
red, Any: €20.00 | green, Any: €20.00 | blue, Any: €15.00
[alg_product_terms]
Displays product’s taxonomy terms.
Attributes
taxonomy
– Required name of the taxonomy to display. Default value: None.
sep
– Separator. Default value: ,
.
parent
– Optional parent ID. For example, to output top level terms only, set it to 0
. Default value: None.
orderby
– Sorts terms. Possible values: name
, parent_id
, term_id
, hierarchy
. Default value: name
.
Examples
[alg_product_terms taxonomy="brand"]
[alg_product_terms taxonomy="pwb-brand"]
[alg_product_function]
Displays any product function’s result. For a list of available functions please check WC_Product
class documentation.
Attributes
function
– Required name of the function to call. Default value: None.
Examples
[alg_product_function function="get_description"]
[alg_product_function function="is_visible"]
[alg_product_function function="is_purchasable"]
[alg_product_function function="get_catalog_visibility"]
[alg_format_date]
Formats value as a date.
Attributes
format
– Date format. Default value: your site’s date & time format.
is_timestamp
– Is input value a timestamp (yes
), or date/time string no
. Default value: no
.
do_localize
– Do we need to localize outputted date. When set to yes
, then date_i18n()
function is used instead of date()
function (no
). Default value: no
.
Example
[alg_format_date format="m-d-Y"][alg_product_meta name="your_custom_field_name"][/alg_format_date]
[alg_format_number]
Formats value as a number.
Attributes
decimals
– Sets the number of decimal points. Default value: 0
.
dec_point
– Sets the separator for the decimal point. Default value: .
.
thousands_sep
– Sets the thousands separator. Default value: ,
.
Example
[alg_format_number decimals="2"][alg_product_meta name="your_custom_field_name"][/alg_format_number]
[alg_to_timestamp]
Converts date/time string to timestamp.
Example
[alg_to_timestamp][alg_product_meta name="your_custom_field_name"][/alg_to_timestamp]
Options
Plugin options are located in “WooCommerce > Settings > Product XML Feeds”.
General Options
- Total XML files (feeds)
- Sets the number of different feeds you wish to create.
- Default:
1
- Default:
- Block size for products query
- Sets the number of products feed file creation script should process in single loop.
- Default:
512
- Default:
- PHP memory limit
- Sets PHP memory limit (in megabytes). Ignored if set to zero. In addition to this you may need to increase WP memory limit by setting
WP_MEMORY_LIMIT
andWP_MAX_MEMORY_LIMIT
in yourwp-config.php
file.- Default:
0
- Default:
- PHP time limit
- Sets the number of seconds feed file creation script is allowed to run. Set to zero for no time limit. Ignored if set to -1 (and server’s default time limit is used). Check
set_time_limit()
function documentation for more info. There is a number of other solutions for increasing PHP time limit.- Default:
-1
- Default:
- 'Raw' input
- Affects “Template Options”. If disabled, use
{
and}
instead of<
and>
accordingly.- Default:
yes
- Default:
XML Feed #X Options
- Enabled
- Enables/disables the current feed.
- Default:
yes
- Default:
- Admin title
- Sets admin title for the current feed.
- Default:
XML Feed #X
- Default:
Template Options
- Default:
<!--?xml version = "1.0" encoding = "utf-8" ?--> [alg_current_datetime]
- Default:
[alg_product_name cdata="yes"] [alg_product_short_description cdata="yes"] [alg_product_url] [alg_product_price] [alg_shop_currency] [alg_product_image_url] [alg_product_gallery_image_url image_nr="1" before="" after=""] [alg_product_sku] [alg_product_stock_quantity] [alg_product_categories] [alg_product_tags] [alg_product_meta name="total_sales"]
- Default:
General Options
- Default:
products.xml or products_X.xml
- Default:
Update weekly
- Default: None
- Default:
Date
- Default:
Descending
Products Filtering Options
- Default: None
- Default: None
- Default: None
- Default: None
- Default: None
- Default: None
- Default:
Variable product only
- Default:
All products
- Default:
0
- Default:
0
- Default: None
- Default: None
- Default: None
- Default: None
pwb-brand
- Default: None
sony,lg,samsung
- Default: None
color
- Default: None
Red,Green
- Default: None