-
-
Save jsakhil/c94b31616f5e898c71de0f5aaab73640 to your computer and use it in GitHub Desktop.
Woo Commerce Hooks and Tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////// Rename or remove order statuses ////// | |
add_filter('wc_order_statuses', 'wc_renaming_order_status'); | |
function wc_renaming_order_status($order_statuses) { | |
$order_statuses = array( | |
'wc-pending' => _x('Pending', 'Order status', 'woocommerce'), | |
'wc-processing' => _x('New Order', 'Order status', 'woocommerce'), | |
'wc-cancelled' => _x('Cancelled', 'Order status', 'woocommerce'), | |
'wc-completed' => _x('Approved', 'Order status', 'woocommerce'), | |
'wc-on-hold' => _x('On Hold', 'Order status', 'woocommerce'), | |
'wc-refunded' => _x('Refunded', 'Order status', 'woocommerce'), | |
'wc-failed' => _x('Failed', 'Order status', 'woocommerce'), | |
); | |
return $order_statuses; | |
} | |
function hide_wc_order_statuses( $order_statuses ) { | |
// Hide core statuses | |
unset( $order_statuses['wc-refunded'] ); | |
unset( $order_statuses['wc-on-hold'] ); | |
unset( $order_statuses['wc-failed'] ); | |
return $order_statuses; | |
} | |
add_filter( 'wc_order_statuses', 'hide_wc_order_statuses' ); | |
////// End of Rename or remove order statuses ////// | |
////// ADDING COLUMN TITLES to orders admin list /////// | |
//add columns | |
add_filter('manage_edit-shop_order_columns', 'custom_shop_order_column', 11); | |
function custom_shop_order_column($columns) { | |
$cols = array(); | |
foreach ($columns as $ck => $c) { | |
if ($ck == 'customer_message') { | |
$cols['user_status'] = __('User Status', 'woocommerce'); | |
$cols['order_type'] = __('Order Type', 'woocommerce'); | |
} else { | |
$cols[$ck] = $c; | |
} | |
} | |
return $cols; | |
} | |
// add the data for each orders by column | |
add_action('manage_shop_order_posts_custom_column', 'cbsp_credit_details', 10, 2); | |
function cbsp_credit_details($column) { | |
global $post, $woocommerce, $the_order; | |
$order_id = $the_order->id; | |
switch ($column) { | |
case 'user_status' : | |
echo $u_st = get_user_meta($the_order->customer_user, 'user_status', 1); | |
break; | |
case 'order_type' : | |
$tp = get_post_meta($order_id, 'delivery_type', 1); | |
echo $tp == 'dzone' ? 'Delivery' : 'Pickup'; | |
break; | |
} | |
} | |
////// end of ADDING COLUMN TITLES to orders admin list /// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment