• Resolved crateescapememphis

    (@crateescapememphis)


    I followed this thread to try to output custom checkout fields Cost Center and Purchase Order, but it’s not working for me.

    I used the Woocommerce Checkout Manager plugin to create 3 new fields on the checkout page, and I want to output those 3 new field labels and their contents on the invoices and packing slips creted by the WooCommerce PDF Invoices & Packing Slips plugin. The following link shows what the 3 fields look like after being created using the Woocommerce Checkout Manager plugin.

    LINK

    I copied all the template files to my child theme. Then I entered the following code into the NEW copy of the “Simple” template, after the order details and before the footer.

    <?php
    $myfield1 = get_post_meta($wpo_wcpdf->export->order->id,'Purchase Order:',true);
    if (isset($myfield1)) {
    	echo 'Purchase Order:',$myfield1;
    }
    ?>
    
    <?php
    $myfield2 = get_post_meta($wpo_wcpdf->export->order->id,'Cost Center:',true);
    if (isset($myfield2)) {
    	echo 'Cost Center: ',$myfield2;
    }
    ?>
    
    <?php
    $myfield3 = get_post_meta($wpo_wcpdf->export->order->id,'Embroidery:',true);
    if (isset($myfield3)) {
    	echo 'Embroidery: ',$myfield3;
    }
    ?>

    The following link shows the result. Basically the labels for the 3 new fields are being output all in row instead of one on each line. And the values of the 3 new fields aren’t being output at all.

    LINK RESULT

    How do I make the field labels output on separate lines, and how do I make the field values output beside their respective labels? I’m thinking I need to make a table with 2 columns and 3 rows, but I’m not sure how to fit the above code into a table like that. Suggestions? Thanks for your time.

    https://www.ads-software.com/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! That’s quite an old thread you found there! :o)
    The up-to-date documentation is here: Displaying a custom field

    Make sure you have the right meta keys/field names, you can check this with the woocommerce store toolkit (as described in Finding WooCommerce Custom Fields). It looks like you used the label for the field rather than the field name!

    Here’s what the FAQ for the WooCommerce Checkout Manager says:

    How do you access saved data to be used with WooCommerce PDF Invoices & Packing Slips?
    The above plugin requests that you code the fields in the template. To access the saved data, use the abbreviation name of the field. As we are using the first abbreviation field as an example. Where “myfield1” is the abbreviation name, and “My custom field:” is the label.

    Example:

    <?php $wpo_wcpdf->custom_field('myfield1', 'My custom field:'); ?>

    You can use <br> for line breaks. Here’s an example. You will need to replace the meta keys (myfield1, etc.) with your own, although this may just work if the above FAQ item is still up to date:

    <?php $wpo_wcpdf->custom_field('myfield1', 'Purchase Order:'); ?><br>
    <?php $wpo_wcpdf->custom_field('myfield2', 'Cost Center:'); ?><br>
    <?php $wpo_wcpdf->custom_field('myfield3', 'Embroidery:'); ?>

    Ewout

    Thread Starter crateescapememphis

    (@crateescapememphis)

    Thnk you so much!!!!

    Plugin Contributor Ewout

    (@pomegranate)

    You’re welcome ??

    Have a fantastic weekend!
    Ewout

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Fields Not Outputting to Invoice & Packing Slip’ is closed to new replies.