• Resolved midshorediesel

    (@midshorediesel)


    I’m familiar with the flag to hide/show the shipping address if different from the billing address, but due to the limited width of the paper I’m printing to, I’d like to display either address block depending if the shipping address is available. If the shipping address is available, it should hide the “.address.billing-address” TD, but it’s it’s not available, then it should hide the “.address.shipping-address” TD thereby allowing the remaining TD to be a bit wider. Is that an easy hack?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @midshorediesel,

    Try the following code snippet I just wrote for you:

    /** 
    * PDF Invoices & Packing Slips for WooCommerce:
    * Conditionally hide the billing or shipping address in the PDF documents
    *
    * If the shipping address differs from the billing address,
    * hide the billing address, otherwise, hide the shipping address.
    */
    add_action( 'wpo_wcpdf_custom_styles', function( $document_type, $document ) {
    // If the shipping address is different from the billing address...
    if ( $document->ships_to_different_address() ) {
    ?>
    /* Hide the billing address */
    td.address.billing-address {
    display:none;
    }
    <?php
    } else {
    ?>
    /* Hide the shipping address */
    td.address.shipping-address {
    display:none;
    }
    <?php
    }
    }, 10, 2 );

    Let me know if it worked 😉

    Thread Starter midshorediesel

    (@midshorediesel)

    Absolutely perfecto, thank you so much Yordan!!

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for confirm that it worked, @midshorediesel!

    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!

    Thread Starter midshorediesel

    (@midshorediesel)

    Absolutely, I promote you everywhere I can! 🙂

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thank you so much, @midshorediesel! 🙏

    I just noticed that you had already left us an amazing 5-star review: Truly appreciate it! ♥️

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Invoice – Replace Billing Address with Shipping Address If Available’ is closed to new replies.