Plugin Directory

Changeset 3158959


Ignore:
Timestamp:
09/27/2024 08:54:19 PM (19 months ago)
Author:
mcgregormedia
Message:

Format readme text

File:
1 edited

Legend:

Unmodified
Added
Removed
  • purchase-orders-for-woocommerce/tags/1.11.1/README.txt

    r3158957 r3158959  
    6060To add a text input field after the PO number field, the code should look something like this:
    6161
     62<?php
    6263function custom_checkout_field_after_po_form() {
    6364    ?>
     
    6970}
    7071add_action( 'pofwc_form_after_po_form', 'custom_checkout_field_after_po_form' );
     72?>
    7173
    7274You can of course change the form HTML to output a different field type such as a `select` dropdown or `textarea`.
     
    7476To save your custom field, hook into the woocommerce_checkout_update_order_meta action as in the example below:
    7577
     78<?php
    7679function custom_checkout_field_update_order_meta( $order_id ) {
    7780
     
    8588}
    8689add_action( 'woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta', 10, 1 );
     90?>
    8791
    8892There 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:
     
    9599To 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:
    96100
     101<?php
    97102function display_custom_order_data_after_po_form( $order ) {
    98103
     
    102107add_action( 'pofwc_account_display_after_po_form', 'display_custom_order_data_after_po_form', 10, 1 );
    103108add_action( 'pofwc_admin_display_after_po_form', 'display_custom_order_data_after_po_form', 10, 1 );
     109?>
    104110
    105111Displaying the data in the emails is slightly different as data escaping is done later in the output process:
    106112
     113<?php
    107114function display_email_custom_order_data_after_po_form( $order ) {
    108115
     
    110117}
    111118add_action( 'pofwc_email_display_after_po_form', 'display_email_custom_order_data_after_po_form', 10, 1 );
     119?>
    112120
    113121This 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.