Changeset 3158959
- Timestamp:
- 09/27/2024 08:54:19 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
purchase-orders-for-woocommerce/tags/1.11.1/README.txt
r3158957 r3158959 60 60 To add a text input field after the PO number field, the code should look something like this: 61 61 62 <?php 62 63 function custom_checkout_field_after_po_form() { 63 64 ?> … … 69 70 } 70 71 add_action( 'pofwc_form_after_po_form', 'custom_checkout_field_after_po_form' ); 72 ?> 71 73 72 74 You can of course change the form HTML to output a different field type such as a `select` dropdown or `textarea`. … … 74 76 To save your custom field, hook into the woocommerce_checkout_update_order_meta action as in the example below: 75 77 78 <?php 76 79 function custom_checkout_field_update_order_meta( $order_id ) { 77 80 … … 85 88 } 86 89 add_action( 'woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta', 10, 1 ); 90 ?> 87 91 88 92 There are four places the PO data can be displayed: the order thank you page, the order emails, the customer order history, and the admin Edit Order screen. To display your custom field data, use one of the following action hooks to add your data in the required place: … … 95 99 To output your example text input from above in the checkout thank you page, the Edit Order screen and customer order history, the code should look something like this: 96 100 101 <?php 97 102 function display_custom_order_data_after_po_form( $order ) { 98 103 … … 102 107 add_action( 'pofwc_account_display_after_po_form', 'display_custom_order_data_after_po_form', 10, 1 ); 103 108 add_action( 'pofwc_admin_display_after_po_form', 'display_custom_order_data_after_po_form', 10, 1 ); 109 ?> 104 110 105 111 Displaying the data in the emails is slightly different as data escaping is done later in the output process: 106 112 113 <?php 107 114 function display_email_custom_order_data_after_po_form( $order ) { 108 115 … … 110 117 } 111 118 add_action( 'pofwc_email_display_after_po_form', 'display_email_custom_order_data_after_po_form', 10, 1 ); 119 ?> 112 120 113 121 This code all goes in your functions.php file in your child theme - don't place this code in a parent theme (unless it's one you maintain yourself) as it will be overwritten when the theme is updated.
Note: See TracChangeset
for help on using the changeset viewer.