• Resolved zasfrtrt

    (@zasfrtrt)


    Hello. I have been using the codes below in the template-functions and it has been working great for me. But now I have too many custom fields on the right side so is there any way to shift some of the custom fields to the left side?

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_certificate', 10, 2 );
    function wpo_wcpdf_certificate ($template_type, $order) {
        if ($template_type == 'invoice') {
            $document = wcpdf_get_document( $template_type, $order );
            ?>      
            <tr class="certificate">
                <th>Certificate:</th>
                <td><?php $document->custom_field('certificate'); ?></td>
            </tr>
            <?php
        }
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @zasfrtrt,

    Sure! You only need to wrap the group of fields you want to display below the billing address (left side) within the wpo_wcpdf_after_billing_address template action hook, the same way you did it in your code above:

    /**
     * Hide the invoice title
     */
    add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_custom_fields_after_billing_address', 10, 2 );
    function wpo_wcpdf_custom_fields_after_billing_address($template_type, $order) {
        if ($template_type == 'invoice') {
            $document = wcpdf_get_document( $template_type, $order );
            ?>      
            <tr class="custom-field">
                <th>Custom field:</th>
                <td><?php $document->custom_field('custom-field'); ?></td>
            </tr>
            <?php
        }
    }

    Let me know if you manage to display your custom fields there ??

    Thread Starter zasfrtrt

    (@zasfrtrt)

    Hi, unfortunately, it does not display anything. It seems the hook does not work when I placed the code in the template function.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Please note you need to replace 'custom-field' for your actual custom field(s) meta key ??

    Thread Starter zasfrtrt

    (@zasfrtrt)

    Hello, it is working great for me, all that is left is that the information on the right seems to be lowering down to a new line. Is there any way to fix this?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @zasfrtrt,

    Try with this layout instead:

    /**
     * Add custom field to the invoice
     */
    add_action( 'wpo_wcpdf_after_billing_address', 'wpo_wcpdf_custom_fields_after_billing_address', 10, 2 );
    function wpo_wcpdf_custom_fields_after_billing_address($template_type, $order) {
        if ($template_type == 'invoice') {
            $document = wcpdf_get_document( $template_type, $order );
            ?>      
            <div class="custom-field">
                <h3>Custom field:</h3>
                <span><?php $document->custom_field('custom-field'); ?></span>
            </div>
            <?php
        }
    }

    Let me know if now it’s look as you wanted ??

    Thread Starter zasfrtrt

    (@zasfrtrt)

    Yup, it’s working thank you.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to know that worked!

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Adding custom fields to the left side’ is closed to new replies.