You can use the WC_Order object for get order date from order id.
if you have the order ID then use the following code to fetch order date.
$order = new WC_Order($order_id); $order_date = $order->order_date;
Have any doubt, then comment here!
WordPress/PHP Developer Chennai
You can use the WC_Order object for get order date from order id.
if you have the order ID then use the following code to fetch order date.
$order = new WC_Order($order_id); $order_date = $order->order_date;
Have any doubt, then comment here!
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!
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!
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!
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!
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!
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!
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!
To load default jquery core file from CDN to WordPress, you need to simply copy and paste the following code in your theme’s functions.php file.
function replace_jquery() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', 'https://code.jquery.com/jquery-1.12.4.min.js', false, '1.12.4'); wp_enqueue_script('jquery'); } } add_action('init', 'replace_jquery');
Have any doubt, then comment here!
To add a new menu/tab to the WordPress toolbar, you need to simply copy and paste the following code in your theme’s functions.php file.
add_action( 'admin_bar_menu', 'add_toolbar_link_top', 999 ); function add_toolbar_link_top( $wp_admin_bar ) { $args = array( 'id' => 'your-id', 'title' => 'Your Title', 'href' => site_url(), 'meta' => array( 'class' => 'your-class-name' ) ); $wp_admin_bar->add_node( $args ); }
This code will add new menu in WordPress toolbar.
Have any doubt, then comment here!