• I added product description in invoice.php, but my description is long that the words can’t cross over a page in pdf. How can I solve this problem? Cause my item need a long desciption

    <?php
    if (!empty($item[‘product’])) {
    $_product = $item[‘product’]->is_type( ‘variation’ ) ? wc_get_product( $item[‘product’]->get_parent_id() ) : $item[‘product’];
    if ( method_exists( $_product, ‘get_description’ ) ) {
    echo $_product->get_description();
    }
    }
    ?>

    I added this coding in <table class=”order-details”>

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @potterleung

    Please try this instead:

    <?php
    	if (!empty($item[‘product’])) {
    		$_product = $item[‘product’]->is_type( ‘variation’ ) ? wc_get_product( $item[‘product’]->get_parent_id() ) : $item[‘product’];
    		if ( method_exists( $_product, ‘get_description’ ) ) {
    			echo '<div style="word-wrap:break-word;">'.$_product->get_description().'</div>';
    		}
    	}
    ?>

    Let me know.

    Thread Starter potterleung

    (@potterleung)

    sorry this is not work for me

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @potterleung

    Well, I test myself and is working fine, but maybe because of the apostrophes are wrong could lead to an error, try this:

    <?php
    	if (!empty($item['product'])) {
    		$_product = $item['product']->is_type( 'variation' ) ? wc_get_product( $item['product']->get_parent_id() ) : $item['product'];
    		if ( method_exists( $_product, 'get_description' ) ) {
    			echo '<div style="word-wrap:break-word;">'.$_product->get_description().'</div>';
    		}
    	}
    ?>
    Thread Starter potterleung

    (@potterleung)

    Can show the product description but the description can’t display over a page in pdf which inside <table>.

    https://myweb.hk/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=invoice&order_ids=4710&_wpnonce=583ec8fd2f

    You can see the second and third product item description can’t show all of them.

    My invoice.php at below:
    https://drive.google.com/file/d/1vhOEafEx1rge1yfQb4Drjd9KyJrve-v5/view?usp=sharing

    table coding:
    <table class=”order-details”>
    <thead>
    <tr>
    <th class=”product”><?php _e(‘Product’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <th class=”quantity”><?php _e(‘Quantity’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <th class=”price”><?php _e(‘Price’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    </tr>
    </thead>

    <tbody>
    <?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
    <tr class=”<?php echo apply_filters( ‘wpo_wcpdf_item_row_class’, $item_id, $this->type, $this->order, $item_id ); ?>”>
    <td class=”product”>
    <?php $description_label = __( ‘Description’, ‘woocommerce-pdf-invoices-packing-slips’ ); // registering alternate label translation ?>
    <span class=”item-name”><?php echo $item[‘name’]; ?></span>
    <?php do_action( ‘wpo_wcpdf_before_item_meta’, $this->type, $item, $this->order ); ?>
    <span class=”item-meta”><?php echo $item[‘meta’]; ?></span>
    <div class=”meta”>
    <?php
    if (!empty($item[‘product’])) {
    $_product = $item[‘product’]->is_type( ‘variation’ ) ? wc_get_product( $item[‘product’]->get_parent_id() ) : $item[‘product’];
    if ( method_exists( $_product, ‘get_description’ ) ) {
    echo ‘<div style=”word-wrap:break-word;”>’.$_product->get_description().'</div>’;
    }
    }
    ?>
    <?php do_action( ‘wpo_wcpdf_after_item_meta’, $this->type, $item, $this->order ); ?>
    </td>

    <td class=”quantity”><?php echo $item[‘quantity’]; ?></td>
    <td class=”price”><?php echo $item[‘order_price’]; ?></td>
    </tr>
    <?php endforeach; endif; ?>

    Thread Starter potterleung

    (@potterleung)

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @potterleung

    Does the product description take the whole page?

    Thread Starter potterleung

    (@potterleung)

    hi @alexmigf. Yes, it over a whole page cause a lot of words.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @potterleung

    If is taking the full height of the page the only solution is to decrease the font size of it, and even that couldn’t be enough.

    Try this:

    <?php
    	if (!empty($item['product'])) {
    		$_product = $item['product']->is_type( 'variation' ) ? wc_get_product( $item['product']->get_parent_id() ) : $item['product'];
    		if ( method_exists( $_product, 'get_description' ) ) {
    			echo '<div style="word-wrap:break-word; font-size:6pt; line-height:normal;">'.$_product->get_description().'</div>';
    		}
    	}
    ?>
    Thread Starter potterleung

    (@potterleung)

    It’s sad that this is not work for me. the words is too small and my description is much more. I found that if the description not in table which can over a page, but will be not organized if more that one product. Maybe I try to find other plugin to fix it.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @potterleung

    The order items work as a block, when the page doesn’t have space enough for it’s height it goes to the next page. In your case the height is superior to the page available space, even if the item is alone it’s height is superior to the space available and that’s why he gets cut.

    Unfortunately I’m not seeing a solution for that but I will ask my colleagues if they have another idea.

    Thread Starter potterleung

    (@potterleung)

    https://myweb.hk/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=invoice&order_ids=4807&_wpnonce=4f600842c9

    The price is showing with 2 row:
    $
    9,600.00

    How can let it be one row: $9,600.00

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @potterleung

    Can you add a screenshot here?

    Thread Starter potterleung

    (@potterleung)

    Thread Starter potterleung

    (@potterleung)

    Thread Starter potterleung

    (@potterleung)

    Another question, how can I no show payment method and payment instruction in the total section?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘pdf capability’ is closed to new replies.