Month: April 2017

Get all orders of a single customer in WooCommerce by email ID

You can fetch all WooCommerce orders of a single customer by different parameter.
Here you can find all orders of a customer by email id.
Use the following to fetch all orders of a single customer in WooCommerce by email ID.
You have to replace customer email id instead of ‘CUSTOMER_EMAIL_ID_HERE’.

$billing_email='CUSTOMER_EMAIL_ID_HERE';
$customer_orders = get_posts( array(
                    'meta_key'    => '_billing_email',
                    'meta_value'  => $billing_email,
                    'post_type'   => 'shop_order',
                    'post_status' => array_keys( wc_get_order_statuses() ),
                    'numberposts' => -1
                ));

Have any doubt, then comment here!

Get all orders of a single customer in WooCommerce by user ID

You can fetch all WooCommerce orders of a single customer by different parameter.
Here you can find all WooCommerce orders of a customer by user id.
Use the following to fetch all orders of a single customer in WooCommerce by user ID.
You have to replace customer id instead of ‘CUSTOMER_USER_ID_HERE’.

$user_id='CUSTOMER_USER_ID_HERE';
$customer_orders = get_posts( array(
                    'meta_key'    => '_customer_user',
                    'meta_value'  => $user_id,
                    'post_type'   => 'shop_order',
                    'post_status' => array_keys( wc_get_order_statuses() ),
                    'numberposts' => -1
                ));

Have any doubt, then comment here!

Get All WooCommerce Orders for a Customer

There are several ways to get all WooCommerce Orders for a Customer.
Here you can get all Woocommerce orders for a customer by customer email id.
Use the following code to fecth WooCommerce orders for a customer.
The following code will fecth all orders for a current user.

$customer_orders = get_posts( array(    
    'meta_key'    => '_customer_user',
    'meta_value'  => get_current_user_id(),
    'post_type'   => 'shop_order',
    'post_status' => array_keys( wc_get_order_statuses() ),
    'numberposts' => -1
) );

Have any doubt, then comment here!

How to change default product visibility in woocommerce

If you want to change default product visibility in woocommerce then add that following code in your functions.php file.
Here instead of “hidden” change your default visibility values.

function filter_woocommerce_product_visibility_default( $visible ) { 
    return "hidden"; 
	//return your default value here
}; 
add_filter( 'woocommerce_product_visibility_default', 'filter_woocommerce_product_visibility_default', 10, 1 );

Have any doubt, then comment here!

How to remove woocommerce product tabs programmatically

If you want to remove woocommerce product tabs programmatically in WordPress then add that following code in your functions.php file.
Here “woocommerce_product_tabs” filter is used for alter woocommerce product tabs.

add_filter( 'woocommerce_product_tabs', 'woocommerce_remove_product_tabs', 98 );
function woocommerce_remove_product_tabs( $tabs ) {

    unset( $tabs['description'] );      	// Remove the description tab
    unset( $tabs['reviews'] ); 			// Remove the reviews tab
    unset( $tabs['additional_information'] );  	// Remove the additional information tab
    return $tabs;
}

Have any doubt, then comment here!

How to remove woocommerce related products programmatically

If you want to remove woocommerce related products programmatically in WordPress then add that following code in your functions.php file.
Clear the query arguments for related products so none show.

function woocommerce_remove_related_products( $args ) {
	return array();
}
add_filter('woocommerce_related_products_args','woocommerce_remove_related_products', 10); 

Have any doubt, then comment here!

How to hide sale flash content in woocommerce

If you want to hide sale flash content in woocommerce then add that following code in your functions.php file.

add_filter('woocommerce_sale_flash', 'woocommerce_custom_hide_sales_flash');
function woocommerce_custom_hide_sales_flash()
{
    return false;
}

Have any doubt, then comment here!