This plugin handles funnel upsells for Klarna Payments.
Certain requirements need to be met in order for the funnels to get processed.
The plugin will not work unless these plugins are active:
- WooCommerce
- Klarna Order Management for WooCommerce
If any of those plugins are not activated, a critical error will appear.
The funnel will get triggered if (and only if) the customer has purchased Nordic Restoring Body Treatment and nothing else.
If the order contains only 1 jar of that specific cream, Funnel 1 will get triggered.
If the order contains 2 or more jars, Funnel 2 will get triggered.
Note: The plugin doesn’t check which payment method was used, it’s possible the funnel would (wrongly) get triggered if some other payment method was selected at checkout.
All the files are located in /wp-content/plugins/vessi/
folder.
The main plugin file serves only the purpose to include all the required functions, located within the /includes/
folder.
The included files hold sets of functions grouped by their purpose, so we have:
- WooCommerce functions: functions that hook into the regular checkout process and depending on the conditions trigger and process the funnels, together with utility functions that can get customer or order details
- Order functions: the main function in this file handles the addition of upsell products to the existing order, both in WooCommerce Order and Klarna Order
- Shortcode functions: responsible for the output of 3 shortcodes: the upsell button and the “No, thank you” buttons that lead either to the next funnel step or the thank you page
- Logging functions: used to discretely log desired data for the debugging purposes
Note: The development is done through GIT version control and the files are stored on BitBucket - after the local changes are committed and pushed, the CI/CD Pipeline automatically deploys the files to the server.
Because of that, any future changes should be done through the same GIT repository as well.
In order to correctly use the plugin, certain rules must be followed.
Currently, the funnel pages are structured in 2 groups: there’s a parent page for each of the funnels:
├── funnel-1
│ ├── upsell-1
│ ├── downsell-1
│ ├── cross-sell-1
│ ├── cross-sell-2
├── funnel-2
│ ├── upsell-1
│ ├── cross-sell-1
│ ├── cross-sell-2
Note: The relative paths of the first pages of both funnels are hardcoded into the plugin’s code, within the
WooCommerce\start_funnel()
function. If those should be changed, the plugin’s code should reflect the change.
There are 3 shortcodes that are supposed to be used throughout the funnels and can be used to build any type of funnel with the unlimited number of steps.
Shortcodes have attributes and the content and the syntax is this:
[shortcode_name] This is the shortcode content [/shortcode_name]
[shortcode_name attribute=“value” attribute2=“value”] This is the shortcode content [/shortcode_name]
This shortcode is used to display the button that adds the items to the existing order and proceeds to the next funnel step.
There are 3 attributes that are required for this shortcode and 1 that is optional:
- product - the ID of the WooCommerce Product
- quantity - the quantity of the products that will get added to the order
- total - the total amount for the added products
- redirect (optional) - the ID of the Page where the user should get redirected after the click. If omitted, the user will get redirected to the end of the funnel, to the Thank You page.
The typical shortcode could look like this:
[vessi_one_click product="852" quantity="2" total="769" redirect="1149"]JA! Jeg vil ikke gå glipp av dette tilbudet. Legg til i bestillingen min.[/vessi_one_click]
The simplest of the shortcodes, produces a plain HTML link element.
It exists only because it was the simplest way to have the styling of all the buttons unified.
It is used for the “No, thank you” buttons that don’t do anything to the order, but they redirect users to the next funnel step.
There is 1 attribute that is required for this shortcode:
- page - the ID of the Page where the user should go next
The typical shortcode could look like this:
[vessi_link page="1148"]Nei takk, og jeg vet at jeg ikke vil få dette tilbudet igjen.[/vessi_link]
This shortcode is almost the same as the previous one (the outputted button looks the same) except it always redirects to the Thank You page.
It is a necessary shortcode because the Thank You page requires the Order Key and Order ID in the URL so the links on the funnel pages had to be dynamic.
The shortcode doesn’t have any attributes, all the required data is calculated from the current Order.
The typical shortcode could look like this:
[vessi_thank_you]Nei takk, og jeg vet at jeg ikke vil få dette tilbudet igjen.[/vessi_thank_you]