Modifying the global product template

The plugin already comes with sensible defaults for the product template. It will simply use the WooCommerce product title and the product description, and automatically truncates and formats them to fit within the limitations of Google Business Profile. 

However, in certain situations you may want to tweak the template to suit your requirements. This can be done in the Product template section of the plugin settings:

How the placeholder tags work

The plugin exposes the entire WC_Product class for the current product (and their extensions such as WC_Product_Simple, WC_Product_Variable, WC_Product_External), through the "Mustache" template engine. This allows for extreme flexibility in the product template. 

The tags in the template are replaced by their corresponding value in the resulting product on your Google Business Profile listing. For example the {{wc_product.get_description}} tag that you see in the default template automatically gets replaced with the WooCommerce product description.

Otherwise the Title and Description fields are just plain text fields, and any other text you write in there will show up literally in your product descriptions. 

Take the following description template for example:

Check out my newest product: {{wc_product.get_title}}
	
Now on sale for only ${{wc_product.get_price}} when picking up in the store

The resulting product on your Google Business Profile listing will look something like this:

Check out my newest product: Example product title

Now on sale for only $123.45 when picking up in the store

Available placeholder tags

Here are some of the most useful tags that are available:

  • {{wc_product.get_title}}
  • {{wc_product.get_description}}
  • {{wc_product.get_short_description}}
  • {{wc_product.get_price}} - The current price of the product, taking sale price into account
  • {{wc_product.get_regular_price}} - The price of the product when it isn't on sale
  • {{wc_product.get_price_excluding_tax}}
  • {{wc_product.get_min_purchase_quantity}}
  • {{wc_product.get_length}} - The physical length of the product (get_height and get_width are likewise also available)

For more available tags, check the WC_Product documentation and look for the functions prefixed with "get_". They can all be used by using the following format: {{wc_product.get_<name_of_the_function>}}

Advanced usage - Conditions

The template engine allows you to create "conditions" as well. Lets say you want to show whether a product is in stock. We can use the "is_in_stock" function from the WC_Product class. 

Here is the title of the product: {{wc_product.get_title}}

{{#wc_product.is_in_stock}}
	The product is in stock!!
{{/wc_product.is_in_stock}}

The "The product is in stock!!" text will only be shown if the product is in stock.

Advanced usage - Lists

Lets say you want to display the product attributes in your product description. In that case we can use the "get_attributes" function.

Here are the attributes of my product:

{{#wc_product.get_attributes}}
	{{.}}
{{/wc_product.get_attributes}}

As you can see the template has a lot of flexibility, and we've just scratched the surface of what is possible. It may seem a bit daunting and technical even! Don't hesitate to reach out if you need help customizing your template.

Advanced usage - Editing the Call-to-action URL

By default the Call-to-action button on your products will link to the associated product page, using the {{wc_product.get_permalink}} tag. 

Adding the product to your shopping cart immediately

WooCommerce allows you to append certain parameters to the URL to perform actions like adding products to the shopping cart. You can read more about it within the WooCommerce documentation.

The example below will add a quantity of 10 items of the selected product to the shopping cart when the user clicks the product CTA button:

{{wc_product.get_permalink}}?add-to-cart={{wc_product.get_id}}&quantity=10

To immediately redirect the user to the checkout page when they click the CTA, the following example can be used (obviously change http://yoursite.com to your own domain):

https://yoursite.com/checkout/?add-to-cart={{wc_product.get_id}}&quantity=1

To redirect them to the shopping cart:

https://yoursite.com/cart/?add-to-cart={{wc_product.get_id}}&quantity=1

Adding UTM tags for Google Analytics/Facebook Ads

To easily track the performance of your GBP products you can add UTM tags to the CTA url. That way you can track clicks on the CTA buttons:

{{wc_product.get_permalink}}?utm_source=google+business+profile&utm_medium=product&utm_campaign={{wc_product.get_id}}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us