Custom Template 2 (XML)

Custom Template 2 is one of the premium functionality of our plugin. Using Custom Template 2, it's possible to make any type of  XML Product Feed for WooCommerce. 

All patterns must be enclosed in curly brackets. In patterns, you can use codes of attributes, formatters, links to parent products, base PHP functions and calculations.

The base pattern shema  {attribute_code, [ formatter 1 ], [ formatter 2 ], ... }

Default Attribute Patterns:

  • Product ID {id} - ID of the product
  • Parent Id {item_group_id} - Id of the parent product of variations
  • SKU {sku} - an identifier of the product
  • Parent SKU {parent_sku} - an identifier of the product
  • Product Name {title} - a name of the product
  • Description {description} - a description of the product
  • Short Description {short_description} - a short description of the product
  • Product Local Category {product_type} - Category hierarchy of the product
  • Product URL {link} - URL of the product
  • Product Condition {condition} - Condition of the product. Default value "New"
  • Availability {availability} - Availability status of the product. Possible values :
    • In Stock
    • Out Of Stock
  • Quantity {quantity} - Quantity of the product
  • Regular Price {price} -Regular price of product (without discounts)
  • Sale Price {sale_price} - Sale price of the product
  • Price With Tax {price_with_tax} - Price including tax 
  • Sale Start Date {sale_price_sdate} - Start date of sale price
  • Sale End Date {sale_price_edate} - End date of sale price
  • Weight {weight} -  Weight of the product
  • width {width} - Width of the product
  • height {height} - Height Of the Products
  • length {length} - Length of the product
  • Product Type {type} - Type of the Product. Possible Values:
    • simple
    • variable
    • grouped
    • external
    • virtual
    • downloadable
  • Variation Type {variation_type} - Variation status of the product. Possible values:
    • parent
    • child
    • simple
  • Total Rating {rating_total} - Total rating of the product
  • Average Rating {rating_average} - Average Rating of the product
  • Tags {tags} - Tags of the product. 
  • Image {image} - a direct URL to base image of the product
  • Featured Image {feature_image} - a direct URL to thumbnail image of the product
  • Image 1 {image_1}, Image 2 {image_2}, Image 3 {image_3}, Image 4 {image_4}, Image 5 {image_5}, Image 6 {image_6} , Image 7 {image_7} , Image 8 {image_8} , Image 9 {image_9} , Image 10 {image_10} - a direct url to gallery images of the product
  • Visibility {visibility} - a visibility of the product. Possible Values:
    • public
    • password
    • private
  • Also, it's possible to use others WooCommerce attributes, Dynamic Attributes, and Category Mapping Attributes. You can get the attributes codes by selecting the Product Attributes Dropdown at the bottom of the Custom Template 2  Feed Config section.

Only Parent product values:

You can use suffix  |only_parent ({link|only_parent}{image|only_parent} etc), if you need to return only value of the parent product.
If the plugin can't find the value of the parent product attribute, all its child products will also have no values, even if the child have values of this attribute.

Parent value, if parent value is not empty:

You can use suffix  | parent  ({image|parent}{link|parent} etc), for return parent value, if child product value is empty.

Parent value, if child value is empty:

You can use suffix   |parent_if_empty ({image|parent_if_empty}{link|parent_if_empty} etc), for return parent value, if child product value is empty.

Output Formatters: 

Every formatter should be enclosed with third bracket and should have a space before every parameter. For Example:

		{name, [substr 0 80], [...]}
Formatter Description Schema Example
strip_tags Remove all html tags {attribute_code, [strip_tags]} {description, [strip_tags]}




htmlentities Convert all applicable characters to HTML entities {attribute_code, [htmlentities]} {description, [htmlentities]}
clear Remove all non-utf-8 characters from string {attribute_code, [strip_tags]} {description, [clear]}
substr Truncate the string {attribute_code, [substr from to]} {name, [substr 0 80], [...]}
str_replace
Replace any string {attribute_code, [str_replace => from => to]} {description, [ str_replace => ABC => XYZ], [...]}
ucwords
Uppercase the first character of each word in the string {attribute_code, [ucwords]} {name, [ucwords]}
ucfirst
Make the string's first character uppercase {attribute_code, [ucfirst]} {name, [ucfirst]}
strtoupper Transform the string to upper case {attribute_code, [strtoupper]} {name, [strtoupper]}
strtolower Transform the string to lower case {attribute_code, [strtolower]} {name, [strtolower]}
convert Change price currency {attribute_code, [convert from to ]} {price, [convert USD AUD]} or {special_price, [convert AUD CHF]}
number_format Format a number with grouped thousands {attribute_code, [number_format decimals]} {price, [number_format 2]} or Price comma format: {price, [number_format 2 , ]}
urlToUnsecure Convert all Urls to http format {attribute_code, [urlToUnsecure]} {image, [urlToUnsecure]}
urlToSecure Convert all Urls to https format {attribute_code, [urlToSecure]} {image, [urlToSecure]}




strip_shortcodes
Delete short codes from the string {attribute_code, [strip_shortcodes]} {description, [strip_shortcodes]}

Additional Patterns:

For PHP calculation and Ternary Operator  you have to set attributes as php variable. For Example:  You want to multiply the price attribute value with 20. Then you have to set the price attibute as $price instead of {price}. {(return $price*20; )}. Don't forget to add semicolon ; after the calculation.

Calculations:

  • {(return $price * 1.15;)}
  • {(return $qty + 1;)}
  • {(return $group_price2 / 10 * 4 - 2.5;)}
  • {(return str_replace("0", "*", $sku);)}
  • {(return substr($sku, 3);)}
  • {(return str_replace("a", "b", substr($sku, 0, 5));)}
  • {(return date('d.m.Y H:i:s');)}
  • {(return date('d.m.Y H:i:s', strtotime('+25 days'));)}
  • {(return date("d/m/Y", strtotime($special_from_date));)}

PHP Ternary Operator:

  • {(return ($price > 1000) ? 'free shipping' : '15';)}
  • {(return ($manage_stock == 1) ? $qty : 999;)}
  • {(return (strlen($manufacturer) > 1) ? $manufacturer : 'NoBrand';)}
  • {(return ($color!=='orange') ? $color : '';)}

Still need help? Contact Us Contact Us