Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('woocommerce_email_after_order_table', 'add_download_links', 10, 4 );
- function add_download_links( $order, $sent_to_admin, $plain_text, $email ) {
- foreach( $order->get_items() as $item_id => $item ) {
- if( $files_meta = $item->get_meta( '_dndmfu_wc_files' ) ) {
- $files = maybe_unserialize( $files_meta );
- if( isset( $files['files'] ) ) {
- foreach( $files['files'] as $file ) {
- $data[] = wp_basename( pathinfo( $file, PATHINFO_DIRNAME ) ).'/'. wp_basename( $file );
- }
- }
- }
- }
- if( $data ) {
- $nonce = wp_create_nonce( 'dndmfu_wc_download' );
- $post_id = (int)$order->get_id();
- echo '<div style="margin-bottom: 40px;">';
- echo '<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;" border="1">';
- echo '<tbody>';
- echo '<tr><td>Files</td></tr>';
- echo '<tr>';
- echo '<td style="border:1px solid #e5e5e5;">';
- echo '<a href="'.site_url('wp-admin').'/post.php?post='.$post_id.'&action=edit&cd_action=dndmfu_wc_download&files='.implode(',', $data ).'&security='.$nonce.'">Download Zip</a></a>';
- echo '</td>';
- echo '</tr>';
- echo '</tbody>';
- echo '</table>';
- echo '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement