with latest woocommerce updates my old code stoped working.
Any ideas how to fix it?
I need to add download links (from meta fields) to some products, that have that field not empty.
?></nobr></td>
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>
<td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
</tr>
<?php
}
//mycode started
global $mailto;
if ($mailto == 'user'){
$pen_audio_1 = get_post_meta( $_product->id, 'pen_audio_1', true );
if ($pen_audio_1){
echo '<tr style="background-color:#FFCCCC;"><td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;">';
echo 'Audiofile 1: <a href="my_url/'.$pen_audio_1.'">download</a></td></tr>';
}
$pen_audio_2 = get_post_meta( $_product->id, 'pen_audio_2', true );
if ($pen_audio_2){
echo '<tr style="background-color:#FFCCCC;"><td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;">';
echo 'Audiofile 2: <a href="my_url/'.$pen_audio_2.'">download</a></td></tr>';
}
}
//mycode ended
if ( $show_purchase_note && is_object( $_product ) && ( $purchase_note = get_post_meta( $_product->id, '_purchase_note', true ) ) ) : ?>
- I changed
if ($mailto == 'user'){
toif ( intval($sent_to_admin) == 0 ) {
. - I don't know how to change
get_post_meta( $_product->id, 'pen_audio_1', true );
- I tried
$pen_audio_1 = get_post_meta( $order_obj->get_order_number(), 'pen_audio_1', true );
but it is not working
====================
Finally, I got working code:
global $sent_to_admin;
if ( intval($sent_to_admin) == 0 ) {
$product_id = $product->get_id();
$pen_audio_1 = ''; $pen_audio_1 = get_post_meta( $product_id, 'pen_audio_1', true );
$pen_audio_2 = ''; $pen_audio_2 = get_post_meta( $product_id, 'pen_audio_2', true );
if ($pen_audio_1){
echo '<tr style="background-color:#FFCCCC;"><td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;">';
echo 'Audio 1: <a href="my_url'.$pen_audio_1.'">download</a></td></tr>';
}
if ($pen_audio_2){
echo '<tr style="background-color:#FFCCCC;"><td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;">';
echo 'Audio 2: <a href="my_url'.$pen_audio_2.'">download</a></td></tr>';
}
}