Category: PHP

Get list of all woocommerce orders by date

If you want to get list of all woocommerce orders by date then using below code. Here change the value of $your_date by yourself.
Assign particular date to $your_date. This code will return the list of woocommerce orders placed in a particular date.

	$your_date = '2016-09-23';
	$args = array(
			'post_type' => 'shop_order',
			'post_status' => 'publish',
			'posts_per_page' => -1,
			'date_query'=> array(
					'after' => $your_date,
					'inclusive' => true,
					)
		);
	$orders = get_posts($args);

Have any doubt, then comment here!

Set blog page programmatically in WordPress

If you want to set blog page programmatically in WordPress then add that following code in your functions.php file. First you have to make sure that blog page is exists or not. if its no exists then create it. After that add that following code in your functions.php file

$blog   = get_page_by_title( 'Blog' );
update_option( 'page_for_posts', $blog->ID );

Have any doubt, then comment here!

Set front page programmatically in WordPress

If you want to set front page programmatically in WordPress then add that following code in your functions.php file. First you have to make sure that front page is exists or not. if its no exists then create it. After that add that following code in your functions.php file

$home = get_page_by_title( 'Home' );
update_option( 'page_on_front', $home->ID );
update_option( 'show_on_front', 'page' );

Have any doubt, then comment here!

Change Payment Method Label on Checkout

There is no hooks available to change payment method label in woocommerce checkout page. You can change this label by use your woocommerce checkout settings.

For example
http://www.boopathirajan.com/wp-admin/admin.php?page=wc-settings&tab=checkout

Here replace http://www.boopathirajan.com instead of your web site name.

Reserved Terms in WordPress

Enable revisions for custom post type in WordPress

When you register custom post type, you have to add support for revisions. Title and text editor is the default support. if you want to enable revisions for your custom post type then you have to add like this.

'supports' => array( 'title', 'editor', 'revisions' ),

Add this code in your custom post type creation arguments array. for your information i listed available supports below.

1.'title'
2.'editor' 
3.'author'
4.'thumbnail' 
5.'excerpt'
6.'trackbacks'
7.'custom-fields'
8.'comments' 
9.'revisions' 
10.'page-attributes' 
11.'post-formats'

Have any doubt, then comment here!

Change the WooCommerce continue shopping URL in WordPress

If you want to change the WooCommerce continue shopping URL in WordPress, then place the place the following snippet in functions.php file within your theme folder!.

The WooCommerce continue shopping button will use your shop archive to send customers back to the shop page. The following code will redirect to home page when you click continue shopping button in your cart page.

function change_continue_shopping_button_url() {
	return site_url();	
}
add_filter( 'woocommerce_continue_shopping_redirect', 'change_continue_shopping_button_url' );

Have any doubt, then comment here!