Skip to content
Advertisement

Passing the previous page title to a custom checkout field in Woocommerce

With Woocommerce, is it possible to pass the previous page title to a custom checkout fields?

Advertisement

Answer

Updated – The following code example uses PHP Session to grab the previous page title (this code example can be extended):

JavaScript

In checkout page you will be able to get the previous page title using:

JavaScript

Then in checkout page we can add this previous page title in a hidden input field:

JavaScript

Then when order is submitted, we save the custom hidden field value as order meta data:

JavaScript

Code goes in function.php file of your active child theme (or active theme). Tested and works.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement