skip to Main Content

WooCommerce: External/Affiliate Product Link ShortCodes

Description

The WooCommerce External/Affiliate Product Link ShortCodes plugin allows you to directly insert links to your external or affiliate products already in WooCommerce right into your other pages and posts without requiring the visitor visit the product page first.

Usage Example

Available properties:

  • product_id: The ID of your product
  • new_window: exclude for same window opening or set to ‘true’ if you want the link to open in a new window
  • link_title: exclude for none or set to whatever you want your visitor to see when they mouseover the link
  • link_rel: exclude for none or set to one of the types from here:
  • params: add in your url variables (does not add ? or prefixed & to an extension of already in place product variables). This appends to the product url entered into the product.

Property: product_id

The product_id property uses the ID of the product you want to link to.

Note: This plugin does not check to be sure the product is an external/affiliate product.

[wc_external_product product_id='1']This is the link text[/wc_external_product]

Property: new_window

The new_window property is set to FALSE by default. If you want your links to open in a new tab/window set this to true

[wc_external_product product_id='1' new_window='true']This is the link text[/wc_external_product]

Property: link_title

The link_title property sets the title attribute of the link. This text will appear when a visitor mouses over the link.

[wc_external_product product_id='1' link_title='This is shown on mouseover']This is the link text[/wc_external_product]

Property: link_rel

The link_rel property refers to the link type. There is a full description and listing of all link types here.

[wc_external_product product_id='1' link_rel='author']This is the link text[/wc_external_product]

Property: params

The params property allows you to append url query variables to the end of the product URL. You’ll need to know what your product url looks like first.

Developer Note: This feature use’s WordPress’s esc_url() feature to make sure the link is valid.

Example 1:

If your product external URL looks like: https://www.google.com

[wc_external_product product_id='1' params='?var_one=val_one&var_two=val_two']This is the link text[/wc_external_product]

Example 2:

If your product external URL looks like:

https://www.google.com/?variable_one=12345

OR

https://www.google.com/?variable_one=12345&variable_two=54321

[wc_external_product product_id='1' params='&var_one=val_one&var_two=val_two']This is the link text[/wc_external_product]

Back To Top