/*
Theme Name: Porto Child
Theme URI: https://www.portotheme.com/wordpress/porto
Author: P-THEMES
Author URI: https://www.portotheme.com/
Description: Porto Responsive WordPress + eCommerce Theme.
Version: 1.1
Template: porto
License: Commercial
License URI: http://themeforest.net/licenses/regular_extended
Tags: woocommerce, corporate, ecommerce, responsive, blue, black, green, white, light, dark, red, two-columns, three-columns, four-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready
*/

/*************** ADD YOUR CUSTOM CSS HERE  ***************/

function my_login_logo() { ?>
    <style type="text/css">
        body.login div#login h1 a {
	        background-image: url(https://webaholics.co/wp-content/uploads/Webaholics_logo_transparent-web1.png);
		padding-bottom: 30px;
		width: 320px;
		background-size: 300px;
                height: 150px;
        }
    </style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );

function my_login_logo_url() {
    return 'http://webaholics.co?utm_source=webaholics%20branding&utm_medium=site%20login&utm_campaign=' . home_url();
}
add_filter( 'login_headerurl', 'my_login_logo_url' );


// New order emails
		remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
		remove_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
		remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
		remove_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
		remove_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
		remove_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );


//Remove Price Data from Emails
function ymcode_hide_shipping_row_with_css()
{
	?>
	<style>
		table table table table th:last-child,
		table table table table .order_item td:last-child,
		table table table table tfoot {
			display: none;
		}    	
    </style>
	<?php
}
?>

add_filter( 'woocommerce_get_order_item_totals', function( $total_rows, $order, $tax_display ){

    // Only for "Free Shipping" method
    if( ! $order->has_shipping_method('free_shipping') || is_account_page() || is_wc_endpoint_url( 'order-received' ) )
        return $total_rows; 

    unset($total_rows['shipping']);

    return $total_rows;
}, 11, 3 );

function cw_add_wc_order_email_images( $output, $order ) {
   static $run = 0;
   if ( $run ) {
        return $output;
    }
   $args = array(
        'order'                 => $order,
        'items'                 => $order->get_items(),
        'show_download_links'   => $show_download_links,
        'show_sku'              => true,
        'show_purchase_note'    => $show_purchase_note,
        'show_image'   	=> true,
        'image_size'    => array( 100, 50 )
    );
   $run++;
   return $order->email_order_items_table( $args );
}
add_filter( 'woocommerce_email_order_items_table', 'cw_add_wc_order_email_images' );

function cw_edit_order_item_name( $name ) {
    return $name . '<br />';
}
add_filter( 'woocommerce_order_item_name', 'cw_edit_order_item_name' );