Docs

Documentation for Flexible Coupons plugin

Flexible PDF Coupons PRO – Custom Shortcodes

Requirements#

You must enable the coupons in WooCommerce settings:

The Flexible PDF Coupons PRO - Custom Shortcodes plugin is an add-on to Flexible PDF Coupons PRO. It allows you to add new shortcodes to PDF templates to import values from WooCommerce order and product fields.

Settings#

Go to the PDF Coupons → Shortcodes tab.

First column - resource name#

Select the resource from which you want to retrieve values for the coupon template.
You can choose from the following resources:

  • Order
  • Order meta
  • Product
  • Product meta
  • Product attributes
  • Site settings
  • Callable function.

If you want to use a callable function, add your custom code to the theme's functions.php file with the function you will then use in the Shortcodes. For example, to get a short description of the product or the variation description (for variable products), add this code:

​function coupon_get_product_short_description( $shortcode_data ) {

if ($shortcode_data->get_product()->get_parent_id()) {
$product = $shortcode_data->get_product()->get_description();
return $product;
}
else {
$product = $shortcode_data->get_product();
return $product->get_short_description();
}
}

Then, in the Shortcodes, use the callable function and copy the function name e.g., coupon_get_product_short_description. Finally, choose the name for the shortcode you will be able to use afterward in the PDF coupon templates.

Second column - meta field name#

After selecting Orders, Product, Product Attributes, or Settings, a list of fields from which you can download will appear in the middle column values straight to a PDF coupon template supported with Flexible PDF Coupons PRO.

In the case of Meta Order Data, Product Meta Data resources, you need to manually enter the meta field name from which the values are to be retrieved.

In the screenshot below, you will find an example for the Purchase Notes field in the product edition, and therefore belonging to the Product Meta set. Open the browser console and use the cursor to select the field whose meta name you are looking for. Copy the name from the console and paste it into the middle column in the Custom Shortcodes settings.

Third column - the shortcode#

The shortcode name will be automatically completed based on the field ID used in the second column. You can change it to any name you like.

PDF Coupon Template #

After saving the Custom Templates settings, the shorts will appear in the shorts list in the PDF template settings:

Use them in the same way as the regular Flexible Coupons PRO shortcodes.

Integrations#

The Flexible PDF Coupons - Custom Shortcodes plugin can create shorts for fields created with other plugins.

Flexible Product Fields#

Flexible PDF Coupons - Custom Shortcodes plugin can import values of fields created by Flexible Product Fields. A shortcode placed on a PDF Coupon template will only import the value of a Flexible Product Fields field if it has been added to a product tagged as PDF Coupon.

When creating a shortcode via Product Meta, enter the name from the Field label field in the meta key field.

Flexible Checkout Fields#

With Flexible PDF Coupons - Custom Shortcodes plugin, you can define shortcodes for fields created in Flexible Checkout Fields. The values of those Flexible Checkout Fields that were filled in during order placing will go into the PDF template of the coupon.

Not the solution you are looking for?

Please check other articles or open a support ticket.

Cookies preferences

Others

Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

Necessary

Necessary
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.

Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.

Functional

Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.

Performance

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.