pdf capability
-
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]
-
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.
sorry this is not work for me
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>'; } } ?>Can show the product description but the description can’t display over a page in pdf which inside <table>.
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=sharingtable 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; ?>https://drive.google.com/file/d/1-JNYOyGXPEcFSBPuKRlLz8DWtkhPmbMA/view?usp=sharing
this is the outlook of invoice my preference :((
Hi @potterleung
Does the product description take the whole page?
hi @alexmigf. Yes, it over a whole page cause a lot of words.
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>'; } } ?>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.
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.
The price is showing with 2 row:
$
9,600.00How can let it be one row: $9,600.00
Hi @potterleung
Can you add a screenshot here?
Another question, how can I no show payment method and payment instruction in the total section?
The topic ‘pdf capability’ is closed to new replies.